How to rotate a video in Linux

I tried to do this in VLC but it was way too many steps.  I found out how to do it in a bash prompt using ffmpeg.

ffmpeg -i ./source_image.mp4 -vf 'transpose=cclock' -c:v libx264 -c:a copy -crf 20 destination_image_Rotated.mp4

Change the transpose=cclock to transpose=clock to rotate clockwise instead of anti clockwise.

I have converted this single command to 2 shell functions in my .bashrc

rotatevideoclockwise()
{
ffmpeg -i $1 -vf 'transpose=clock' -c:v libx264 -c:a copy -crf 20 $2
}

rotatevideoanticlockwise()
{
ffmpeg -i $1 -vf 'transpose=cclock' -c:v libx264 -c:a copy -crf 20 $2
}

You will need to run source ~/.bashrc to get this to work or log out and back in again.

 

credit to fungus

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.