I have a video stream (XVID) and an audio stream (mp3) in an AVI file.
I also have a video stream (x264) and an audio stream (aac) in an MKV file.
I want to extract the VIDEO stream from the AVI (xvid) and the AUDIO stream from the MKV (aac), and create an AVI.
So, to extract the video from the avi, I tried:
ffmpeg -i OLD.AVI -f rawvideo -vcodec rawvideo NEW.AVI
As far as I understand this should give me an AVI file, without AUDIO, but instead gives me a big AVI that can not be played.
I also tried ffmpeg -i OLD.avi -acodec copy NEW.avi but the video gets re-encoded somehow, and it is even shorter than the original.
So, how do I extract the original XVID from an avi?
Then, lets suppose the video thing gets solved, I would need to extract the AAC and convert to CBR MP3 (mkvtoolnix/foobar) an mix it with the new avi using:
ffmpeg -i AUDIO.mp3 -i NEW.avi FULL.avi
Any other comments? Thanks!
+ Reply to Thread
Results 1 to 10 of 10
Last edited by kwanbis; 13th Apr 2012 at 19:16.
ffmpeg does include a 'copy' command, which might work better for you. For example:
ffmpeg -i video.mp4 -vcodec copy -acodec copy video.avi
(-vcodec and -acodec are actually aliases for the -c:/-codec: command, but it should still work the same, I believe:
‘-c[:stream_specifier] codec (input/output,per-stream)’ ‘-codec[:stream_specifier] codec (input/output,per-stream) ’Select an encoder (when used before an output file) or a decoder (when used before an input file) for one or more streams. codec is the name of a decoder/encoder or a special value copy (output only) to indicate that the stream is not to be re-encoded. For example ffmpeg -i INPUT -map 0 -c:v libx264 -c:a copy OUTPUT encodes all video streams with libx264 and copies all audio streams. For each stream, the last matching c option is applied, so ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT will copy all the streams except the second video, which will be encoded with libx264, and the 138th audio, which will be encoded with libvorbis.
Note: I'm by no means an expert on ffmpeg, and don't use it manually except on rare occasions, so hopefully, someone more experienced than I will be able to help. )
Last edited by Ai Haibara; 13th Apr 2012 at 22:39.If cameras add ten pounds, why would people want to eat them?
ffmpeg -i old.AVI -vcodec copy new.AVI
Part of the problem is AAC audio is not completely compatible in AVI. (You can do it, but lots of compatibility problems with many applications and hardware players)
Also , are you adverse to doing this with other programs, or does it have to be ffmpeg?
I think this should work, it assumes that audio is track #1 in the mkv file and video is track #0. You can find out by using ffmpeg -i input.mkv and it will list the tracks. Otherwise you have to change the -map value
ffmpeg -i input.avi -vcodec copy -i input.mkv -map 0:1 -acodec copy output.avi
Last edited by poisondeathray; 14th Apr 2012 at 12:28.
If cameras add ten pounds, why would people want to eat them?
I know the aac is not compatible and so i have already extracted it and converted it to MP3. So, to simplify, lets assume I have some avis, about 60, and that I want to add them the MP3 audio.
The other thing is that I want to remove the original audio.
It does not has to be ffmpeg, but i like command line tools, cause you can do it in batches.
Sorry, put the inputs first, and specify stream maps for them both (again this assumes that the mkv has audio as track #1, and video as track #0)
ffmpeg -i input.avi -i input.mkv -map 0:0 -map 1:1 -vcodec copy -acodec libmp3lame output.avi
It is working with
ffmpeg -i old.avi -i old.mkv -map 0:0 -map 1:1 -vcodec copy -acodec libmp3lame -ab 128k output.avi