Last active
May 15, 2024 11:35
-
-
Save vukanac/a3d82d815d0135edae9036acf366c3e2 to your computer and use it in GitHub Desktop.
ffmpeg shell command to convert all videos from my dir to acceptable Audi MMI format/size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd $HOME/my_funny_video | |
for i in *.mp4; | |
do name=`echo "$i" | cut -d'.' -f1` | |
echo "$name" | |
ffmpeg -hide_banner \ | |
-i "$i" \ | |
-r 25 \ | |
-vf scale=w=720:h=404:force_original_aspect_ratio=decrease:force_divisible_by=2 ease \ | |
-c:v libx264 \ | |
-preset medium \ | |
-tune animation \ | |
-profile:v baseline \ | |
-crf 23 \ | |
-maxrate 1750k -bufsize 1750k \ | |
-c:a aac -b:a 192k \ | |
"$HOME/audi_mmi/${name}_480.mp4" | |
done | |
# https://www.audiworld.com/forums/audio-video-security-discussion-15/converting-video-working-formats-2014-a4-mmi-3g-cdn-2855965/ | |
# https://en.wikipedia.org/wiki/Multi_Media_Interface |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You've a small typo in your '-vf scale...' line.
Change
force_original_aspect_ratio=decr:force_divisible_by=2 ease
to
force_original_aspect_ratio=decrease:force_divisible_by=2
Original code without
force_divisible_by=2
works most of the time, just ffmpeg's calculation to decrease resolution to force original aspect ratio can sometimes arrive at resolutions that aren't divisible by 2, which the libx264 encoder won't accept:[libx264 @ 0x560245e8b500] width not divisible by 2 (719x404)
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!
It's a relatively new option that will probably require latest stable FFmpeg-4.4 ->
https://patchwork.ffmpeg.org/project/ffmpeg/patch/[email protected]/
Older versions may need to use the way more complex iw/ih command-line calcuations outlined here -> https://trac.ffmpeg.org/wiki/Scaling
Thanks :)
PS> The resulting video output is working in as far back as Audi MMI 2012