replace audio track in a video file

ffmpeg -i orig_video.wmv -i new_audio.wav -vcodec copy -map 0.0 -map 1.0 new_video.wmv
The "map" may be different depending on the .wmv file. run `ffprobe` to see which is the video-track in the .wmv file usually this is "0.0". Stream #0.0: Video:... Stream #0.1: Audio: .. and "1.0" corresponds to the 2nd input file - your new audio. You may want to add "-acodec wmav2" and "-ar 128k" options for 128kbit/s Windows Media Audio 2 or whatever audio-codec/quality your want. `ffmpeg -codecs | grep "EA"` gives you a list of available codecs for Encoding Audio. Try using '-sameq' instead of '-vcodec copy' (re-encode the video with same quality rather than a bit-exact copy - this often solves muxing issues but will cause a small loss of either video quality or increased bandwidth). and also try a different output format eg. 'new_video.avi' or '..mov' instead of 'new_video.wmv'. you may need both, this should work: ffmpeg -i vid.wmv -i aud.wav -sameq -map 0.0 -map 1.0 output.avi

0
By: lolssl
2015-10-02 12:56:27

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: