VideoHelp Forum
+ Reply to Thread
Results 1 to 10 of 10
Thread
  1. Member kwanbis's Avatar
    Join Date: May 2008
    Location: Argentina
    Search Comp PM
    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

    I'm correct?

    Any other comments? Thanks!
    Last edited by kwanbis; 13th Apr 2012 at 20:16.
    Quote Quote  
  2. VH Wanderer Ai Haibara's Avatar
    Join Date: Jan 2006
    Location: Somewhere on VideoHelp...
    Search Comp PM
    ffmpeg does include a 'copy' command, which might work better for you. For example:
    Code:
    ffmpeg -i video.mp4 -vcodec copy -acodec copy video.avi
    The above command line will simply copy the video and audio streams from an MP4 into an AVI.

    (-vcodec and -acodec are actually aliases for the -c:/-codec: command, but it should still work the same, I believe:

    Code:
    ‘-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.
    (taken (without formatting munging, that's mine and the code-tag's fault) from ffmpeg Documentation.)

    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 23:39.
    If cameras add ten pounds, why would people want to eat them?
    Quote Quote  
  3. Member kwanbis's Avatar
    Join Date: May 2008
    Location: Argentina
    Search Comp PM
    Originally Posted by Ai Haibara View Post
    ffmpeg does include a 'copy' command, which might work better for you. For example:
    Code:
    ffmpeg -i video.mp4 -vcodec copy -acodec copy video.avi
    The above command line will simply copy the video and audio streams from an MP4 into an AVI.
    Well, I actually want to copy VIDEO from the AVI, and AUDIO from the MKV, to a new avi, but the MKV is AAC, so i need to extract the audio first, convert to mp3, and then merge. Anyway, that is the easy part, as the mkv tools are great, but so far, the avi tools are much more complicated, so I was thinking maybe I should do

    Code:
    ffmpeg -i old.AVI -vcodec copy new.AVI
    But i'm not sure.
    Quote Quote  
  4. Member
    Join Date: Sep 2007
    Location: Canada
    Search Comp PM
    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

    Code:
    ffmpeg -i input.avi -vcodec copy -i input.mkv -map 0:1 -acodec copy output.avi
    You're probably better of re-encoding the audio to MP3 (more compatible with AVI container) . Just change -acodec copy to -acodec libmp3lame , but your binary needs to be complied with support
    Last edited by poisondeathray; 14th Apr 2012 at 13:28.
    Quote Quote  
  5. VH Wanderer Ai Haibara's Avatar
    Join Date: Jan 2006
    Location: Somewhere on VideoHelp...
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Also , are you adverse to doing this with other programs, or does it have to be ffmpeg?
    Yeah, I could easily do this with other programs, including VirtualDubMod. Maybe AVI-Mux GUI, but I've never really used it, so I don't know for sure.
    If cameras add ten pounds, why would people want to eat them?
    Quote Quote  
  6. Member kwanbis's Avatar
    Join Date: May 2008
    Location: Argentina
    Search Comp PM
    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.
    Quote Quote  
  7. Member kwanbis's Avatar
    Join Date: May 2008
    Location: Argentina
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Part of the problem is AAC audio is not completely compatible in AVI. (You can do it, but lots of compatibility proble ms with many applications and hardware players)
    Thanks, I would try:

    Code:
     ffmpeg -i input.avi -vcodec copy -i input.mkv -map 0:1 -acodec libmp3lame output.avi
    Quote Quote  
  8. Member kwanbis's Avatar
    Join Date: May 2008
    Location: Argentina
    Search Comp PM
    Well, I tried many combinations, but I always get unknown DEcoder copy


    ffmpeg -i old.avi -vcodec copy -i old.mkv -map 0:1 -acodec libmp3lame new.avi

    ffmpeg -i old.avi -c:v copy -i old.mkv -c:a libmp3lame new.avi
    Quote Quote  
  9. Member
    Join Date: Sep 2007
    Location: Canada
    Search Comp PM
    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)

    Code:
    ffmpeg -i input.avi -i input.mkv -map 0:0 -map 1:1 -vcodec copy -acodec libmp3lame output.avi
    Quote Quote  
  10. Member kwanbis's Avatar
    Join Date: May 2008
    Location: Argentina
    Search Comp PM
    It is working with

    Code:
    ffmpeg -i old.avi -i old.mkv -map 0:0 -map 1:1 -vcodec copy -acodec libmp3lame -ab 128k output.avi
    But for some reason, not all the video is transferred, i'm gonna check with some other AVIs.

    Thanks.
    Quote Quote  



Similar Threads