0
1
I'm testing transcoding from rtmp to hls. As I see, ffmpeg seems to flush every 256k to file. I tried several options like bufsize
, flush_packets
but it didn't work. I want to flush frame video as soon as possible.
My command is:
/usr/bin/ffmpeg -i rtmp://localhost:1935/live/test -y -acodec copy -vcodec copy -hls_time 2 -hls_list_size 8 -pix_fmt yuv420p -keyint_min 60 -flush_packets 1 -hls_segment_filename /tmp/test/%3d.ts -hls_flags delete_segments /tmp/test/_tmp.m3u8
I use ffmpeg version 3.4.6.
Thanks.
Share the commands you tried. – Gyan – 2019-07-05T15:17:41.130
I updated my question. – newvalue – 2019-07-06T01:03:28.720
Add
-avioflags +direct -hls_ts_options fflags=+flush_packets
and check. – Gyan – 2019-07-06T05:01:57.990It doesn't work. To eliminate other issues related to rtmp, I try to test to transcode from file:
I monitor the changing in the directory, and here is the log:
After diving in ffmpeg codebase, I found that ffmpeg change buffer size to 256k when output to file. I tried to remove this code and it worked well.
https://github.com/FFmpeg/FFmpeg/blob/3e10223385b83358f013cbf6ba069f15fedc731a/libavformat/file.c#L238
Yes, but that requires code maintenance. flush_packets overrides that but the hls muxer isn't passing that to child muxers, based on your results. Add an option to the hls muxer to adjust the AVIOContext of the child muxers to enable flush_packets – Gyan – 2019-07-06T10:57:25.177