Opened 5 years ago

Closed 4 years ago

#4020 closed defect (fixed)

ffmpeg segment create wrong duration outputs

Reported by: qianliang Owned by:
Priority: important Component: avformat
Version: git-master Keywords: regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

% ffmpeg -y -i 75.ts -map 0:1 -acodec copy 75_audio.ts -map 0:0 -vcodec copy -f segment -segment_time 60 75_video_%d.ts
ffmpeg version N-66797-gb8a5599 Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct 10 2014 22:01:57 with gcc 4.9.1 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfi
g --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-lib
opencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      54. 10.100 / 54. 10.100
  libavcodec     56.  4.101 / 56.  4.101
  libavformat    56.  9.100 / 56.  9.100
  libavdevice    56.  1.100 / 56.  1.100
  libavfilter     5.  1.103 /  5.  1.103
  libswscale      3.  1.100 /  3.  1.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  1.100 / 53.  1.100
Input #0, mpegts, from 'f:/videos/ts/75.ts':
  Duration: 00:01:29.38, start: 61533.402456, bitrate: 7475 kb/s
  Program 100
    Stream #0:0[0x1001]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9],
25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1002]: Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 170 kb/s
Output #0, mpegts, to 'f:/videos/ts/75_audio.ts':
  Metadata:
    encoder         : Lavf56.9.100
    Stream #0:0: Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, 170 kb/s
Output #1, segment, to 'f:/videos/ts/75_video_%d.ts':
  Metadata:
    encoder         : Lavf56.9.100
    Stream #1:0: Video: h264 ([27][0][0][0] / 0x001B), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbn, 25
 tbc
Stream mapping:
  Stream #0:1 -> #0:0 (copy)
  Stream #0:0 -> #1:0 (copy)
Press [q] to stop, [?] for help
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: -2, current: -2; changing to -1. This may result
 in incorrect timestamps in the output file.
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: -1, current: -1; changing to 0. This may result
in incorrect timestamps in the output file.
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: 0, current: -1; changing to 1. This may result i
n incorrect timestamps in the output file.
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: 1, current: 0; changing to 2. This may result in
 incorrect timestamps in the output file.
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: 2, current: 0; changing to 3. This may result in
 incorrect timestamps in the output file.
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: 3, current: 1; changing to 4. This may result in
 incorrect timestamps in the output file.
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: 4, current: 1; changing to 5. This may result in
 incorrect timestamps in the output file.
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: 5, current: 2; changing to 6. This may result in
 incorrect timestamps in the output file.
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: 6, current: 2; changing to 7. This may result in
 incorrect timestamps in the output file.
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: 7, current: 3; changing to 8. This may result in
 incorrect timestamps in the output file.
[segment @ 03666480] Non-monotonous DTS in output stream 1:0; previous: 8, current: 3; changing to 9. This may result in
 incorrect timestamps in the output file.


ffmpeg version N-66797-gb8a5599
built on http://ffmpeg.zeranoe.com/builds/

And here is my video source: http://pan.baidu.com/s/1hqh68Wc

And the duration of my video source is 00:01:29, output 3 segments is 00:01:01, 00:00:58, 00:00:58, and the total is 00:02:57.

And I try to do the same operation in old ffmpeg version(N-46474-gdb012e1), it came out the right segments 00:01:00, 00:00:29.

Change History (5)

comment:1 Changed 5 years ago by cehoyos

  • Component changed from ffmpeg to undetermined
  • Keywords segment removed
  • Priority changed from critical to important
  • Version changed from 2.4.2 to git-master

Did you upload the input sample?

comment:2 Changed 5 years ago by cehoyos

  • Keywords regression added

comment:3 Changed 5 years ago by cehoyos

  • Component changed from undetermined to avformat
  • Reproduced by developer set
  • Status changed from new to open

Regression since ac293b66

comment:4 Changed 5 years ago by scaryguy

I confirm this bug.

ffmpeg -i istikbal_reklam.mp4 -bsf:v h264_mp4toannexb -c copy -segment_list istikbal.m3u8 -segment_time 10 -f segment istikbal%d.ts
ffmpeg version 2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct 19 2014 18:31:37 with Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.4.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
  libavutil      54.  7.100 / 54.  7.100
  libavcodec     56.  1.100 / 56.  1.100
  libavformat    56.  4.101 / 56.  4.101
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  1.100 /  5.  1.100
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'istikbal_reklam.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.48.100
  Duration: 00:00:43.46, start: 0.021333, bitrate: 1490 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1402 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 82 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[mpegts @ 0x7fca1983ce00] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
    Last message repeated 1 times
[adts @ 0x7fca1983f800] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
Output #0, segment, to 'istikbal%d.ts':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.4.101
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1402 kb/s, 25 fps, 25 tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, 82 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mpegts @ 0x7fca1a000000] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
    Last message repeated 1 times
[adts @ 0x7fca1a00aa00] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[mpegts @ 0x7fca1a000000] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
    Last message repeated 1 times
[adts @ 0x7fca1a031800] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[mpegts @ 0x7fca1b000000] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
    Last message repeated 1 times
[adts @ 0x7fca1b00aa00] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
frame= 1086 fps=0.0 q=-1.0 Lsize=N/A time=00:00:43.47 bitrate=N/A
video:7437kB audio:438kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

This command produces this M3U8 file which is not supposed to do:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:13
#EXTINF:10.200000,
istikbal0.ts
#EXTINF:9.800000,
istikbal1.ts
#EXTINF:11.080000,
istikbal2.ts
#EXTINF:12.440000,
istikbal3.ts
#EXT-X-ENDLIST

HTTP Live Streaming Specification states that TARGETDURATION is REQUIRED to be set correctly and all segments should follow it.

I mean, this bug is critical, I think.

Thank you

comment:5 Changed 4 years ago by michael

  • Resolution set to fixed
  • Status changed from open to closed
Note: See TracTickets for help on using tickets.