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

Simon Brown simon.k.brown at gmail.com
Tue Feb 18 18:24:51 EET 2020


>
>
> Thanks - I'm not re-encoding at the moment because I can't afford the CPU
> time.  I'll tune the encoder that is generating the stream for a suitable
> GOP size.
>
> I've tried your options, Dennis and much the same result:
>
> C:\ffmpeg-20200216-8578433-win64-static\bin>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
> 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
> [h264 @ 0000018f6b0d1980] non-existing PPS 0 referenced
>     Last message repeated 1 times
> [h264 @ 0000018f6b0d1980] decode_slice_header error
> [h264 @ 0000018f6b0d1980] no frame!
> [h264 @ 0000018f6b0d1980] non-existing PPS 0 referenced
>     Last message repeated 2 times
> [h264 @ 0000018f6b0d1980] decode_slice_header error
> [h264 @ 0000018f6b0d1980] no frame!
> [h264 @ 0000018f6b0d1980] non-existing PPS 0 referenced
> [h264 @ 0000018f6b0d1980] decode_slice_header error
> [h264 @ 0000018f6b0d1980] no frame!
> [h264 @ 0000018f6b0d1980] non-existing PPS 0 referenced
>     Last message repeated 2 times
> [h264 @ 0000018f6b0d1980] decode_slice_header error
> [h264 @ 0000018f6b0d1980] no frame!
> [h264 @ 0000018f6b0d1980] non-existing PPS 0 referenced
> [h264 @ 0000018f6b0d1980] decode_slice_header error
> [h264 @ 0000018f6b0d1980] no frame!
> [h264 @ 0000018f6b0d1980] non-existing PPS 0 referenced
>     Last message repeated 2 times
> [h264 @ 0000018f6b0d1980] decode_slice_header error
> [h264 @ 0000018f6b0d1980] no frame!
> [h264 @ 0000018f6b0d1980] non-existing PPS 0 referenced
> [h264 @ 0000018f6b0d1980] decode_slice_header error
> [h264 @ 0000018f6b0d1980] no frame!
> [h264 @ 0000018f6b0d1980] non-existing PPS 0 referenced
>     Last message repeated 2 times
> [h264 @ 0000018f6b0d1980] decode_slice_header error
> [h264 @ 0000018f6b0d1980] no frame!
> [h264 @ 0000018f6b0d1980] non-existing PPS 0 referenced
> [h264 @ 0000018f6b0d1980] decode_slice_header error
> [h264 @ 0000018f6b0d1980] no frame!
> [h264 @ 0000018f6b0d1980] non-existing PPS 0 referenced
>     Last message repeated 1 times
> [h264 @ 0000018f6b0d1980] decode_slice_header error
> [h264 @ 0000018f6b0d1980] no frame!
> Input #0, mpegts, from 'udp://127.0.0.1:9034':
>   Duration: N/A, start: 34730.859244, bitrate: N/A
>   Program 1
>     Stream #0:0[0x1100]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
> yuv420p(tv, top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k
> tbn, 50 tbc
>     Stream #0:1[0x1110]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000
> Hz, stereo, fltp, 48 kb/s
> [dash @ 0000018f6e3eec80] No bit rate set for stream 0
> [dash @ 0000018f6e3eec80] Opening 'init-stream0.m4s' for writing
> [mp4 @ 0000018f6b0bac40] 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
>
> Thanks,
> Simon
>
Ok, some progress - I have a stream that plays, but only because I'm
re-encoding it.
Is the codec tag h264 different to what libx264 produces?  Is there a
reason it can't work with h264 codec tag?
Anyway, the command line I'm now using is this:
C:\xampp\htdocs>C:\ffmpeg-20200216-8578433-win64-static\bin\ffmpeg.exe -i
udp://127.0.0.1:9034 -c:v libx264 -b:v 5000k -preset ultrafast -an -flags
+global_header -flags +cgop -g 5 -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"
c:\xampp\htdocs\test.m3u8

This seems to work, and the stream is live and hls.js keeps up, but it's
still got 2.5 seconds latency.  Given that the gop size is 5 I'd have
thought it should be more like 0.6s latency, or is the fact that x264 is
dropping frames to keep up meaning that the GOP size is relative to the
output frame rate not the input frame rate?

As it is, this can't be a final solution because I cannot afford the
re-encoding CPU time, nor can I generate the original stream with a GOP
size of 5 without compromising other features.  Is there no way that LHLS
can wait for an I-frame and then start playing immediately it receives it?

Cheers,
Simon


More information about the ffmpeg-user mailing list