I'm compressing a 1080x1920 video (portrait orientation). When I have the Max Resolution set to 720p, ffshare crashes with
[libx264 @ 0xb400c45f434aa400] width not divisible by 2 (405x720)
Apparently it is trying to make the height 720, which leads to a division error. The solution should be to check if the width is less than the height and, if so, scale the width to 720.
```log
Command:
ffmpeg -y -i PXL_20230506_173451420.TS.mp4 -preset medium -crf 23 -vf format=yuv420p -c:v h264 -vf scale=-1:720,setsar=1 2b8e2fb4-25ea-49b6-9ca9-962462863c72.mp4
Output:
ffmpeg version n5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
built with Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
configuration: --cross-prefix=aarch64-linux-android- --sysroot=/files/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/ffmpeg-kit/prebuilt/android-arm64/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --target-os=android --enable-neon --enable-asm --enable-inline-asm --ar=aarch64-linux-android-ar --cc=aarch64-linux-android24-clang --cxx=aarch64-linux-android24-clang++ --ranlib=aarch64-linux-android-ranlib --strip=aarch64-linux-android-strip --nm=aarch64-linux-android-nm --extra-libs='-L/home/taner/Projects/ffmpeg-kit/prebuilt/android-arm64/cpu-features/lib -lndk_compat' --disable-autodetect --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --disable-static --enable-shared --enable-pthreads --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libdav1d --enable-libkvazaar --enable-libx264 --enable-libxvid --enable-libx265 --enable-libvidstab --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-libzimg --disable-openssl --enable-zlib --enable-mediacodec --enable-gpl
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'saf:14.mp4':
Metadata:
major_brand : isom
minor_version : 131072
compatible_brands: isomiso2mp41
creation_time : 2023-05-06T17:40:11.000000Z
location : +47.6320-122.3605/
location-eng : +47.6320-122.3605/
com.android.capture.fps: 30.000000
Duration: 00:05:17.64, start: 0.000000, bitrate: 19862 kb/s
Stream #0:0[0x1](eng): Data: none (mett / 0x7474656D), 30 kb/s (default)
Metadata:
creation_time : 2023-05-06T17:40:11.000000Z
handler_name : MetaHandle
Stream #0:1[0x2](eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 191 kb/s (default)
Metadata:
creation_time : 2023-05-06T17:40:11.000000Z
handler_name : SoundHandle
vendor_id : [0][0][0][0]
Stream #0:2[0x3](eng): Video: hevc (hvc1 / 0x31637668), yuvj420p(pc, bt709), 1920x1080, 19633 kb/s, SAR 1:1 DAR 16:9, 29.99 fps, 29.83 tbr, 90k tbn (default)
Metadata:
creation_time : 2023-05-06T17:40:11.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:3[0x4](eng): Data: none (mett / 0x7474656D) (default)
Metadata:
creation_time : 2023-05-06T17:40:11.000000Z
handler_name : MetaHandle
Multiple -filter, -af or -vf options specified for stream 0, only the last option '-filter:v scale=-1:720,setsar=1' will be used.
Stream mapping:
Stream #0:2 -> #0:0 (hevc (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[swscaler @ 0xb400c5d0646d5000] [swscaler @ 0xb400c5d064585000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d0646d5000] [swscaler @ 0xb400c5d064435000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d0646d5000] [swscaler @ 0xb400c5d064c69000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d0646d5000] [swscaler @ 0xb400c5d06485d000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d0646d5000] [swscaler @ 0xb400c5d064a39000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d0646d5000] [swscaler @ 0xb400c5d064a01000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d0646d5000] [swscaler @ 0xb400c5d064bf9000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d0646d5000] [swscaler @ 0xb400c5d0646b9000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d0646d5000] [swscaler @ 0xb400c5d0644c1000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064745000] [swscaler @ 0xb400c5d064515000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064745000] [swscaler @ 0xb400c5d06493d000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064745000] [swscaler @ 0xb400c5d064959000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064745000] [swscaler @ 0xb400c5d064451000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064745000] [swscaler @ 0xb400c5d06438d000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064745000] [swscaler @ 0xb400c5d064339000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064745000] [swscaler @ 0xb400c5d064841000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064745000] [swscaler @ 0xb400c5d064761000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064745000] [swscaler @ 0xb400c5d0647d1000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064bf9000] [swscaler @ 0xb400c5d064c69000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064bf9000] [swscaler @ 0xb400c5d064c4d000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064bf9000] [swscaler @ 0xb400c5d064611000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064bf9000] [swscaler @ 0xb400c5d064ca1000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064bf9000] [swscaler @ 0xb400c5d064665000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064bf9000] [swscaler @ 0xb400c5d064729000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064bf9000] [swscaler @ 0xb400c5d0643e1000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064bf9000] [swscaler @ 0xb400c5d0647ed000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064bf9000] [swscaler @ 0xb400c5d0647b5000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064959000] [swscaler @ 0xb400c5d064339000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064959000] [swscaler @ 0xb400c5d064b35000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064959000] [swscaler @ 0xb400c5d064a1d000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064959000] [swscaler @ 0xb400c5d064895000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064959000] [swscaler @ 0xb400c5d06462d000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064959000] [swscaler @ 0xb400c5d064b19000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064959000] [swscaler @ 0xb400c5d064905000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064959000] [swscaler @ 0xb400c5d064921000] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0xb400c5d064959000] [swscaler @ 0xb400c5d0648b1000] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0xb400c45f434aa400] width not divisible by 2 (405x720)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Result: FAILURE
App Version: 1.2.5
```
I'm compressing a 1080x1920 video (portrait orientation). When I have the Max Resolution set to 720p, ffshare crashes with
Apparently it is trying to make the height 720, which leads to a division error. The solution should be to check if the width is less than the height and, if so, scale the width to 720.