0
I want to batch convert video files with different extensions and convert them to MP4. If the video codec is already H.264, I want to copy it and convert the audio only if it is AC3, MP3, or anything that is not AAC.
I'm familiar with ffmpeg, but I don't know how to have it intelligently skip converting codecs if it is already in part H.264 and AAC.
The batch file below would work for all video files, but I know I'd be re-processing parts of files that do need to be transcoded.
for %%a in ("*.*") do ffmpeg -i "%%a" -c:v libx264 -preset slow -crf 20 -c:a libvo_aacenc -b:a 128k "newfiles\%%~na.mp4"
I'm not sure how to build this as part of a batch file - but if it helps push you in the right direction, you would likely want to run an FFprobe on the file and poll the metadata for codec information. For all files that are not H264, your above code will do a proper conversion. For all files that match H264 as a codec, you will want to do
ffmpeg -i [INPUT] -c:v copy -c:a libvo_aacenc -b:a 128k -f mp4 [OUTPUT]
. Not sure how helpful this is, as you may already know this - but until someone else responds, hopefully it pushes you in the right direction. – occvtech – 2015-08-10T17:26:04.363Yeah, that doesn't really help me. I'm not clever enough to figure when to apply a specific set of ffmpeg instructions. – Sun – 2015-08-13T01:20:59.167