1

I'm using FFmpeg to work with videos which have a negative start time:

$ ffmpeg -i test.mp4 -ss 0 out.mp4
...
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    creation_time   : 2018-01-03 11:35:13
  Duration: 00:00:06.16, start: -1.238906, bitrate: 1425 kb/s
...
Output #0, mp4, to 'out.mp4':
...
frame=  222 fps=0.0 q=-1.0 Lsize=     166kB time=00:00:07.44 bitrate= 182.9kbits/s

Is there any way to cut the video at time 0? i.e. the output should have duration 6.16 and not 7.74. I've tried setting -avoid_negative_ts to all the different values. Obviously, I could manually read the negative value and run it again with the correct offset using -ss, but I'm looking for an automatic solution.

1 Answers1

4

Normally, -ss as an input option works as a relative offset from start of file. Since your start time is negative and will be unknown in advance, you can enable seek_timestamp to seek to a absolute timestamp value.

ffmpeg -seek_timestamp 1 -ss 0 -i test.mp4 out.mp4
Gyan
  • 38,955