[FFmpeg-user] How to transcode to HLS and DASH with mp4 and webm all at once
Stefan Oltmanns
stefan-oltmanns at gmx.net
Tue Oct 11 15:32:50 EEST 2022
Hello,
after a lot of experimentation I managed to have DASH and HLS output in
the same encoding.
Only thing I cannot get to work is not encoding the audio multiple
times: HLS cannot map a stream multiple times and while tee can
duplicate a stream to multiple outputs, it cannot duplicate a stream to
the same output (I had a quick look at the source, there is a map
input->output, that wouldn't work if you have multiple outputs for one
stream).
Is there any way to duplicate a stream after it has been encoded?
Or is there any other solution than to encode the audio multiple times?
Best regards
Stefan
Am 09.10.22 um 17:53 schrieb Stefan Oltmanns:
> Hello,
>
> I would like ffmpeg to transcode a file into different versions for
> adaptive streaming (different codecs, different resolutions, different
> bitrates):
>
> DASH with webm (av1, opus) and MP4 (h264, aac)
> HLS with MPEG2-TS (h264, aac)
>
> While it is easy to find example command-lines for each of these formats
> (webm-DASH, MPEG-DASH or HLS) I currently fail at two things:
>
> -I would like to use one DASH manifest for webm and mp4 files. I'm not
> sure if this is possible in general and if supported by ffmpeg. I would
> like the player (scala with video.js) to choose the best codec for the
> client.
>
> -I would like to prevent unnecessary encoding: The x264 encoder output
> (same for aac) for each resolution/bandwidth should be used for DASH and
> HLS. There is the tee-muxer that seems to be designed for that, but I
> cannot figure out how to use it in such a complex situation.
>
> Can somebody give me an example howto
> a) extend my (simplified) command-line to also generate a HLS output for
> the h264/aac stream
> b) generate a DASH manifest for all currently generated output files
>
> ffmpeg -i $VIDEO_IN\
> -filter_complex
> '[0:v]split=2[in1][in2];[in1]scale=w=1920:h=1080,split=2[1080a][1080b];[in2]scale=w=1280:h=720,split=2[720a][720b]'
>
> \
> -map [720a] -keyint_min 100 -g 100 -c:v libsvtav1 -crf:v 25
> -maxrate 2000k -bufsize 3M -f webm -dash 1 output_dash/video_720.webm \
> -map [720b] -keyint_min 100 -g 100 -c:v libx264 -crf:v 23 -maxrate
> 2000k -bufsize 3M -f mp4 -movflags dash output_dash/video_720.mp4 \
> -map [1080a] -keyint_min 100 -g 100 -c:v libsvtav1 -crf:v 25
> -maxrate 5000k -bufsize 8M -f webm -dash 1 output_dash/video_1080.webm \
> -map [1080b] -keyint_min 100 -g 100 -c:v libx264 -crf:v 23 -maxrate
> 5000k -bufsize 8M -f mp4 -movflags dash output_dash/video_1080.mp4 \
> -map a:0 -c:a libopus -b:a 64k -ac 1 -ar 48000 -f webm -dash 1
> output_dash/audio_mono_64k.webm \
> -map a:0 -c:a libopus -b:a 128k -ar 48000 -f webm -dash 1
> output_dash/audio_stereo_128k.webm \
> -map a:0 -c:a libfdk_aac -b:a 64k -ac 1 -ar 48000 -f mp4 -movflags
> dash output_dash/audio_mono_64k.mp4 \
> -map a:0 -c:a libfdk_aac -b:a 128k -ar 48000 -f mp4 -movflags dash
> output_dash/audio_stereo_128k.mp4
>
> Best regards
> Stefan
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-user
mailing list