3

I have a video. Here is it's ffprobe output:

> ffprobe 7347-00009\ kliksa.mp4
ffprobe version 2.6.1 Copyright (c) 2007-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libvorbis --enable-libvpx --enable-libass --enable-ffplay --enable-libfdk-aac --enable-libopus --enable-libquvi --enable-libx265 --enable-nonfree --enable-vda
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '7347-00009 kliksa.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: avc1isommp42
    creation_time   : 2015-09-17 14:04:14
  Duration: 00:00:30.44, start: 0.000000, bitrate: 7238 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 6977 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2015-09-17 14:04:14
      handler_name    : ?Apple Video Media Handler
      encoder         : inegy Cinecoder H.264 Encoder
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
    Metadata:
      creation_time   : 2015-09-17 14:04:14
      handler_name    : ?Apple Sound Media Handler

All players show that it's duration is 30 seconds. But it's EXACT duration is 00:00:30.44 as ffprobe shows.

What I want to do is setting the videos duration to EXACTLY 00:00:30.00.

I tried this:

ffmpeg -i 7347-00009\ kliksa.mp4 -c copy -ss 00:00:00.000 -to 30.000 test.mp4

But I still have a duration of 00:00:30.02. Here is ffprobe output:

> ffprobe test.mp4
ffprobe version 2.6.1 Copyright (c) 2007-2015 the FFmpeg developers
  built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libvorbis --enable-libvpx --enable-libass --enable-ffplay --enable-libfdk-aac --enable-libopus --enable-libquvi --enable-libx265 --enable-nonfree --enable-vda
  libavutil      54. 20.100 / 54. 20.100
  libavcodec     56. 26.100 / 56. 26.100
  libavformat    56. 25.101 / 56. 25.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 11.102 /  5. 11.102
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.25.101
  Duration: 00:00:30.02, start: 0.000000, bitrate: 7240 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 6982 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

So, how can I have a video cut frame accurately?

  • Isn't it weird that no one knows how to do it? :\ – scaryguy Sep 21 '15 at 20:22
  • I tried to replicate your results (a different duration than specified) and had a bit of difficulty there- all the videos ffmpeg was producing for me were of the exact duration I asked for. When i did replicate it I thought it might be due to bitstream copying but re-encoding actually made the problem worse. I suspect it may be down to a nuance of libx264, but that's just speculation. You may get a response on the ffmpeg-user mailing list, however. – bertieb Sep 24 '15 at 15:21
  • I think the problem is caused by the stream copy command. It may not be able to cut in the middle of ref frames. Try with -vcodec libx264 as a test. – Elliott B Apr 27 '16 at 8:39
0

According to this answer, frame-accurate cutting of video using ffmpeg without re-encoding is only possible at GOP boundaries. I am not sure if it applies to cutting just the end of a video or not.

BTW, a constant frame rate video at 25 fps cannot have a duration of 30.02 seconds. 1 frame is supposed to be on display for 1/25 of a second, which is 0.04 seconds.

Maybe your video just has bad timestamps? Try regenerating them:

ffmpeg -i test.mp4 -fflags +genpts output.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.