ubuntu:video:rotate_videos_with_ffmpeg
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ubuntu:video:rotate_videos_with_ffmpeg [2020/02/13 00:02] – created peter | ubuntu: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 " | ffmpeg -i in.mov -vf " | ||
</ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | * 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 13: | Line 22: | ||
Use **-vf " | Use **-vf " | ||
+ | |||
+ | </ | ||
---- | ---- | ||
- | Running | + | If you don't want to re-encode your video AND your player can handle rotation metadata you can just change the rotation in the metadata using ffmpeg: |
<code bash> | <code bash> | ||
- | ffmpeg -filters | + | ffmpeg -i input.m4v -metadata: |
</ | </ | ||
- | shows this: | + | Check the rotate metadata first with: |
+ | |||
+ | <code bash> | ||
+ | ffmpeg -i input.m4v 2>&1 | grep rotate | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | 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 " | ||
+ | </ | ||
+ | |||
+ | for counter-clockwise the angle must be negative | ||
+ | |||
+ | <code bash> | ||
+ | ffmpeg -i in.mp4 -vf " | ||
+ | </ | ||
+ | |||
+ | |||
+ | It is possible to get finer-grained resolution of radians, because * behaves as multiplication: | ||
+ | |||
+ | <code bash> | ||
+ | ffmpeg -i in.avi -vf " | ||
+ | </ | ||
+ | |||
+ | (slightly less rotation than -PI/4 = -10*PI/40 | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Determine filters supported by ffmpeg ===== | ||
+ | |||
+ | Other filters that can be used. | ||
+ | |||
+ | <code bash> | ||
+ | ffmpeg -filters | ||
+ | </ | ||
+ | returns: | ||
< | < | ||
Line 433: | Line 483: | ||
- | ---- | ||
- | |||
- | < | ||
- | Filters: | ||
- | anull Pass the source unchanged to the output. | ||
- | aspect | ||
- | crop Crop the input video to x: | ||
- | fifo | ||
- | format | ||
- | hflip Horizontally flip the input video. | ||
- | noformat | ||
- | for the input to the next filter. | ||
- | null Pass the source unchanged to the output. | ||
- | pad Pad input image to width: | ||
- | 0, default color: black). | ||
- | pixdesctest | ||
- | pixelaspect | ||
- | scale Scale the input video to width: | ||
- | mage format. | ||
- | slicify | ||
- | ple slices. | ||
- | unsharp | ||
- | vflip Flip the input video vertically. | ||
- | buffer | ||
- | n. | ||
- | color Provide an uniformly colored input, syntax is: [color[: | ||
- | te]]] | ||
- | nullsrc | ||
- | nullsink | ||
- | </ |
ubuntu/video/rotate_videos_with_ffmpeg.1581552127.txt.gz · Last modified: 2020/07/15 09:30 (external edit)