Landscape on the phone, portrait on the PC
I recorded some videos with my smartphone and, incredibly, after the import on the PC, I found them rotated in the wrong mode. Landscape to portrait, or viceversa. Not ever, not at all, but sometimes it happens.
So I was looking for a way to rotate those videos. I shot videos with my Nexus 5X and imported them both on Fedora and Ubuntu machines. Same results. Not always, but for most same results. The videos were shot in portrait mode and I would like to rotate them to landscape mode. Or the videos were shot in landscape mode and I would like to rotate them to portrait mode.
I have tried with Kdenlive, but it took a lot of time and also sometimes (somethings) went wrong. So, I decided to search a different solution.
Use FFmpeg to do it in the easy and fast way
On my Linux machines, a very easy way to do that is to use FFmpeg. You can install it on your distribution with a one command by terminal.
On Fedora:
sudo dnf install ffmpeg
Or, on Ubuntu:
sudo apt install ffmpeg
I did some attempts before finding a suitable solution. In some cases, FFmpeg re-encodes the footage and it takes a lot of time. No way for me. All my files were in MP4 format and FFmpeg can handle to rotate without re-encode them.
Solution:
ffmpeg -i '/home/user/Videos/video-to-rotate.mp4' -c copy -metadata:s:v:0 rotate=180 '/home/user/Videos/rotated-video.mp4'
With this simple command, FFmpeg doesn’t re-encode the video and rotate it in a couple of seconds. Really really fast.
Notes:
I started looking at instructions in this discussion on stackoverflow and following the different solutions. After different attempts, I understood that the correct value for my phone videos is 180.
One comment
Comments are closed.