ffprobe:video:rotate
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ffprobe:video:rotate [2025/01/13 10:01] – created peter | ffprobe:video:rotate [2025/01/13 10:20] (current) – peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== ffprobe - Video - Rotate ====== | ====== ffprobe - Video - Rotate ====== | ||
+ | |||
+ | To detect whether videos are recorded in portrait or landscape mode. | ||
+ | |||
+ | |||
+ | ===== Video orientation detection ===== | ||
<code bash> | <code bash> | ||
ffprobe -v error -select_streams v:0 -show_entries stream_tags=rotate -of csv=s=x:p=0 input.mp4 | ffprobe -v error -select_streams v:0 -show_entries stream_tags=rotate -of csv=s=x:p=0 input.mp4 | ||
</ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
---- | ---- | ||
+ | |||
+ | ==== Getting Width, Height, Rotation ==== | ||
<code bash> | <code bash> | ||
- | rotate=$(ffprobe -v error -select_streams v:0 -show_entries stream_tags=rotate -of csv=s=x:p=0 " | + | ffprobe -v error -select_streams v:0 -show_entries |
- | if [ " | + | |
- | echo "We need to rotate: $rotate" | + | |
- | fi | + | |
</ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | 1920, | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | * Due to the 270 rotation, in reality the actual input should be 1080x1920, and not 1920x1080. | ||
+ | * But ffprobe reports the actual width x height; Width is displayed first, then height (no matter the order it is requested). | ||
+ | |||
+ | </ | ||
+ | |||
---- | ---- | ||
- | ===== With Grep ===== | + | ===== Using Grep ===== |
<code bash> | <code bash> | ||
Line 27: | Line 50: | ||
rotate | rotate | ||
</ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== In a Bash Script ===== | ||
+ | |||
+ | <code bash> | ||
+ | rotate=$(ffprobe -v error -select_streams v:0 -show_entries stream_tags=rotate -of csv=s=x:p=0 " | ||
+ | if [ " | ||
+ | echo "We need to rotate: $rotate" | ||
+ | fi | ||
+ | </ | ||
+ | |||
+ | ---- | ||
ffprobe/video/rotate.1736762508.txt.gz · Last modified: 2025/01/13 10:01 by peter