LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to rotate mp4 file (https://www.linuxquestions.org/questions/linux-software-2/how-to-rotate-mp4-file-4175641011/)

mfoley 10-23-2018 10:50 PM

How to rotate mp4 file
 
I've been searching and testing for hours. No luck. I have a .mov file I converted to mp4 using:
Code:

ffmpeg -i "2018.10 Chair Update Video.mov" -f mp4 -vcodec copy -acodec copy output.mp4
Unfortunately, the video is rotated 90 degrees counter-clockwise. I've tried numerous things including using VLC and various ffmpeg commands including:
Code:

ffmpeg -i output.mp4 -vf "transpose=1" outputR.mp4
ffmpeg -i output.mp4 -c copy -metadata:s:v:0 rotate=90 outputR.mp4

and numerous other variations I found on the web. Nothing works. The video remains stubbornly rotate 90-counter.

This is turning out a lot more difficult than I thought. Ideas?

dc.901 10-24-2018 02:45 PM

I've used handbrake in past, and it was quite good (however, I did not rotate video)
I do see there is an option to rotate:
https://www.itsupportguides.com/know...ing-handbrake/

https://www.groovypost.com/howto/con...les-transcode/

Have you tried this already?

BTW: there is also CLI option for handbrake if you do not want to use GUI:
https://handbrake.fr/docs/en/latest/...reference.html

average_user 10-24-2018 03:08 PM

You can rotate your monitor.
Anyway, this command you suggested worked for me:
Code:

ffmpeg -i output.mp4 -vf "transpose=1" outputR.mp4
ffmpeg version:
Code:

$ ffmpeg --version
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.3.0 (GCC)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --docdir=/usr/doc/ffmpeg-3.2.4/html --mandir=/usr/man --disable-debug --enable-shared --disable-static --enable-gpl --enable-version3 --enable-avresample --arch=x86_64 --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-libcaca --enable-libcdio --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libmp3lame --enable-opengl --enable-libopenjpeg --enable-libpulse --enable-libsmbclient --enable-libwavpack --enable-x11grab

Is ffmpeg printing some errors?

average_user 10-24-2018 03:12 PM

And also notice that some video players can rotate videos, for example mplayer:
Code:

mplayer -vf rotate=2 outputR.mp4
In man mplayer it says:
Code:

      rotate[=<0-7>]
              Rotates the image by 90 degrees and optionally flips it.  For values between  4-7  rotation  is  only
              done if the movie geometry is portrait and not landscape.

                0    Rotate by 90 degrees clockwise and flip (default).

                1    Rotate by 90 degrees clockwise.

                2    Rotate by 90 degrees counterclockwise.

                3    Rotate by 90 degrees counterclockwise and flip.


BW-userx 10-24-2018 03:35 PM

maybe convert it to mp4 first, as stated, I too use HandBrake for this.

average_user 10-24-2018 03:45 PM

Quote:

Originally Posted by BW-userx (Post 5918850)
maybe convert it to mp4 first, as stated, I too use HandBrake for this.

I think that's what OP is doing - he first converts .mov to .mp4 with ffmpeg and then tries to rotate output .mp4 video.

alexpaton 10-25-2018 09:07 AM

I find that AVIDemux is one of the most useful video tools for applying filters to videos. It looks less pretty than Handbrake, but the settings are much more comprehensible.

teckk 10-25-2018 02:26 PM

Both of these will rotate video 90deg clockwise

Examples:
Code:

ffmpeg -i input.mov -c:a copy -c:v libx264 -crf 18 -preset slow -vf "rotate=PI/2" outfile.mp4
Code:

ffmpeg -i input.mov -c:a copy -c:v libx264 -crf 18 -preset slow -vf "transpose=1" outfile.mp4


All times are GMT -5. The time now is 06:36 PM.