Add rotation metadata if initially in portrait mode

YouTube ignores it though - only supports landscape
This commit is contained in:
David Halls
2021-07-18 07:32:31 +01:00
parent 2767c05572
commit 8be5ea5d51
2 changed files with 5 additions and 3 deletions

View File

@@ -180,7 +180,7 @@ async function start() {
}
// start HLS from the canvas stream to the ingestion URL
hls = new HLS(canvas_stream, ingestion_url, ffmpeg_lib_url, frame_rate);
hls = new HLS(canvas_stream, ingestion_url, ffmpeg_lib_url, frame_rate, portrait);
hls.addEventListener('run', () => console.log('HLS running'));
hls.addEventListener('exit', ev => {
const msg = `HLS exited with status ${ev.detail.code}`;

View File

@@ -3,15 +3,16 @@ import { MuxReceiver } from './mux-receiver.js';
const audioBitsPerSecond = 128 * 1000;
const videoBitsPerSecond = 2500 * 1000;
const key_frame_interval = 10;
const key_frame_interval = 3;
export class HLS extends EventTarget {
constructor(stream, base_url, ffmpeg_lib_url, frame_rate) {
constructor(stream, base_url, ffmpeg_lib_url, frame_rate, portrait) {
super();
this.stream = stream;
this.base_url = base_url;
this.ffmpeg_lib_url = ffmpeg_lib_url;
this.frame_rate = frame_rate;
this.portrait = portrait;
this.update_event = new CustomEvent('update');
}
@@ -255,6 +256,7 @@ export class HLS extends EventTarget {
'-map', '0:v',
'-map', '0:a',
'-c:v', 'copy', // pass through the video data (h264, no decoding or encoding)
...(this.portrait ? ['-metadata:s:v:0', 'rotate=-90'] : []),
'-c:a', 'aac', // re-encode audio as AAC-LC
'-b:a', audioBitsPerSecond.toString() // set audio bitrate
]