Linux FFMPEG – Flip Vertical Video to Horizontal

I was recently shooting some videos on my phone to share with someone else and accidentally flipped the phone before filming a clip. I never film vertically as I know that our playback devices are not designed to playback vertical footage. But I screwed up and got a clip that was vertical. Since I would consider sharing such a clip “bad form,” I needed a quick and easy way to flip the clip. Enter FFMPEG.

This can be done very easily with a single line of code at the console or terminal in Linux, assuming you have FFMPEG installed. Here’s the line of code:

ffmpeg -i input_video.mp4 -vf "transpose=2" output_video.mp4

Here’s what the code does. First, it calls “ffmpeg.” Then you tell it what video to input “-i input_video.mp4.” (The “-i” tells FFMPEG that what follows is the input.) If you’re not in the same directory as the video, you can simply add that information (e.g., /home/user/input_video.mp4). Next, the “-vf “transpose=2″” tells FFMPEG to first “-vf” create a filtergraph (basically, apply a filter) which is “transpose.” The “2” indicates how much to rotate the video – 90 degrees in this case. Finally, pick a name for your file and a file extension. That’s it. That will rotate your video from vertical to horizontal.

Here’s an actual example of code that I used:

ffmpeg -i /home/ryan/Desktop/vertical.mp4 -vf "transpose=2" /home/ryan/Desktop/horizontal.mp4

Sources for this post. FFMPEG’s documentation (here and here) and this post.

 715 total views

Linux – Fixing “apt-get” failed installation

Occasionally, when I try to install an update or install software via the console using apt-get, something goes wrong. To date, I have never had the failure of a package to install ruin my system. However, it isn’t uncommon after such an incident to get an error the next time I run apt-get. The easiest way to fix apt-get is to run the following command:

sudo dpkg --configure -a

The above command is the replacement for the old command in Debian-based distributions:

sudo dpkg-reconfigure --all

Almost every time I have run into an apt-get error, the above command has been able to solve the problem. It’s a useful command to have on hand if you’re running a Debian-based Linux distribution (like Kubuntu, my distribution of choice).

 419 total views