User Tools

Site Tools


ubuntu:video:rotate_videos_with_ffmpeg

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ubuntu:video:rotate_videos_with_ffmpeg [2020/02/13 00:08] peterubuntu:video:rotate_videos_with_ffmpeg [2023/06/06 18:30] (current) peter
Line 1: Line 1:
 ====== Ubuntu - Video - Rotate Videos with FFmpeg ====== ====== Ubuntu - Video - Rotate Videos with FFmpeg ======
 +
 +===== Software Encoding =====
  
 <code bash> <code bash>
 ffmpeg -i in.mov -vf "transpose=1" out.mov ffmpeg -i in.mov -vf "transpose=1" out.mov
 </code> </code>
 +
 +<WRAP info>
 +**NOTE:**  This will re-encode the audio and video parts.
 +
 +  * You can usually copy the audio without touching it, by using **-c:a copy**.
 +  * To change the video quality, set the bitrate (for example with **-b:v 1M**) or have a look at the H.264 encoding guide if you want VBR options.
 +
  
 For the transpose parameter you can pass: For the transpose parameter you can pass:
Line 14: Line 23:
 Use **-vf "transpose=2,transpose=2"** for 180 degrees. Use **-vf "transpose=2,transpose=2"** for 180 degrees.
  
- 
-<WRAP info> 
-**NOTE:**  This will re-encode the audio and video parts. 
- 
-You can usually copy the audio without touching it, by using **-c:a copy**. 
- 
-To change the video quality, set the bitrate (for example with **-b:v 1M**) or have a look at the H.264 encoding guide if you want VBR options. 
 </WRAP> </WRAP>
  
Line 30: Line 32:
 ffmpeg -i input.m4v -metadata:s:v rotate="90" -codec copy output.m4v ffmpeg -i input.m4v -metadata:s:v rotate="90" -codec copy output.m4v
 </code> </code>
 +
 +Check the rotate metadata first with:
 +
 +<code bash>
 +ffmpeg -i input.m4v 2>&1 | grep rotate
 +</code>
 +
 +----
 +
 +To rotate the picture clockwise you can use the rotate filter, indicating a positive angle in radians. With 90 degrees equating with PI/2, you can do it like so:
 +
 +<code bash>
 +ffmpeg -i in.mp4 -vf "rotate=PI/2" out.mp4
 +</code>
 +
 +for counter-clockwise the angle must be negative
 +
 +<code bash>
 +ffmpeg -i in.mp4 -vf "rotate=-PI/2" out.mp4
 +</code>
 +
 +
 +It is possible to get finer-grained resolution of radians, because * behaves as multiplication:
 +
 +<code bash>
 +ffmpeg -i in.avi -vf "rotate=-8*PI/40" -q 1 out.avi 
 +</code>
 +
 +(slightly less rotation than -PI/4 = -10*PI/40
  
  
ubuntu/video/rotate_videos_with_ffmpeg.1581552492.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki