Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#6043 closed defect (wontfix)

hls muxer states "failed to delete old segment" but not

Reported by: doubleb Owned by: stevenliu
Priority: normal Component: undetermined
Version: unspecified Keywords: hls
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
ffmpeg hls mixer gives misleading erros using use_localtime option and some complex filter graphs.

[hls muxer @ 0x2693700] failed to delete old segment segment20161224035418.ts: No such file or directory

This error message is misleading because ffmpeg did deleted segment file, but as you can see from debug log output, ffmpeg tries to delete these segment files twice and of cource second attempt will fail.
This misbehaving relates to use_localtime because without this option old segment files deletion is normal.
I have tested and this phenomane is not always occurs, it requires a certain filter graph. If you alter the graph expression in my example command line the error messages will disapper. Maybe is this a memory handling error?
This error could be reproduced with newest and and old version N-78237-g70742e5 also.

How to reproduce:

./ffmpeg_g -loglevel info -report -v 9 -loglevel 99   -y -f lavfi -i color=c=red:size=640x480:r=25 -f lavfi -f lavfi -i color=c=pink:size=1920x1080:r=25 -f lavfi -i anullsrc=r=44100:cl=stereo  -f lavfi -i anullsrc=r=44100:cl=stereo -filter_complex "[1]setpts=PTS-STARTPTS[1o]; [0:v]setpts=PTS-STARTPTS [0vo]; [1o][0vo] overlay=x=10:y=10 ,  split=3 [v1][v2][vimg] ; [v1] scale=size=960x540, setdar=dar=16/9 [vout1] ; [v2] scale=size=640x360,  setdar=dar=16/9 [vout2] ; [vimg] fps=1/5, scale=size=320x180 [voutimg] ; [3]asetpts=PTS-STARTPTS [0ao]; [2]asetpts=PTS-STARTPTS [2o]; [0ao][2o] amix, asplit=2 [aout1][aout2] " -map "[vout1]"  -vcodec rawvideo -f null dummy  -map "[aout1]"  -acodec aac -cutoff 20000 -ac 2 -ar 44100 -ab 192k  -f hls -hls_time 3 -hls_list_size 5 -hls_flags delete_segments -use_localtime 1 -hls_segment_filename '/dev/shm/segment%Y%m%d%H%M%S.ts' /dev/shm/stream.m3u8 -map "[vout2]" -map "[aout2]" -vcodec rawvideo -acodec pcm_s16le -f null dummy  -map "[voutimg]"  -f null dummy

ffmpeg version:

ffmpeg version N-82911-gea93052 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
  configuration: --enable-gpl --enable-libfreetype --enable-libzmq --enable-nonfree --disable-shared
  libavutil      55. 43.100 / 55. 43.100
  libavcodec     57. 70.100 / 57. 70.100
  libavformat    57. 61.100 / 57. 61.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 68.100 /  6. 68.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100

Full output of report is attached.

Attachments (1)

ffmpeg-20161224-034525.log (1.3 MB) - added by doubleb 2 years ago.
report ouput

Download all attachments as: .zip

Change History (10)

Changed 2 years ago by doubleb

report ouput

comment:1 Changed 2 years ago by doubleb

  • Summary changed from hls muxer failed to delete old segment to hls muxer states failed to delete old segment but not

comment:2 Changed 2 years ago by doubleb

  • Summary changed from hls muxer states failed to delete old segment but not to hls muxer states "failed to delete old segment" but not

comment:3 Changed 2 years ago by doubleb

An even simpler command line to reproduce the error: (wait 50 seconds after starting)

ffmpeg -loglevel info   -y -f lavfi -i color=c=red:size=640x480:r=25 -f lavfi -f lavfi -i color=c=pink:size=1920x1080:r=25 -f lavfi -i anullsrc=r=44100:cl=stereo  -f lavfi -i anullsrc=r=44100:cl=stereo -filter_complex "[1]setpts=PTS-STARTPTS[1o]; [0:v]setpts=PTS-STARTPTS [0vo]; [1o][0vo] overlay=x=10:y=10 ,  split=3 [v1][v2][vimg] ; [v1] scale=size=960x540, setdar=dar=16/9, nullsink ; [v2] scale=size=640x360,  setdar=dar=16/9 , nullsink ; [vimg] fps=1/5, scale=size=320x180, nullsink ; [3]asetpts=PTS-STARTPTS [0ao]; [2]asetpts=PTS-STARTPTS [2o]; [0ao][2o] amix [aout1] "   -map "[aout1]"  -acodec aac -cutoff 20000 -ac 2 -ar 44100 -ab 192k  -f hls -hls_time 3 -hls_list_size 5 -hls_flags delete_segments -use_localtime 1 -hls_segment_filename 'segment%Y%m%d%H%M%S.ts' stream.m3u8}}}

comment:4 Changed 2 years ago by stevenliu

  • Owner set to stevenliu
  • Status changed from new to open

comment:5 Changed 2 years ago by stevenliu

Perhaps this is not hlsenc problem, i add debug message into hlsenc, and test it use your reproduce way, the m3u8 list like this:

localhost:hlsenc StevenLiu?$ ./ffmpeg -re -loglevel info -y -f lavfi -i color=c=red:size=640x480:r=25 -f lavfi -f lavfi -i color=c=pink:size=1920x1080:r=25 -f lavfi -i anullsrc=r=44100:cl=stereo -f lavfi -i anullsrc=r=44100:cl=stereo -filter_complex "[1]setpts=PTS-STARTPTS[1o]; [0:v]setpts=PTS-STARTPTS [0vo]; [1o][0vo] overlay=x=10:y=10 , split=3 [v1][v2][vimg] ; [v1] scale=size=960x540, setdar=dar=16/9, nullsink ; [v2] scale=size=640x360, setdar=dar=16/9 , nullsink ; [vimg] fps=1/5, scale=size=320x180, nullsink ; [3]asetpts=PTS-STARTPTS [0ao]; [2]asetpts=PTS-STARTPTS [2o]; [0ao][2o] amix [aout1] " -map "[aout1]" -acodec aac -cutoff 20000 -ac 2 -ar 44100 -ab 192k -f hls -hls_time 3 -hls_list_size 20 -hls_flags delete_segments -use_localtime 1 -hls_segment_filename 'segment%Y%m%d%H%M%S.ts' stream.m3u8
ffmpeg version N-82785-g6b95da9 Copyright (c) 2000-2016 the FFmpeg developers

built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
configuration: --enable-libass --enable-opengl --enable-libx264 --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local --enable-libopencv --enable-libtesseract --enable-libspeex --enable-libfreetype --enable-libfontconfig --enable-libfdk-aac
libavutil 55. 41.101 / 55. 41.101
libavcodec 57. 66.109 / 57. 66.109
libavformat 57. 58.101 / 57. 58.101
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 68.100 / 6. 68.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100

Input #0, lavfi, from 'color=c=red:size=640x480:r=25':

Duration: N/A, start: 0.000000, bitrate: N/A

Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc

Input #1, lavfi, from 'color=c=pink:size=1920x1080:r=25':

Duration: N/A, start: 0.000000, bitrate: N/A

Stream #1:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc

Input #2, lavfi, from 'anullsrc=r=44100:cl=stereo':

Duration: N/A, start: 0.000000, bitrate: 705 kb/s

Stream #2:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s

Input #3, lavfi, from 'anullsrc=r=44100:cl=stereo':

Duration: N/A, start: 0.000000, bitrate: 705 kb/s

Stream #3:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s

[mpegts @ 0x7fb65806f200] frame size not set
Output #0, hls, to 'stream.m3u8':

Metadata:

encoder : Lavf57.58.101
Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 192 kb/s (default)
Metadata:

encoder : Lavc57.66.109 aac

Stream mapping:

Stream #0:0 (rawvideo) -> setpts
Stream #1:0 (rawvideo) -> setpts
Stream #2:0 (pcm_u8) -> asetpts
Stream #3:0 (pcm_u8) -> asetpts
amix -> Stream #0:0 (aac)

Press [q] to stop, ? for help
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231914.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231921.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231926.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231926.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231931.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231936.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231936.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231941.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231941.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231946.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231951.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231951.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231956.ts]
[hls @ 0x7fb658804c00] dddddd en->filename = [segment20161224231956.ts]
size=N/A time=00:00:40.03 bitrate=N/A speed=0.913x
video:0kB audio:10kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[aac @ 0x7fb658806200] Qavg: 65536.000
localhost:hlsenc StevenLiu?$
localhost:hlsenc StevenLiu?$ cat stream.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:3.018600,
segment20161224231914.ts
#EXTINF:2.995367,
segment20161224231921.ts
#EXTINF:2.995378,
segment20161224231926.ts
#EXTINF:2.995378,
segment20161224231926.ts
#EXTINF:2.995367,
segment20161224231931.ts
#EXTINF:3.018600,
segment20161224231936.ts
#EXTINF:2.995378,
segment20161224231936.ts
#EXTINF:2.995367,
segment20161224231941.ts
#EXTINF:2.995378,
segment20161224231941.ts
#EXTINF:2.995378,
segment20161224231946.ts
#EXTINF:3.018589,
segment20161224231951.ts
#EXTINF:2.995378,
segment20161224231951.ts
#EXTINF:2.995367,
segment20161224231956.ts
#EXTINF:1.021678,
segment20161224231956.ts
#EXT-X-ENDLIST

When the list have two segment one name, ffmpeg will double unlink the file.

./ffmpeg -re -loglevel info -y -f lavfi -re -i color=c=red:size=640x480:r=25 -f lavfi -f lavfi -re -i color=c=pink:size=1920x1080:r=25 -f lavfi -re -i anullsrc=r=44100:cl=stereo -f lavfi -re -i anullsrc=r=44100:cl=stereo -filter_complex "[1]setpts=PTS-STARTPTS[1o]; [0:v]setpts=PTS-STARTPTS [0vo]; [1o][0vo] overlay=x=10:y=10 , split=3 [v1][v2][vimg] ; [v1] scale=size=960x540, setdar=dar=16/9, nullsink ; [v2] scale=size=640x360, setdar=dar=16/9 , nullsink ; [vimg] scale=size=320x180[vout] ; [3]asetpts=PTS-STARTPTS [0ao]; [2]asetpts=PTS-STARTPTS [2o]; [0ao][2o] amix [aout1] " -map "[vout]" -map "[aout1]" -c:v libx264 -g 12 -acodec aac -cutoff 20000 -ac 2 -ar 44100 -ab 192k -f hls -hls_time 3 -hls_list_size 2 -hls_flags delete_segments -use_localtime 1 -hls_segment_filename 'segment%Y%m%d%H%M%S.ts' stream.m3u8

this is ok.

of course, ffmpeg is split segment by video keyframe ,your command line just only audio, maybe ffmpeg need support split by audio only stream.

comment:6 Changed 2 years ago by stevenliu

  • Resolution set to wontfix
  • Status changed from open to closed

comment:7 Changed 2 years ago by cehoyos

  • Keywords hls added

comment:8 Changed 2 years ago by doubleb

So as I understand from your test, these error messages come from the fact, that -use_localtime option may produce identical segment names for different segments even when -hls_time value is greater then 2.
I think hls_enc should give a warning log message in these cases when it produces same segment names as an existing one in its segment maintain list.
My original ffmpeg command line - when I discovered these error messages - contained video content in hls, but I removed that part in my error report to be reproducible without libx264 encoder. So, these cases may appear in normal (video+audio) cases also.
Thanky ou for your help.

Last edited 2 years ago by doubleb (previous) (diff)

comment:9 Changed 2 years ago by doubleb

I have sent a patch proposal to devel-list that shows warning log messages when duplicate segment filenames occur.

Note: See TracTickets for help on using tickets.