How to trim a large video with ffmpeg?

11,988

Option placement matters

You can try using -ss as an input option (before -i). This will immediately seek to the closest seek point before the declared -ss position. Note that when -ss is used as an input option the -to option behaves the same as the -t option.

If you find this is not accurate enough you may have to use -ss as an output option and/or re-encode instead of stream copy. As an output option it is slower, so it is possible you simply did not wait long enough for it to fully decode to your position.

Example

ffmpeg -ss 01:21:24 -i input.mp4 -t 7 -c copy output.mp4

Also see

Share:
11,988
Admin
Author by

Admin

Updated on June 13, 2022

Comments

  • Admin
    Admin about 2 years

    I am trying to trim a video that is 75 GB size and 1 hour and 28 minutes long

    I only want to get 7 seconds out of it

    When I try this

    ffmpeg -i Replay.mp4 -ss 01:21:24.0000 -to 01:21:32.0000 -acodec copy -vcodec copy ShortReplay2.mp4
    

    I get this

    Stream mapping:
      Stream #0:1 -> #0:0 (copy)
      Stream #0:0 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    frame=    0 fps=0.0 q=-1.0 size=       0kB time=00:00:00.00 bitrate=N/A
    

    It's stuck and nothing happens, have waited for about 30 minutes and is still stuck

    However when I try trimming it from the beginning of the video

    ffmpeg -i Replay.mp4 -ss 00:00:00.000 -to 00:20:00.000 -acodec copy -vcodec copy ShortReplay2.mp4
    

    It works without issues

    Is it because the file size is too big and the program takes too long to read it? What can I do?