VideoHelp Forum
+ Reply to Thread
Results 1 to 6 of 6
Thread
  1. Hello all,

    i have a Problem with ffmpeg. Its running smooth and fine, but i want ffmpeg to DONT map the streams.
    Its better if i explain this with an example.

    I have two videos. One, which can be altered and an other that is fixed and can't be processed. Afterall i use the mp4box to append one video to the other. Therefore both videos need to be exactly the same. And here we go.

    Video1:

    Code:
        Stream #0.0(eng): Audio: mpeg4aac, 44100 Hz, stereo
        Stream #0.1(eng): Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 25.00 fps(r)
        Stream #0.2(eng): Data: mp4s / 0x7334706D
        Stream #0.3(eng): Data: mp4s / 0x7334706D
    Its a standard video (isma) nothing special about it.

    Now i want to convert video2.

    Code:
    ffmpeg -y -i video2.mp4 -v 1 -threads 1 -vcodec mpeg4 -b 500 -r 25 -s 320x240 -acodec libfaac -ab 96 -ar 44100 -ac 2 -f mp4 -pass 1 video_new.mp4
    I simplified this command, cause i just want to show you the following:

    Code:
      Duration: 00:08:15.4, start: 0.000000, bitrate: 522 kb/s
        Stream #0.0(eng): Audio: mpeg4aac, 44100 Hz, stereo
        Stream #0.1(eng): Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 25.00 fps(r)
        Stream #0.2(eng): Data: mp4s / 0x7334706D
        Stream #0.3(eng): Data: mp4s / 0x7334706D
    Output #0, mp4, to 'video_new.mp4':
        Stream #0.0(eng): Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, pass 1, 0 kb/s, 25.00 fps(c)
        Stream #0.1(eng): Audio: libfaac, 44100 Hz, stereo, 0 kb/s
    Stream mapping:
      Stream #0.1 -> #0.0
      Stream #0.0 -> #0.1
    
    If you are now going to concenate the videos, they wont fit, cause ffmpeg is changing the stream of the second video ... first stream 0.1 is now video (was audio) and second is audio (was video) ...

    I have looked into the documentary and found the "map" parameter, but this isn't going to work cause i dont want to remap them, i just want him to do NOT remap it right from the beginning.

    I hope you get the thought behind this...

    So the final question is: How to prevent ffmpeg to "map the channels" automatically?
    Oh! This wasn't supposed to happen...
    Quote Quote  
  2. If you're familiar with mp4box, use it on your *source* mp4 files in order to rearrange the stream mapping to the "standard" order (video stream first, then audio stream).
    Quote Quote  
  3. Hello jpschuck,

    thanx for your answer.
    i am familiar with ffmpeg i just have used the mp4box for a few minor things. According to the documentation of mp4box:

    To select a desired media track, the following syntax is used:

    * -add inputFile#video: adds the first video track in inputFile. DOES NOT WORK for IsoMedia nor MPEG-2 TS files.
    * -add inputFile#audio: adds the first audio track in inputFile. DOES NOT WORK for IsoMedia nor MPEG-2 TS files.
    * -add inputFile#trackID=ID or -add inputFile#ID: adds the specified track. For IsoMedia files, ID is the track ID. For other media files, ID is the value indicated by MP4Box -info inputFile.
    If i got this correctly i just can add new streams or media tracks ... not remap them. Imo to get this working i have to extract every track and reimport them in a new media file ... this is quite not what i wanted...

    Or do you have an other idea?
    Oh! This wasn't supposed to happen...
    Quote Quote  
  4. Originally Posted by Pixelartist
    Hello jpschuck,
    If i got this correctly i just can add new streams or media tracks ... not remap them. Imo to get this working i have to extract every track and reimport them in a new media file ... this is quite not what i wanted...

    Or do you have an other idea?
    You got the idea : your problem is that you can't join the two mp4 files because their A/V tracks are not in the same order, once you've converted the second file, is that right ? So, instead of telling ffmpegX not to remap the stream of the second file, all you have to do is to use mp4box to change the track order in the first file.

    Assuming your first video is named movie1.mp4, use the following command :
    Code:
    mp4box -add movie1.mp4#video -add movie1.mp4#audio new_movie.mp4
    This will extract the video and audio tracks from movie1.mp4 and consequently remap them in a new file called new_video.mp4. Now you should be able to append this file to the one created by ffmpegX.

    this is quite not what i wanted...
    What would be exactly your problem with this method ?

    MP4box is probably even able to extract, remap and append tracks in an one step process but I don't know the commands to do that.
    Quote Quote  
  5. Well… I just realized this topic was moved from the Mac forum, as it was a Linux oriented question. That's why I was talking about ffmpegX instead of ffmpeg. Actually I was pretty amazed that a Mac user would be using ffmpeg and mp4box through CLI. Yet my answer still applies, unless there are major differences between the Mac and Linux ports of MP4box.
    Quote Quote  
  6. Sorry that i posted in the wrong forum!

    This is definitly a way to do this! This is a nice workaround and i thank you for this one.

    But perhaps there is a way to convince ffmpeg to do not change the mapping in the first place, so i dont have to take that way :P

    I will work further on this one (in spite of working solution jpschuck has shown) ...
    Oh! This wasn't supposed to happen...
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!