If you are working on a computer vision project, there is a great chance that you have been recording videos with sound, which you have no use of. To save space and processing power, you can strip the audio from the video just like this:
avconv -i input_video.mp4 -an output_video.mp4
(Replace avconv with ffmpeg if necessary.)
Just so you know, there is something dishonest with avconv as they make you believe ffmpeg is dead or obsolete. In fact it's nothing like that. avconv is a fork of ffmpeg and has become the default on Ubuntu. So if you are reading to use a filter that isn't present in avconv, then you need to download the latest version of ffmpeg from source or from a PPA. Read more on this subject here.
Showing posts with label ffmpeg. Show all posts
Showing posts with label ffmpeg. Show all posts
Saturday, February 21, 2015
Rotate a video on Linux
When you record videos on your smartphone, the video itself is not rotated. The video recorder simply adds a tag telling the player how to rotate the video.
That's why mediainfo reports "Rotation: 180°" or other angles on videos recorded from my Samsung Galaxy S4.
Unfortunately unlike the video player on your phone, the vast majority of video players on desktop computers and TVs don't support this tag.
If the video is upside down:
avconv -i original_video.mp4 -vf "vflip,hflip" output_video.mp4
or
avconv -i original_video.mp4 -vf "transpose=2,transpose=2" output_video.mp4
(You can replace avconv with ffmpeg if avconv is not found on your system.)
Note that the first version is slightly faster (2-5 %).
If the video was recorded in portrait mode:
if the top of the image is on the left of the screen, it needs a +90° rotation:
avconv -i original_video.mp4 -vf "transpose=1" output_video.mp4
if the top of the image is on the right of the screen, it needs a -90° or +270° rotation:
avconv -i original_video.mp4 -vf "transpose=2" output_video.mp4
That's why mediainfo reports "Rotation: 180°" or other angles on videos recorded from my Samsung Galaxy S4.
Unfortunately unlike the video player on your phone, the vast majority of video players on desktop computers and TVs don't support this tag.
If the video is upside down:
avconv -i original_video.mp4 -vf "vflip,hflip" output_video.mp4
or
avconv -i original_video.mp4 -vf "transpose=2,transpose=2" output_video.mp4
(You can replace avconv with ffmpeg if avconv is not found on your system.)
Note that the first version is slightly faster (2-5 %).
If the video was recorded in portrait mode:
if the top of the image is on the left of the screen, it needs a +90° rotation:
avconv -i original_video.mp4 -vf "transpose=1" output_video.mp4
if the top of the image is on the right of the screen, it needs a -90° or +270° rotation:
avconv -i original_video.mp4 -vf "transpose=2" output_video.mp4
Subscribe to:
Comments (Atom)