I would like to cut out specific parts of a mp4 video, and merge back those parts to create a single video file. This is to make an animated preview of the video.
More specifically : Cut out these parts of a video :
- Part 1 : start time of the cut = 20% of total time ; end time of the cut = 20% of total time + 3seconds,
- Part 2 : 40% of total time ; 40%nof total time + 3 seconds
- Part 3 : 60% of total time ; 60% of total time + 3 seconds
- Part 4 : 80% of total time ; 80% of total time + 3 seconds
(The videos are more than 3 minutes long, so there should not be any overlap in the parts)
Then merge those 4 parts in a new mp4 video file. How do you do that with FFMPEG ?
Edit : so this is as far as I got for this question :
I found answers to questions on "Superuser" and "Stackexchange" for these questions on FFMPEG: -How to get video durations in seconds -Cut part from video file with start/end positions -Concatenate mp4 files
So : Get total time of video :
$ ffprobe -v error -show_entries format=duration \
-of default=noprint_wrappers=1:nokey=1 -sexagesimal inputvideo.mp4
With the -sexagesimal I should get the right time format to use after.
Cut out part of video
ffmpeg -ss [start] -i in.mp4 -t [duration] -c copy /path/videopart[number].mp4
Right here I don't know : How to do an operation on total time (20%, 40%... then 20% +3 seconds, 40% +3 seconds..) How to properly implement it in the code line
Create a file videoparts.txt with the files names :
$ cat videoparts.txt
file '/path/videopart1.mp4'
file '/path/videopart2.mp4'
file '/path/videopart3.mp4'
file '/path/videopart4.mp4'
Then this should merge them in a single file :
$ ffmpeg -f concat -i videoparts.txt -c copy outputvideo.mp4