Would like to change audio codec, but keep video settings with ffmpeg

An aggregation of Ehsan's answer with fletom's comment that works for me, thanks to both.

ffmpeg -i input.avi -acodec mp3 -vcodec copy out.avi

Hard to judge what you are doing, since the ffmpeg command was a bit garbled in your post.

To replace an audio track:

ffmpeg -i test.avi -i normalized.mp3 -map 0:0 -map 1:0 -vcodec copy -acodec copy new_test.avi

More information about the above parameters is found in: FFmpeg Documentation.


If you just want to change the audio and/or video codec(s) you could just add them as parameters like so:

Just change the audio codec to mp3 (what ever the original codec was)

ffmpeg -i input.avi -vcodec copy -acodec mp3 out.avi

Just change the video codec to h264

ffmpeg -i input.avi -vcodec h264 out.avi

It's good to note that ffmpeg must support encoding of the new codec. See https://stackoverflow.com/questions/3377300/what-are-all-codecs-supported-by-ffmpeg

Tags:

Ffmpeg