[FFmpeg-user] Using FFMpeg to produce LL-HLS

Dennis Mungai dmngaie at gmail.com
Mon Feb 17 17:08:55 EET 2020


On Mon, 17 Feb 2020 at 17:26, Simon Brown <simon.k.brown at gmail.com> wrote:
>
> On Mon, 17 Feb 2020 at 12:06, Dennis Mungai <dmngaie at gmail.com> wrote:
>
> > On Mon, 17 Feb 2020, 14:50 Simon Brown, <simon.k.brown at gmail.com> wrote:
> >
> > > I'm trying to reduce the latency of streaming video to a web page.
> > > I have tried a few options:
> > > 1) WebRTC - great, but doesn't support interlaced video
> > > 2) fMP4 - couldn't get a working solution
> > > 3) HLS - great, plays interlaced video as well, but latency is appalling
> > > 4) LL-HLS - can't find anything that produces it.
> > >
> > > Does FFMpeg support generating LL-HLS?
> > >
> > > Regards,
> > > Simon
> > >
> >
> > Yes, though at the moment you'll have to use the dash muxer.
> >
> > See ffmpeg -h muxer=dash
> >
> > For usage.
> >
> > >
> > _______________________________________________
> > 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".
>
>
> Thanks Dennis,
> I've read through the options and looked at some examples and have
> downloaded the latest FFMpeg build from zeranoe (nightly build).  That
> produces this result:
>
> C:\ffmpeg-20200216-8578433-win64-static\bin>ffmpeg.exe -i udp://
> 127.0.0.1:9034 -codec copy -f dash -seg_duration 1 -frag_duration 0.1
> -window_size 5 -extra_window_size 5 -single_file 0 -lhls 1 -hls_playlist 1
> -strict experimental -streaming 1 -adaptation_sets "id=0,streams=v
> id=1,streams=a" c:\xampp\htdocs\video.m3u8
> ffmpeg version git-2020-02-16-8578433 Copyright (c) 2000-2020 the FFmpeg
> developers
>   built with gcc 9.2.1 (GCC) 20200122
>   configuration: --enable-gpl --enable-version3 --enable-sdl2
> --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass
> --enable-libdav1d --enable-libbluray --enable-libfreetype
> --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
> --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy
> --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx
> --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
> --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp
> --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc
> --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom
> --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va
> --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
> --enable-libopenmpt --enable-amf
>   libavutil      56. 41.100 / 56. 41.100
>   libavcodec     58. 70.100 / 58. 70.100
>   libavformat    58. 38.101 / 58. 38.101
>   libavdevice    58.  9.103 / 58.  9.103
>   libavfilter     7. 76.100 /  7. 76.100
>   libswscale      5.  6.100 /  5.  6.100
>   libswresample   3.  6.100 /  3.  6.100
>   libpostproc    55.  6.100 / 55.  6.100
> Input #0, mpegts, from 'udp://127.0.0.1:9034':
>   Duration: N/A, start: 68873.648600, bitrate: N/A
>   Program 1
>     Stream #0:0[0x1100]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
> yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k
> tbn, 100 tbc
>     Stream #0:1[0x1110]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000
> Hz, stereo, fltp, 192 kb/s
> [dash @ 0000022f500c6a40] No bit rate set for stream 0
> [dash @ 0000022f500c6a40] Opening 'init-stream0.m4s' for writing
> [mp4 @ 0000022f4e21ac00] Could not find tag for codec h264 in stream #0,
> codec not currently supported in container
> Could not write header for output file #0 (incorrect codec parameters ?):
> Invalid argument
> Stream mapping:
>   Stream #0:0 -> #0:0 (copy)
>   Stream #0:1 -> #0:1 (copy)
>     Last message repeated 1 times
>
> What am I doing wrong?  I thought h264 was supported in HLS/Dash?
>
> Regards,
> Simon

Hey there,

Try this instead:

ffmpeg.exe -i udp://127.0.0.1:9034 -codec copy -bsf:a aac_adtstoasc
-flags +global_header -f dash ^
-seg_duration 1 -frag_duration 0.1 -window_size 5 -extra_window_size 5
-single_file 0 -lhls 1 -hls_playlist 1 ^
-strict experimental -streaming 1 -adaptation_sets "id=0,streams=v
id=1,streams=a" c:\xampp\htdocs\video.m3u8

Then report back.

Btw I'd recommend re-encoding the content wherever possible. A fixed
GOP size combined with the -flags +cgop with an encoder such as
libx264 produces the best results.
The GOP size should ideally be a fraction of the segment length, eg 2
seconds. The codec neutral option -g 2 should set that for you.


More information about the ffmpeg-user mailing list