brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ffmpeg -ac 2 mixes 5.1 surround down to stereo

Ffmpeg
~/tips/tip-ffmpeg-ac-2-downmix

ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv

Converts surround audio to two channels so it plays well on laptops and headphones.

Surround audio played on a laptop or headphones often sounds wrong: voices are too quiet because the dialogue sits in the center channel. Mixing it down to stereo fixes that.

ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv

-ac 2 sets the number of audio channels in the output to two. ffmpeg uses its standard downmix, which folds the center channel into left and right and mixes the rear channels in at a lower level. The video is copied, so only the audio gets encoded.

The same option works for mono: -ac 1 combines everything into one channel, which I find handy for a voice recording where one side is louder than the other.

A common complaint is that the default downmix makes dialogue too quiet compared to explosions. In that case you can raise the center channel yourself with the pan filter, for example -af "pan=stereo|FL=FC+0.30*FL+0.30*BL|FR=FC+0.30*FR+0.30*BR". Those weights are a matter of taste, and the right ones depend on the source, so test on a short piece first using -t 60.

Further reading: ffmpeg documentation, FFmpeg filters documentation

More Ffmpeg tips ffmpeg -stream_loop 2 -i in.mp4 -c copy out.mp4 ffmpeg -i in.mp4 \ ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4 ffmpeg -i talk.mp4 -vn -c:a copy talk.m4a ffmpeg -n -i "$f" -c copy "${f%.mkv}.mp4" All Ffmpeg tips (38) All topics

Link