[LAU] splitting video/audio and recombining

Robin Gareus robin at gareus.org
Mon Mar 5 08:44:32 UTC 2012


On 03/05/2012 08:18 AM, James Stone wrote:
> On Mar 4, 2012 7:12 PM, "Robin Gareus" <robin at gareus.org> wrote:
>>
>> On 03/04/2012 07:48 PM, James Stone wrote:
>>> Hi List,
>>>
>>> I have a video which needs a bit of eq'ing on the audio side. Can
>>> anyone point me in the direction of how to split the file into audio
>>> and video so I can apply some treatment to the audio, and then combine
>>> them back together again? The video is wmv at the moment, but mplayer
>>> doesn't seem to have any problem with it.
>>>
>>
>> #extract audio
>> ffmpeg -i orig_video.wmv audio_out.wav
>>
>> #replace audio
>> ffmpeg \
>>  -i orig_video.wmv \
>>  -i new_audio.wav \
>>  -vcodec copy \
>>  -map 0.0 -map 1.0 \
>>  new_video.wmv
>>
>>
>> Details:  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.
>>
> 
> Thanks. It is 0:0 and 0:1 and -b:a=192k I found, but I have some sync
> problems after recombining tho. Any other ideas?
> 

My gut feeling is to blame ffmpeg's WMV muxer (it may not be able to mux
a bit-exact copy of the original video with your new soundtrack).

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'


welcome to the world of video.
robin

PS. yes, there are other options (lots of options for ffmpeg to
configure the muxer) and other tools. e.g. 'mencoder' provides its own
muxer-implementations for some formats.


More information about the Linux-audio-user mailing list