[FFmpeg-trac] #7806(ffmpeg:new): Input seeking seems result in incorrect duration of output file when seeking value is small with -codec copy

FFmpeg trac at avcodec.org
Sat Mar 23 04:41:26 EET 2019


#7806: Input seeking seems result in incorrect duration of output file when
seeking value is small with -codec copy
-------------------------------------+-------------------------------------
             Reporter:               |                     Type:  defect
  vincentkilua                       |
               Status:  new          |                 Priority:  normal
            Component:  ffmpeg       |                  Version:  git-
             Keywords:  seeking      |  master
  duration                           |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 Summary of the bug:
 I was trying to remove a couple of seconds from the beginning of the input
 file. However, the output seeking(i.e. ''-ss'' was placed after ''-i'')
 with ''-codec copy'' was resulted in frozen frame for a few seconds at the
 beginning of the output file, therefore I attempted to use the input
 seeking(i.e. ''-ss'' was placed before ''-i'') instead. The resulting
 output file was exhilarating that begin smoothly and accurately except the
 duration information of the output file was different from the actual
 value.

 How to reproduce:
 {{{
 E:\>ffmpeg -ss 00:00:05 -i input.mp4 -t 00:01:00 -c copy output.mp4
 ffmpeg version N-93439-gb073fb9eea Copyright (c) 2000-2019 the FFmpeg
 developers
   built with gcc 8.2.1 (GCC) 20190212
   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-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-
 nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
   libavutil      56. 26.100 / 56. 26.100
   libavcodec     58. 47.105 / 58. 47.105
   libavformat    58. 26.101 / 58. 26.101
   libavdevice    58.  7.100 / 58.  7.100
   libavfilter     7. 48.100 /  7. 48.100
   libswscale      5.  4.100 /  5.  4.100
   libswresample   3.  4.100 /  3.  4.100
   libpostproc    55.  4.100 / 55.  4.100
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf57.41.100
   Duration: 00:03:47.37, start: 0.000000, bitrate: 3150 kb/s
     Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv,
 bt709), 1920x1080, 2955 kb/s, 25 fps, 25 tbr, 16k tbn, 50 tbc (default)
     Metadata:
       handler_name    : VideoHandler
     Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
 stereo, fltp, 190 kb/s (default)
     Metadata:
       handler_name    : SoundHandler
 Output #0, mp4, to 'output.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf58.26.101
     Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv,
 bt709), 1920x1080, q=2-31, 2955 kb/s, 25 fps, 25 tbr, 16k tbn, 16k tbc
 (default)
     Metadata:
       handler_name    : VideoHandler
     Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
 stereo, fltp, 190 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
 frame= 1625 fps=0.0 q=-1.0 Lsize=   24727kB time=00:00:59.99
 bitrate=3376.5kbits/s speed=1.4e+03x
 video:23209kB audio:1464kB subtitle:0kB other streams:0kB global
 headers:0kB muxing overhead: 0.220123%
 }}}
 The above command was supposed to result in a video file with duration
 00:01:00 as described in the prompt(time=00:00:59.99). However I got a
 file with duration 00:01:05 that contains the 00:01:00 long video instead.
 {{{
 PS E:\> ffprobe .\output.mp4
 ffprobe version N-93439-gb073fb9eea Copyright (c) 2007-2019 the FFmpeg
 developers
   built with gcc 8.2.1 (GCC) 20190212
   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-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-
 nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
   libavutil      56. 26.100 / 56. 26.100
   libavcodec     58. 47.105 / 58. 47.105
   libavformat    58. 26.101 / 58. 26.101
   libavdevice    58.  7.100 / 58.  7.100
   libavfilter     7. 48.100 /  7. 48.100
   libswscale      5.  4.100 /  5.  4.100
   libswresample   3.  4.100 /  3.  4.100
   libpostproc    55.  4.100 / 55.  4.100
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\output.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf58.26.101
   Duration: 00:01:05.02, start: 0.000000, bitrate: 3115 kb/s
     Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv,
 bt709), 1920x1080, 2924 kb/s, 25 fps, 25 tbr, 16k tbn, 50 tbc (default)
     Metadata:
       handler_name    : VideoHandler
     Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
 stereo, fltp, 184 kb/s (default)
     Metadata:
       handler_name    : SoundHandler
 }}}
 It won't happen when I use a larger value(say 10, 15 seconds). I have also
 tried the same commands with some older releases, and resulted in
 identical outputs.
 {{{
 ffmpeg -ss 00:00:10 -i input.mp4 -t 00:01:00 -c copy output10.mp4
 ffmpeg -ss 00:00:15 -i input.mp4 -t 00:01:00 -c copy output15.mp4
 }}}
 [[Image(https://cvws.icloud-
 content.com/B/AbadJTdniLspRj1Wtcj60HxHe_UpAU2zq1c_J8uS23XukEWA7Y4XugNf/Snipaste_2019-03-23_09-50-18.png?o=AkqxdfGcfl11zxCcbGeTlJQ54jFGTen4APC1PHUYZ7Es&v=1&x=3&a
 =B7IuIKuYQnfa1qdBU0T-
 IodVWb_vA5kBSgEAAAOKAUo&e=1553308358&k=xucVQ4WK__jHJVhLk448dQ&fl=&r=a49640c1-1189-4e15-aff8-d85cbbecf5f1-1&ckc=com.apple.clouddocs&ckz=com.apple.CloudDocs&p=21&s=UoqpDOlcxEihf6WgDD8cySeq_k0&cd=i)]]

--
Ticket URL: <https://trac.ffmpeg.org/ticket/7806>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list