This is a note to self, and hopefully to others, about how to easily and quickly trim videos without recompression.
Often I end up with long video recordings that I want to split or trim. One a side note sometimes people call this “cropping”, but in my world cropping is to cut out parts of the image, that is, a spatial transformation. Splitting and trimming are temporal transformations.
You can of course both split and trim in most video editing software, but these will typically also recompress the file on export. This reduces the quality of the video, and it also takes a long time. A much better solution is to trim losslessly, and fortunately there is a way to do this with the wonder-tool FFMPEG. Being a command line utility (available on most platforms) it has a ton of different options, and I never remember these. So here it goes, this is what I use (on Ubuntu) to trim out parts of a long video file:
This will cut out the section from about 1h19min to 2h18min losslessly, and will only take a few seconds to run.
I have been using Ubuntu as my main OS for the past year, but have often relied on my old MacBook for doing various things that I haven’t easily figured out how to do in Linux. One of those things is to trim video files non-destructively. This is quite simple to do in QuickTime, although Apple now forces you to save the file with a QuickTime container (.mov) even though there is still only MPEG-4 compression in the file (h.264).
There are numerous linux video editors available, but most of these offer way too many features and hence the need to re-compress the files. But I have found two solutions that work well.
The first one, ffmpeg, should be obvious, although I hadn’t thought that it could also do trimming. However, I often like GUI software, and I have found that Avidemux can do what I need very easily. Just open a file, add start and stop markers for the section to be trimmed, and click save. As opposed to QuickTime, it also allows for saving directly to MPEG-4 files (.mp4) without recoding the file.
There was only one thing that I had to look up, and that was the need for starting the trim section on a keyframe in the video. This is quite obvious when wanting to avoid re-encoding the file, but unfortunately Avidemux doesn’t help in explaining this but only gives an error message. The trick was to use the >> arrows to jump to the next keyframe, and then the file saved nicely.
I am working on finalizing an electronic version of a large PDF file (600 page NIME proceedings), and have had some problems optimizing the PDF file. This may not be so strange, since the file is an assembly of 130 individual PDF files all made by different people and using all sorts of programs and OS.
Usually, PDFCompress works wonders when it comes to reducing PDF file sizes, but for the proceedings-file it choked at some of the fonts. Strangely enough, Acrobat Pro also encountered problems, and with no useful explanation on what went wrong.
Fortunately, OSX came to the rescue. When saving a PDF file in OSX it is possible to apply a quartz filter. And OSX had no problems saving and reducing a new PDF file of the proceedings-file. However, the built-in “reduce file size” filter reduced the images too much. But I found an explanation on how to create your own quartz filters, where it is possible to choose compression settings.
I find it strange that Acrobat Pro couldn’t do the job, but I am very happy to have found a solution.