You are instructing FFmpeg to read a video named inputVideo.mp4 and extract 5 seconds starting at the 3rd second and ending at the 8th second.Īdditionally, you are telling FFmpeg to copy the audio and video and not perform re-encoding – this is very fast! Here is a simple commandline that you can use to cut/trim/extract a portion of your video – fast! ffmpeg -ss 00:00:03 -i inputVideo.mp4 -to 00:00:08 -c:v copy -c:a copy trim_ipseek_copy.mp4 Fast Way to Cut / Trim Without Re-encoding (using Copy and Input Seeking) This is because FFmpeg re-encodes the video from the start-time and can insert I-frames as necessary to produce a frame-accurate clip of the video. The time-stamp indicates this if look carefully. You can see that it starts accurately at the requested time without any stutters or black frames. I cut a 5 second section and re-encoded it using libx264. But, it does have its advantages that cannot be overlooked. You can also use this commandline to re-encode at a particular bitrate, or quality using crf, change the resolution, etc.ĭo remember that this option will take a lot of time and resources because you are performing a re-encode. ffmpeg -i inputVideo.mp4 -ss 00:03 -to 00:08 -c:v libx264 -crf 30 trim_opseek_encode.mp4 In this example, you are instructing FFmpeg to read a video named inputVideo.mp4 and extract 5 seconds starting at the 3rd second and ending at the 8th second – while re-encoding it using libx264. Here is the command line for this using output seeking. If you re-encode your video when you cut/trim, then you get a frame-accurate cut because FFmpeg will re-encode the video and start with an I-frame. Note: if you use both -t and -to, then only -t will be used. For example, -ss 40 -to 70 instructs FFmpeg to extract 30 seconds of the video starting from the 40th second to the 70th second. You can specify the end-time using the -to parameter. For example, -ss 40 -t 10 instructs FFmpeg to extract 10 seconds of video starting from the 40th second. You can specify the duration of the required clip using the -t parameter. And, if we put those two together, we can efficiently cut / splice a video using FFmpeg. Now, let’s learn to specify the end time as well. For example, you can tell FFmpeg to seek to 01:02:03 – i.e., the 3rd second of the 2nd minute of the 1 hour of the movie! Specifying the End Time Here, the time is specified as HH:MM:SS.MILLISECONDS. The first thing that you need to do is tell FFmpeg to seek to the 10th second, right? This is achieved using the -ss parameter in the FFmpeg command line and the syntax is –. Let’s suppose that you want to extract a portion of your video – say from the 10th to the 20th seconds.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |