VideoHelp Forum
+ Reply to Thread
Results 1 to 6 of 6
Thread
  1. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    Hello

    I'm using the latest and greatest (ffmpeg N-79690-g78baa45).

    For some reason, the following doesn't work as expected: Instead of slicing the video after 5mn, it keeps going for 10:
    Code:
    ffmpeg -ss 00:15:17 -i input.mp4 -to 00:20:17 -c copy -threads 2 -f mp4 output.mp4
    Same result:
    Code:
    ffmpeg -ss 00:15:17 -i input.mp4 -to 00:20:17 -c:v libx264  -pix_fmt yuv420p -c:a copy -threads 2 -f mp4 output.mp4
    Any idea why? Did the ffmpeg team changed the meaning of the -to switch?

    Thank you.
    Last edited by yetanotherlogin; 2nd Sep 2016 at 04:19.
    Quote Quote  
  2. Member racer-x's Avatar
    Join Date
    Mar 2003
    Location
    3rd Rock from the Sun
    Search Comp PM
    Try:

    Code:
    ffmpeg -ss 00:15:17 -i input.mp4 -t 00:05:00 -c copy -threads 2 -f mp4 output.mp4
    Got my retirement plans all set. Looks like I only have to work another 5 years after I die........
    Quote Quote  
  3. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    I find that -to only works when -ss is entered as an output option.
    Quote Quote  
  4. Member
    Join Date
    Mar 2011
    Location
    Paris, France
    Search PM
    Thanks. I don't want to use the -t option because the -to option lets me just type the end of the segment without having to compute how long it lasts.

    Why does it matter where I put the -ss and -to options?

    Here, they're put before the -i option:
    http://ffmpeg.io/howto

    Here, they're after:
    http://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-...e-using-ffmpeg
    ---
    Edit: Here's the explanation:
    https://trac.ffmpeg.org/wiki/Seeking
    Last edited by yetanotherlogin; 2nd Sep 2016 at 04:18.
    Quote Quote  
  5. Member
    Join Date
    Nov 2015
    Location
    Lexington, MA
    Search Comp PM
    "Thanks. I don't want to use the -t option because the -to option lets me just type the end of the segment without having to compute how long it lasts. Why does it matter where I put the -ss and -to options?"

    The -ss option can be either an input option or an output option. The -to option and -t option are only output options.

    If you use -ss and -to both on the output, then -to will work as you expect. The downside is that it will filter and encode all of the frames from the beginning of the file, then throw them out until the start time in -ss. Just a timewaster, but -to then works.

    If you use -ss before -i, then those frames are thrown away before processing, so the output never sees those frames. So as far as the -to can tell, the video is that much shorter and started at 0, instead of started at the -ss time.

    Want a clip from src video that starts at 2:30 and ends at 7:30...

    ffmpeg -i src.mpg <encode options> -ss 00:02:30 -to 00:07:30 dst.mpg

    ffmpeg -i src.mpg <encode options> -ss 00:02:30 -t 00:05:00 dst.mpg
    ffmpeg -i src.mpg <encode options> -ss 00:02:30 -t 300 dst.mpg

    ffmpeg -ss 00:02:30 -i src.mpg <encode options> -t 300 dst.mpg

    All but the last command process frames from the start of the file then drops them in the very last step before writing; the last command instead throws out those frames (very quickly) before processing and starts processing frames beginning with the -ss time.


    ffpmeg
    Quote Quote  
  6. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    It doesn't matter if you use -t it - to. If you use -ss as an input it resets the timecode to 0 so -t and - to then means to a point from the ss point starting at 0. It is further complicated by the fact that if you use -c copy, ffmpeg will cut at a key frame but your first frame may not have a timecode of 0. This may play ok on some players but give problems if you try to merge it to another segment, even with the same parameters.

    There is a way to do it with -vframes that works but it is tricky also.
    Last edited by Budman1; 13th May 2018 at 22:36.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!