I have lots and lots of photos on my computer (and servers!). Sometimes I have a pile of photos of which I want to find only the ones that are in portrait or landscape mode. This can be done manually for a few images, but browsing through thousands of them is more tricky. Then I often tend to use a nifty little shell script that I found here. It effectively sorts all images into two folders automagically.
This is a note to self, and hopefully to others, about how to easily and quickly trim videos without recompressing the file.
I often have long video recordings that I want to split or trim (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 split and trim files in most graphical 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 perform “lossless” trimming. Fortunately, there is a way to do this with the wonderful command-line utility FFmpeg. It is available for most platforms and has a ton of different options. So to remember how it is done, here is a simple one-liner:
ffmpeg -i input.mp4 -ss 01:19:27 -to 02:18:51 -c:v copy -c:a copy output.mp4
This will cut out the section from about 1h19min (after the -ss command) to 2h18min (after the -to command). The copy parts of the command are meant to copy both the original audio and video content without recompressing. This means that the above command only takes a few seconds to run.
You may instead want to specify a fixed duration to extract, in which case you can use:
ffmpeg -i input.mp4 -ss 00:01:10 -t 00:01:05 -c:v copy -c:a copy output.mp4
This will extract 1min5sec (using the -t flag) starting from 1min10sec (the -ss flag) in the file. Happy trimming!
Yet another note to self on how to fix things in Ubuntu after a fresh install, found at askubuntu, this time to remove the standard bookmarks in the Nautilus file browser. I use a different setup of folders, and don’t really need these unused bookmarks. I wish it could have been easier to just right-click and delete to remove them (like for your own bookmarks), but it turns out to be a bit more tricky.
The default bookmarks are actually built from
~/.config/user-dirs.dirs, and this file is rebuilt on login from
/etc/xdg/user-dirs.defaults. So it is necessary to modify both of the files, which may most easily be done with:
nano ~/.config/user-dirs.dirs sudo nano /etc/xdg/user-dirs.defaults
In the nano editor you should comment out the ones that you don’t want.
And after a login the bookmarks are gone.
As part of the fun of reinstalling an OS, you need to set up all the small things again (and you also get rid of all the small things you had set up and that you don’t need any longer…). This message is mainly a note to self about how to move windows between screens on Ubuntu with a key combination, found at stackexchange:
- Install CompizConfig Settings Manager:
sudo apt install compizconfig-settings-manager compiz-plugins-extra
- Run Compiz from the dash
- Enable the
Putplug-in (select the check-box)
- Click on
- Configure the shortcut for
Put to next Output(click
enable). I like to use <super-less>, since that key combination is very convenient on a Norwegian keyboard
- Log out and back in to make changes take effect
One of the fun parts of reinstalling an OS (yes, I think it is fun!), is to discover new software and new ways of doing things. As such, it works as a “digital shower”, getting rid of unnecessary stuff that has piled up.
Trying to also get rid of some physical mess, I am scanning some piles of paper documents. This leaves me with some large multi-page PDFs that I would like to split up easily. In the spirit of software carpentry I looked for a simple solution for splitting up a PDF file, and came across the command “burst” in the little terminal application pdftk. To use it on Ubuntu, you will first need to install it, using the terminal command:
sudo apt update && sudo apt install pdftk
Then this one-liner is all that is necessary to split a PDF file into a series of individual PDFs:
pdftk your-file.pdf burst
For convenience, I also made it into a small Ubuntu script:
And then you can of course also combine the files again, either all PDFs:
pdftk *.pdf cat output newfile.pdf
or only the files you like:
pdftk file1.pdf file2.pdf cat output newfile.pdf