3

After reading about how to convert a video by 90 degrees

I tried these commands:

mencoder old.mp4 -oac lavc -ovc x264 vcodec=mpeg4 -vf flip,mirror -o new.mp4

mencoder old.mp4 -oac lavc -ovc x264 vcodec=mpeg4 -vf rotate=2 -o new.mp4

ffmpeg -i old.mp4 -vf "hflip" -strict -2 new.mp4 

but the converted video is still upside down.

Running the video with

mplayer -vf flip,mirror  old.mp4

renders it as desired. But anyway, I'd like to convert it.

I'm using ffmpeg version 2.8.15-0ubuntu0.16.04.1 and MEncoder 1.2.1 (Debian), built with gcc-5.3.1

2 Answers2

6

Videos from phones often have metadata that tell the player to rotate upon playback (not all players respect this). When re-encoding, ffmpeg will automatically rotate the video according to the rotate metadata, so you don't have to do anything special:

ffmpeg -i input.mp4 -c:a copy output.mp4

However, if the rotate metadata is wrong you can simply remove or change it without needing to re-encode:

ffmpeg -i input.mp4 -c copy -metadata:s:v rotate="" output.mp4

Alternatively, you could change it such as -metadata:s:v rotate="180".

llogan
  • 11,868
0

I found the following command line code worked with Ubuntu 20.04LTS using ffmpeg:

ffmpeg -i filename.mp4 \
-c copy -metadata:s:v:0 rotate=0 \
output.mp4

It only changes the metadata with no loss in quality.

andrew.46
  • 38,003
  • 27
  • 156
  • 232
George
  • 1