I need to convert only portrait videos to landscape, some video maybe landscape already.
I need to achieve this with a shell script on a mac.
I've previously managed to rotate a video with ..
ffmpeg -i "/Users/jm/Library/Mobile Documents/com~apple~QuickTimePlayerX/Documents/output.mp4"
-strict 1 -metadata:s:v rotate="90" -codec copy "$3"
$3 is the input file in my shell script
I've found this ...
ffmpeg -i input.m4v 2>&1 | grep rotate
From this answer https://stackoverflow.com/a/31683689/450456
I'm not sure how to combine the two, or have to get and use the height and width in an if statement in a shell script.
EDIT: Info as requested
ffmpeg -i final.mp4
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.1_2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libass --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --enable-openssl --disable-lzma --enable-nonfree
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'final.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2019-11-12T20:45:27.000000Z
Duration: 00:00:24.36, start: 0.031667, bitrate: 365 kb/s
Stream #0:0(und): Video: hevc (Main 10) (hvc1 / 0x31637668), yuv420p10le(tv, smpte170m/unknown/unknown), 1242x2688, 365 kb/s, 1.73 fps, 600 tbr, 600 tbn, 600 tbc (default)
Metadata:
creation_time : 2019-11-12T20:45:27.000000Z
handler_name : Core Media Data Handler
encoder : HEVC
At least one output file must be specified