2024-10-09, 07:31 PM
Thanks a lot for the help. I asked AI and got this:
for file in *.mp4; do
audio_count=$(ffmpeg -i "$file" 2>&1 | grep 'Stream #' | grep 'Audio' | wc -l)
if [ "$audio_count" -eq 1 ]; then
sudo ffmpeg -i "$file" -map 0:v -map 0:a:0 -vcodec copy -acodec aac -b:a 192k -ar 48000 -sample_fmt fltp "${file%.mp4}.mkv"
else
sudo ffmpeg -i "$file" -map 0:v -map 0:a:0 -map 0:a:1 -vcodec copy -acodec aac -b:a 192k -ar 48000 -sample_fmt fltp "${file%.mp4}.mkv"
fi
done
it brings over both tracks and encodes with the same samplingrate
for file in *.mp4; do
audio_count=$(ffmpeg -i "$file" 2>&1 | grep 'Stream #' | grep 'Audio' | wc -l)
if [ "$audio_count" -eq 1 ]; then
sudo ffmpeg -i "$file" -map 0:v -map 0:a:0 -vcodec copy -acodec aac -b:a 192k -ar 48000 -sample_fmt fltp "${file%.mp4}.mkv"
else
sudo ffmpeg -i "$file" -map 0:v -map 0:a:0 -map 0:a:1 -vcodec copy -acodec aac -b:a 192k -ar 48000 -sample_fmt fltp "${file%.mp4}.mkv"
fi
done
it brings over both tracks and encodes with the same samplingrate