To detect whether videos are recorded in portrait or landscape mode.
ffprobe -v error -select_streams v:0 -show_entries stream_tags=rotate -of csv=s=x:p=0 input.mp4
NOTE: On unrotated videos, the above command produces no output.
ffprobe -v error -select_streams v:0 -show_entries stream=width,height:stream_tags=rotate -of csv=p=0 input.mp4
returns:
1920,1080,270
NOTE: Even though the rotation here is 270, the width and height are still shown as if the orientation was portrait.
ffprobe somevideo.mp4 2>&1 | grep rotate
returns:
rotate : 90
rotate=$(ffprobe -v error -select_streams v:0 -show_entries stream_tags=rotate -of csv=s=x:p=0 "${sourceFile}") if [ "$rotate" != "" ]; then echo "We need to rotate: $rotate" fi