science club |
Cutting a movie with vlc and ffmpeg
We use Linux for everything and there are a few graphical applications
to cut a movie but all of them were complicated to install and required
libraries that my older Linux installation did not have.
The movie we did is a 5min long movie for a school project and we did not want to make
any complicated cuts. We just wanted to assemble the individual scenes into
one big 5min movie.
As a camera we used a Panasonic DMC-GF3 configured in VGA resolution and
"motion jpeg". This results in .mov video files (Apple QuickTime movie files).
Here is what we did. It worked very well for us and we had a really nice
movie in a very short time.
Many short scenes as .mov video files
We shot the video in such a way that we did many small scenes. Each one
is only a few seconds long and if one scene is shot from different angles
then those are as well individual .mov video files on the camera.
If something went wrong during a scene then we would simply redo the scene.
We did not have to truncate any .mov video files or remove sections from .mov video files.
The first task was therefore to simply sort all scenes in the right order
and remove the ones that are not good. With the VLC video player you can view many files as one movie simply by starting the vlc command with a wildcard (*)
in the directory where all the files are:
viewing all scenes as one movie with the VLC player
Using a file manager to cut the movie
To move the different scenes into the right order I just give them a
unique filename prefix consisting of a 2 digit scene number (e.g 06) and
a sub-scene number (1...9..a..z). In other words to insert the clip
P1410124.mov as 3rd file in scene 6 I would rename it to 063-P1410124.mov
mv P1410124.mov 063-P1410124.mov
To view the movie after any change you just run again:
Very simple and easy, very fast. Repeat this process until you have
all the scense in place.
Making one big movie file with ffmpeg
The final movie should be just one file and not many. For this we need to
concatenate all those files into one big file. This is where ffmpeg comes
into the picture. I used ffmpeg verion 3.2.4. To concatenate all those files
we need to build first a text files that will tell ffmpeg which files to
concatenate in which order. The syntax for that file is one line at a time,
the key word "file" at the beginning and then the actual file name.
We can generate that file as follows:
ls *.mov > concat.txt
perl -pe 's/^/file /;' concat.txt > concat-list.txt
The concat-list.txt is then the control file for ffmpeg.
ffmpeg -f concat -i concat-list.txt -c copy output.mov
This command will concatenate the small movie scenes into on big output.mov file.
concatenating movie scenes with ffmpeg
In theory it should even be possible to concat many video files into one
with vlc itself that did however not work for me.
ffmpeg does a better job here plus you don't have to click around in
a GUI to select all the files. ffmpeg is very fast and allows for efficient
The final product
Concatenating files in the above way does not change the codec and
the final .mov file could be compressed further.
You can use ffmpeg to change the codec or
you can try "online movie conversion" sites.
Even youtube does a pretty good job. You just upload your movie to youtube.com
and while still logged into your account you go to the "video manager" section
where you can see all your public and private videos. Click on the arrow next
to the "Edit" button and you can download the video again as mp4. It is usually a
smaller file and better compressed than the original .mov file that you uploaded.
Copyright © 2004-2018 Guido Socher