Opened 3 months ago

Last modified 3 months ago

#7681 new defect

Ffmpeg segment produces corrupted segments after segment #0 when encoding h264 stream to mp4

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

Description

Summary of the bug:

How to reproduce:
ffmpeg -report -v 9 -loglevel 99 -i udp://127.0.0.1:6000 -c copy -flags +global_header -f segment -segment_time 10 -segment_format_options movflags=+faststart -reset_timestamps 1 /mnt/sda1/test%d.mp4

ffmpeg version 4.1
built on gcc 7.4.0 (OpenWrt? GCC 7.4.0 r9059-6e104c63d6)

I`m trying to save h264 stream with aac audio to .mp4 file without re encoding but only first segment is playable in Windows Media Player and Opera/Firefox?. Next segments gives error in WMP, in Firefox there is no sound and there is error in Opera and Chrome, VLS plays it without any problem. First segment (number 0) plays everywhere.

Attachments (3)

ffmpeg-20190115-184805.log (498.6 KB) - added by pikwas 3 months ago.
ffmpeg-20190115-184805
test0.mp4 (2.4 MB) - added by pikwas 3 months ago.
Sample file #0
test3.mp4 (1.8 MB) - added by pikwas 3 months ago.
Sample file #3 (this file is not playable in WMP and browsers)

Change History (9)

Changed 3 months ago by pikwas

ffmpeg-20190115-184805

Changed 3 months ago by pikwas

Sample file #0

Changed 3 months ago by pikwas

Sample file #3 (this file is not playable in WMP and browsers)

comment:1 Changed 3 months ago by cehoyos

Is the issue reproducible with current FFmpeg git head?
Is network input required or can you also reproduce the issue with testsrc2?
Please do not attach output files unless specifically asked.

comment:2 Changed 3 months ago by pikwas

Issue was tested on 3.2.12, 3.5.1, 4.0.2 and 4.1 downloaded today. I dont know how can I test it with cuurrent FFmpeg git head ?

Issue is reproduced with testsrc2, even worse because in this case whole segmend are unplayable in WMP ora browsers, only VLC can play it.

comment:3 Changed 3 months ago by cehoyos

Where did you download FFmpeg? Current FFmpeg git head is the only supported version.
Please provide the simplified command line including the complete, uncut console output to make this a valid ticket.

comment:4 follow-up: Changed 3 months ago by pikwas

Ffmpeg is downloaded from here:

https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20190116-51978ae-win64-static.zip

Here is output for ffmpeg 4.0.2

C:\ffmpeg-4.0.2-win32-static\bin>ffmpeg.exe -f lavfi -i testsrc2 -c copy -flags
+global_header -f stream_segment -segment_time 100 -segment_format_options movfl
ags=+faststart -reset_timestamps 1 C:\test%d22.mp4
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.1 (GCC) 20180722
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --e
nable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enab
le-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-li
bvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --en
able-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-
libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enabl
e-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enabl
e-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enab
le-dxva2 --enable-avisynth
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, lavfi, from 'testsrc2':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1
DAR 4:3], 25 tbr, 25 tbn, 25 tbc
[stream_segment,ssegment @ 03867cc0] Opening 'C:\test022.mp4' for writing
Output #0, stream_segment,ssegment, to 'C:\test%d22.mp4':
  Metadata:
    encoder         : Lavf58.12.100
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1
DAR 4:3], q=2-31, 25 tbr, 12800 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 1428 fps=0.0 q=-1.0 size=N/A time=00:00:57.08 bitrate=N/A speed= 114x
[mp4 @ 03871ac0] Starting second pass: moving the moov atom to the beginning of
the file
[stream_segment,ssegment @ 03867cc0] Opening 'C:\test122.mp4' for writing
frame= 2502 fps=2179 q=-1.0 size=N/A time=00:01:40.04 bitrate=N/A speed=87.1x
[mp4 @ 03871ac0] Starting second pass: moving the moov atom to the beginning of
the file
frame= 2634 fps=2180 q=-1.0 Lsize=N/A time=00:01:45.32 bitrate=N/A speed=87.2x

video:296325kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxin
g overhead: unknown
Exiting normally, received signal 2.

for ffmpeg 4.1 I can`t user testsrc2:

C:\ffmpeg-4.1-win64-static\bin>ffmpeg.exe -f lavfi -i testsrc2 -c copy -flags +g
lobal_header -f stream_segment -segment_time 100 -segment_format_options movflag
s=+faststart -reset_timestamps 1 C:\test%d22.mp4
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181017
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfi
g --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-lib
freetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amr
wb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --
enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-l
ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --
enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --en
able-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --en
able-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --e
nable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enab
le-avisynth
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, lavfi, from 'testsrc2':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1
DAR 4:3], 25 tbr, 25 tbn, 25 tbc
[stream_segment,ssegment @ 0000000000455dc0] Opening 'C:\test022.mp4' for writin
g
[mp4 @ 0000000000412d80] Could not find tag for codec rawvideo in stream #0, cod
ec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invali
d argument
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
    Last message repeated 1 times

comment:5 in reply to: ↑ 4 Changed 3 months ago by cehoyos

Replying to pikwas:

Ffmpeg is downloaded from here:

https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20190116-51978ae-win64-static.zip

But unfortunately this (the only supported version) is not the version you provided console output for.

Please test -f ssegment.

comment:6 Changed 3 months ago by pikwas

I tried with -f ssegment but results are the same.

C:\ffmpeg-4.1-win64-static\bin>ffmpeg.exe -f lavfi -i testsrc2 -c copy -flags +
lobal_header -f ssegment -segment_time 100 -segment_format_options movflags=+fa
tstart -reset_timestamps 1 C:\test%d22.mp4
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181017
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconf
g --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-li
freetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-am
wb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy -
enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-
ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 -
enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --e
able-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --e
able-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --
nable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --ena
le-avisynth
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, lavfi, from 'testsrc2':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1
DAR 4:3], 25 tbr, 25 tbn, 25 tbc
[stream_segment,ssegment @ 0000000000385d80] Opening 'C:\test022.mp4' for writi
g
[mp4 @ 0000000000342d40] Could not find tag for codec rawvideo in stream #0, co
ec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Inval
d argument
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
    Last message repeated 1 times

C:\ffmpeg-4.1-win64-static\bin>
Note: See TracTickets for help on using tickets.