Now that we've got the description out of the way, let's get into the ffmpeg split video function and the many ways in which a video file can be split to exact specifications, such as ffmpeg split video into frames, ffmpeg split video into parts, ffmpeg split video by size, and dozens of options like these. You can also use iMyFone Filme which can easily split videos into severalsegments easily.
- Part 1. 7 Ways to Use the FFmpeg Split Video Function
- Method 1. FFmpeg Split Video into Frames
- Method 2. FFmpeg Split Video by Size
- Method 3. FFmpeg Split Video into Parts of Equal Duration
- Method 4. FFmpeg Split Video by Scene
- Method 5. FFmpeg Split Video by Time or Duration
- Method 6. FFmpeg Split Video by Width
- Method 7. FFmpeg Split Video Horizontally
- Part 2. Tips to Split Videos Losslessly with FFmpeg
- Part 3. An Easier Way to Split Video for Free[Without Quality Loss]
Part 1. 7 Ways to Use the FFmpeg Split Video Function
If you need to split video in FFmpeg, you need learn how to use the command, it is very hard for some beginners if they dont know how to use the command. i would recommend iMyFone Filme for FFmpeg alternative.
Filme can split video with few clicks in 5 seconds. Download iMyFone Filme now and get 3 month free license below.
Before digging into how to use FFmpeg, keep in mind the powerful command: ffmpeg -ss 00:00:05 -t 6 -i input.mp4 -vcodec copy -acodec copy output.mov.
-ss means beginning time.
-t is the length of final part.
-i is the input file, in the above case it's a file called 'input.mp4'.
-vcodec stands for the video codec to encode the output file. 'copy' means you're using the same codec as the input file.
-acodec is the audio codec.
output.mp4 is the output file, you can rename it as you need.
Method 1. FFmpeg Split Video into Frames
This command allows you to extract specific frames from a video, which are basically image files that make up the video. For example, if the video runs at 24 frames per second, it means there are 24 images displayed on your screen every second when the video is playing. This command can be used to split videos into frames and extract the individual frames. The command works as shown in the steps below:
1. Open Terminal (in Mac) and enter the following command to navigate to your video folder. It's important that you always run ffmpeg commands in the folder where the source content is stored.
As an example, you can type cd ~/Videos followed by Enter.
2. The next command splits your video into frames and stores each one as a separate image thumbnail file.
ffmpeg -i video.mp4 thumb%04d.jpg -hide_banner
That's it. You can now go to the same folder location and pick out the image you need.
Method 2. FFmpeg Split Video by Size
This command lets you cut a larger video into a smaller one of a specific file size. It is useful when you have a lot of unwanted footage and only need a specific portion in a specific size for the purpose of uploading or sharing. Here's what to do:
In Terminal or any command-line interface, enter this command:
./split-video.sh huge-video.mov 64000000 "-c:v libx264 -crf 23 -c:a copy -vf scale=960:-1"
The source code for the above command can be accessed here. In the command, the number 64000000 represents 64MB, which means your video will be split into chunks of 64MB each. This is only approximate. You can change that number to specify the size of chunks you need.
Method 3. FFmpeg Split Video into Parts of Equal Duration
This command can be used to split a video into multiple parts of identical durations. This is useful for social media sites where specific video durations are required or preferred. You can use this command:
ffmpeg -i "input_video.MTS" -ss 164 -f segment -segment_time 120 -vcodec copy -reset_timestamps 1 -map 0:0 -an output_video%d.MTS
Method 4. FFmpeg Split Video by Scene
This one is a little tricky and doesn't always detect individual scenes in an accurate manner, but you can give it a go:
split.sh -d 0.5 -o /tmp/parts -f file.mp4
The script for this can be found here. As an alternative, you can use PySceneDetect by installing it with this command if you have Pip (the Python Package Manager) on your system:
pip install scenedetect[opencv,progress_bar]
Following this, you can use the scenedetect function to split the video:
scenedetect --input my_video.mp4 detect-content list-scenes split-video
Mthod 5. FFmpeg Split Video by Time or Duration
You can also use the ffmpeg command to split a video into parts of varying durations. The command for this is shown below:
ffmpeg -ss 00:00:00 -t 00:50:00 -i largefile.mp4 -acodec copy \-vcodec copy smallfile.mp4
The above command will split the video at 50 minutes from the beginning. You can change that as you like. Simply repeat the process for the remaining portion of the video to get multiple parts.
Method 6. FFmpeg Split Video by Width
This function allows you to crop a video to a particular width to suit specific devices during playback. It is also helpful when you have unwanted elements in the edges of the shot. To split a video by width, use this command:
ffmpeg -i input.mp4 -filter:v "crop=iw*(5/10):ih*(5/10):iw:0" output.mp4
In the example above, the video will be cropped to half the width and half the height. To keep the same height, just change that parameter into 10/10 for the ih component. There are several variations of this command, but this should work just fine. You can also maintain the aspect ratio by using a :keep_aspect=1 parameter inside the quote marks in the example shown above. The command would then look like this:
ffmpeg -i input.mp4 -filter:v "crop=iw*(5/10):ih*(5/10):iw:0:keep_aspect=1" output.mp4
Method 7. FFmpeg Split Video Horizontally
This is essentially the same cropping function but, instead of cropping it to a smaller width, you will be keeping the width the same and reducing the height of the video by 50%. Here are the commands with and without the aspect ratio component:
ffmpeg -i input.mp4 -filter:v "crop=iw*(5/10):ih*(5/10):iw:0" output.mp4
ffmpeg -i input.mp4 -filter:v "crop=iw*(5/10):ih*(5/10):iw:0:keep_aspect=1" output.mp4
Similar to cropping vertically, in this case, change the iw component's value to 10/10 to keep the same height, and use the aspect ratio to created a cropped file with the same ratio as the source file.
Also Read:
Part 2. Tips to Split Videos Losslessly with FFmpeg
1. Lossless Split Video Command (keep first portion)
By default, FFmpeg will split videos and re-encode them, which can cause some amount of quality loss. To avoid this, you can use the copy codec for audio and video in the corresponding ffmpeg split video command. It will look something like this:
ffmpeg -i originalvideo.mp4 -ss 0:0:4 -t 0:1:10 -vcodec copy -acodec copy outputvideo.mp4
The command above will split it to a specific segment as defined by the timeline parameters. In this example, the split will start at 4 seconds and end at 1 minute and 10 seconds. You can change the parameters as you like, but the important thing is to use the copy codec, or else you may see a loss of quality.
2. Lossless Split Video Command (keep both portions)
A variation of this command can be used to save both portions after the video is split:
ffmpeg -i largefile.mp4 -t 00:50:00 -c -vcodec copy -acodec copy smallfile1.mp4 \-ss 00:50:00 -c -vcodec copy -acodec copy smallfile2.mp4
You can also just use the -c copy parameter to copy audio and video from the original to the output, which will result in lossless quality.
3. Check the Quality of the Original File
One very important aspect that many users miss is the fact that their original source file needs to be high-quality. It's a good idea to have 4K or a similar high resolution for your input file. If not, the poor quality from your source file will be copied to your output file and therefore have the same quality.
4. Use the Man FFmpeg Command to Learn More Video Split Functions
As a final tip, you can run the $ man ffmpeg command in Terminal to fetch the FFmpeg manual. This will show you a lot of advanced commands for the following actions:
ffmpeg split and join video
ffmpeg split flv video
ffmpeg split mp4 video
ffmpeg split video by chapter
ffmpeg split video by frame number
ffmpeg split video lossless
ffmpeg split video mp4
ffmpeg split video parts
ffmpeg split video scene detection
...and so on.
Also Read:
Use FFmpeg To Resize/Scale Video
Part 3. An Easier Way to Split Video for Free [Without Quality Loss]
Filme is a premium video editor that is now free for use for any purpose, personal or commercial. As a robust tool with comprehensive edit, effects, audio, and other functions, it can be used to easily split a video or crop a video to exact specifications. Filme also allows you to merge videos after splitting them and use transitions to avoid abrupt scene jumps. The collection of audio tracks, transitions, filters, and other effects is quite impressive. Here's the basic overview of features for splitting and cropping videos in Filme.
Trim the ends of a video
Split a video into two or more parts
Crop and resize videos with pixel-level accuracy
Custom and preset ratios for cropping
Timeline zoom in/out feature for greater accuracy
How to Split a Video in Filme
Here's the video tutorial for how to split a video with Filme
To split a video, import the file or drag and drop it into the timeline in Filme.
Move the playhead (the marker with the vertical line that shows the current play position) to where you want the split.
Click the scissors icon (split video icon) to cut the video at that position.
One of the key features here is that you can zoom into and out of a timeline to position your playhead for a more accurate video split. There is a +/- and a slider on the top right-hand corner of the software window that allows you to control the zoom. This will not affect the video in any way but merely gives you better control over the playhead position.
Additional functions are also abundantly available, such as creating a video slideshow with the fast video mode, editing images, effects, editing text, and much more. It also features advanced tools like white balance, rotation, PiP, quality conversion, media merging, slow motion and fast motion speed control, and so on. In short, it's the only video editor you'll ever need again.
To get a free and unrestricted copy of Filme, simply head over to the product page and share it with your friends on Facebook and your Twitter followers. We'll send you a license key absolutely free!