Wednesday, November 03, 2010

Converting Half-Stereo to Mono

I was stuck trying to edit a number of video files which had stereo audio, but only the left channel had any sound; the right channel was completely silent. I was using kdenlive (excellent tool) for non-linear editing, but the "mono-to-stereo" didn't work at all there. The documentation says it should copy the left channel to the right one. Or the problem could have had something to do with my audio not really being mono, but "half-stereo".

So here's how you convert m2t left-channel-only audio files to m2t files with the left channel copied over to the right channel.

SRC_VID is your source m2t file, DEST_MONO is where you want the mono audio track to be temporarily stored, and DEST_VID is where you want the final m2t video to be stored.

ffmpeg -i ${SRC_VID} -vn -ac 1 -acodec ac3 -f mp3 ${DEST_MONO}

ffmpeg -i ${SRC_VID} -i ${DEST_MONO} -map 0:0 -map 1:0 -vcodec copy -acodec copy ${DEST_VID}
rm -f ${DEST_MONO}