I want to use Ubuntu and preferably standard packages such as ffmpeg to rotate a .3gp video file by 90 degrees in any direction. Preferably a command line or Python script.
How can I do that?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityI want to use Ubuntu and preferably standard packages such as ffmpeg to rotate a .3gp video file by 90 degrees in any direction. Preferably a command line or Python script.
How can I do that?
by using VLC, you may rotate the video by going to Tools >> Preferences...
And select "All" for show settings. Then go to: Video >> Filters >> Rotate
After setting the degree you want, you can rotate by going to Tools > Effects and Filters > Video Effects > Geometry .. .
the one I've tested is mp4 but I believe that VLC can support 3gp too. hope this helps. :)
From the command-line, with ffmpeg:
ffmpeg -i input.3gp -filter:v transpose=1 \
-c:v libx264 -preset veryfast -crf 22 \
-c:a copy \
-metadata:s:v rotate="" \
output.3gp
transpose=1
will rotate the video 90 degrees clockwise; to rotate anti-clockwise, use transpose=2
. See the transpose documentation for a bit more information.
-metadata:s:v rotate=""
will strip any existing video stream rotation metadata; otherwise ffmpeg
will copy it which may cause your player to apply additional unwanted rotation.
For information on the video encoding settings here, see this H.264 encoding guide and the AAC encoding guide if you want to re-encode the audio instead of stream copying.
There have been some changes to libav since the time that this question was originally answered. In an attempt to keep this current and useful I'll provide the followng:
You can accomplish this with recent versions of ffmpeg
and avconv
by using the transpose video filter.
avconv -i inputfile -vf transpose=clock outputfile
for clockwise rotation.
in ffmpeg the syntax is the same.
ffmpeg -i inputfile -vf transpose=clock outputfile
where inputfile is your supported input video file and outputfile is your desired output file.
For counter clockwise rotation replace clock with cclock
Here's an excerpt from the documentation:
‘cclock_flip’
Rotate by 90 degrees counterclockwise and vertically flip. (default)
‘clock’
Rotate by 90 degrees clockwise.
‘cclock’
Rotate by 90 degrees counterclockwise.
‘clock_flip’
Rotate by 90 degrees clockwise and vertically flip.
Sources:
https://libav.org/avconv.html#transpose
https://ffmpeg.org/ffmpeg-filters.html#transpose-1
Testing on Ubuntu 14.04.5 LTS, Ubuntu 16.04, Ubuntu 18.04
ffmpeg
worked for me (didn't try avconv
)
Sep 15, 2019 at 4:02
ffmpef
includes a lot of unnecessary arguments, thanks!
Oct 17, 2019 at 14:05
Avidemux should be able to do this.
Do Video->Filters->Rotate(x degrees)->Close
then File->Save->Save Video
I don't know exactly what the difference is, but the top answer ffmpeg command takes a very long time to run on my computer in order to rotate a video.
This ffmpeg command on the other hand took only about 7 seconds to rotate a 2gb video file:
ffmpeg -i input-video.mov -metadata:s:v rotate="-90" -codec copy output-video.mov
I solved a similar problem — I had a .MOV that was taken upside-down (i.e., rotated 180 degrees) which I wanted to set right.
On my Ubuntu 14.04 system, I ran avconv
with essentially the same command-line options as given for ffmpeg
in evilsoup's answer. Apparently, it does not support a transpose
option for 180-degree rotation, so I did the 90-degree clockwise (i.e., transpose=1
) twice.
When I tried minimal options, I got a message to the effect that:
encoder 'aac' is experimental and might produce bad results.
Add '-strict experimental' if you want to use it.
and the output file was zero length, so I added the -strict experimental
.
Command lines that worked were:
avconv -i IMG_orignl.MOV -filter:v 'transpose=1' -strict experimental IMG_interm.MOV
avconv -i IMG_interm.MOV -filter:v 'transpose=1' -strict experimental IMG_result.MOV
The result was satisfactory, with unexplained side-effects:
Not that I'm complaining: these are desirable; I just don't understand why they came about...
avconv
command lines in their entirety, and not just the differences from the ffmpeg
command. Your answer should be self-sufficient; the other answer might go away. (3) Good luck!
Jun 8, 2015 at 4:25
-filter:v transpose=1 …
.
Jun 8, 2015 at 4:26