Check out the Latest Articles:
Mux? Demux? Remux? Huh?

Recently I had a reader contacting me about demuxing files. He wanted to know what it was, and why on earth would you want to do it?

So I sent him an email explaining what “muxing” as a whole is and how demuxing factors into it.

I thought that the rest of my readers might be able to benefit from the knowledge that I expressed to him, so here goes!

Imagine A World…

Nah, just kidding. Imagine that you have ripped a DVD or Blu-ray to your hard disk. If you have no idea how to do this, I have published several guides on how to go about doing so.

So you have these files contained on your hard drive. For a DVD, it will look like an assortment of VOBs (among others, IFO, BUP, etc). For a Blu-ray disk, it will look like M2TS files (among MANY others, but M2TS are the only files that actually contain the video content). Many of you are familiar with files to the extent that you think there is just data in them. And to an extent you are right. But what if I told you that there are in fact several files, or more specifically tracks, contained in your precious media files.

If you think about it, it makes sense. How else would you be able to watch a movie and have both video and audio, and maybe an optional subtitle track?

This is what Muxing does. It takes these individual tracks and combines them into one VOB or M2TS file (depending on the output specification, DVD or Blu-ray). Chances are you won’t be doing much muxing unless you are getting into the nitty gritty details of DVD compilation and Blu-ray generation. Actually that is not quite true, as many programs such as BD Rebuilder or MultiAVCHD mux files for you. Okay, so chances are you won’t be doing much muxing by hand.

Muxing

To summarize, muxing is the act of combining two or more signals into one. In the digital media file world, this means combining a video track, one or more audio tracks, and possible subtitle tracks. There are other tracks as well, such as chapters, but they aren’t that important for the purpose of this post.

Demuxing

I’ll give you one guess. Did you guess that demuxing is the opposite of muxing? Then your wrong! Ha, just kidding. You were correct!

Demuxing is the act of taking a muxed file such as a VOB or M2TS file and splitting it back up into its component streams. Some of you may be thinking, “Why on earth would anyone want to do that?”

Well, I’ll tell you. Demuxing is useful in situations where you want to deal with a specific component of a media file, without affecting the file as a whole. Confused?

Let me try this: Imagine that you have ripped a DVD to your hard drive. But, you have a subtitle track that you have custom edited for a particular reason (like replacing the word “man” with “BATMAAAN!!). Awesome, no?

Okay, so you have this ripped disk and custom subtitle track. What you want to do is replace the DVD’s original subtitle track with your custom subtitle track. In order to do so, you must first demuxing the DVD’s main movie into it’s primary components.

These often look like the following for a DVD:

  • .m2v file (video)
  • .ac3 or dts file (audio)
  • .idx/.sub file (subtitles)

Now that you have the original components, you can remux (REcombine the video files via MUXing) the video and audio tracks with your custom subtitle track. Doing it this way ensures that there is absolutely no quality loss, plus you get your awesome Batman subtitle track! How cool is that?!

Another Use

Not enough for you? Well imagine if you want to compress a media file. But you don’t want to lose any audio quality. So you demux the original media file, compress just the video file using your favorite program, and then mux the compressed video track with the original audio track. Now you have a smaller file size, while still retaining the original audio. Satisfied?

Conclusion

Well that about wraps it up. Again, muxing is the process of combining multiple streams/file into a single stream/file. Demuxing is the inverse of muxing. And remuxing? I think you get what remuxing is…

If not, let me know in the comments! ;)


  • Asif

    Very nice explanation! I always used to wonder what the heck is demuxing/muxing.

  • JHo

    Really cool article. Well done!

  • meisen

    Awesomely good explained basics. And i had 2 or 3 laughs too :)

    thank you very much

  • http://www.massivhaus-heinzvonheiden.de heinz von heiden

    You certainly deserve a round of kudos for your entry and more specifically, your blog in general. Very high quality informations.

  • Elie

    Great article Adub !!

  • Pablo

    I will be very happy if someone manage to answer on my question.

    Well, we have a single audio file. We are using ffmpeg to make some compression and we are also changing sample rate.
    Now my question is how the process of conversion look??

    I see it in this way:

    First the file is demuxed then it is decoded to a bits streams. The next step is a operation on the raw bits streams and changing the sample rate. The last step is to encode the bits streams and mux it to a output file.

    I’m thinking correct?
    Thanks for your help.

  • http://adubvideo.net Adub

    Essentially yes.

    In actuality, the demuxing occurs “on the fly” while FFMPEG is running. It demuxes and decodes the input streams (video, audio, etc) in memory and then works on the resulting “raw data” of the decoded stream(s). The final file is then muxed in memory as well (usually).

    So in short, yes, you have it right.

  • Pablo

    Thanks for you answer.

    I have the last question but is rather concerning hardware point of view. Maybe someone know answer.

    During a conversion process (one file type to another) we are dealing with digital signal all the time?

    So, there is a need of use of the DNS (Digital Signal Processor)? Without this part of hardware conversion will be impossible?

  • http://adubvideo.net Adub

    Pablo, it is all digital. Bits, 1′s and 0′s.

    There is no need to use a DSP. DSP’s are usually only used when playing back a file. Then your computer’s sound card (which does have DSPs) uses those DSPs to create an analog signal to be sent to your headphones.

  • Pablo

    Thanks a lot for clarify my doubts :)
    Regards

  • http://adubvideo.net Adub

    No problem Pablo.

  • Curiouser

    Uhm, I feel a bit silly asking this, but I’m quite new to to the MKV file format.
    Recently, I tried to open a group of mkv files into a video editing software (as I was trying to make an amv… ^^;;) but couldn’t. I read from a few other forums that in order to do so, I’d need to either convert the file or demux it.
    Reading your explanation, I was wondering, if i were to do so, would it (or could I) create a new file with all the separated tracks, or will the original be changed? If so, is there anything I can do, like an alternative? Because it would be a bit bothersome if I had to demux and remux everytime I wanted to use the files… ^^;;
    Any help would be greatly appreciated!

  • http://adubvideo.net Adub

    Unfortunately, modern video editing software doesn’t widely support the MKV format. More often than not, MP4 or MOV are a safer bet if you know you are going to be editing. You can frameserve the files via VirtualDub or Avisynth if you don’t want to remux, but that can be difficult to setup and possibly slow.

    However, demux and remuxing a file will not change the original. It simply copies the streams from the original MKV into an new container. You just have to be sure that the new container supports your original stream formats (ex H264 and AAC are widely supported, WMV not so much). Generally a remux from MKV to MP4 should work.

  • Curiouser

    Ah, I see. Thank you very much for your help! ^^

  • carena

    Thanks for the info! I’m still not sure how to apply it to my particular situation, though…

    I’m trying to take English audio from a DVD (TS_Video), extract it, and add it to an avi file. Regarding the same avi file, I need to extract Russian audio before adding in the English. Additionally, I’m on a Mac but can access a PC if absolutely necessary.

    Any assistance on achieving this as easily as possible will be appreciated. :)

  • carena

    Sorry for the double post, but I forgot to click the ‘notify me’ option the first time in case anyone responds.

  • http://adubvideo.net Adub

    When dealing with AVI’s, AviMux (http://www.alexander-noe.com/video/amg/) is one of the best programs available to do what you desire.

    You are going to want to demux your DVD. PGCDemux is extremely capable (and fast). Simply load up the main IFO file, pick your main playlist and click OK and you will have a resulting AC3 file with the main audio.

    You can either encode this to MP3 or mux directly to your AVI in AVIMux. There are a number of guides available for AVIMux, but here is a good place to start : http://www.videohelp.com/tools/AVIMux_GUI

    The sad thing is that these are all PC only programs. Unfortunately there are not a lot of programs available on Mac that support this kind of functionality.

  • Stephen T.

    Hi Adub,

    Thanks for your overview on demuxing. I’m trying to demux the AC3 file from a movie into its component parts. I could like to separate the music soundtrack in a movie from the voice and effects soundtrack and add my own music sound track to the movie. I’ve been using TS Muxer to demux Bluray .m2ts files into component video and AC3, but I can’t figure out how to demux the AC3 into its component 6 channels. Is this even possible? Do the 6 channels contain separate files for the music soundtrack and movie effects and voices soundtrack? Not sure what’s in the 6 channels. Thanks in advance.

    Regards,

    Steve

  • http://adubvideo.net Adub

    It is possible to split an AC3 into it’s main channels. However, you are not guaranteed that the music will be isolated to a particular channel. The 6 channels contain speaker specific information (e.g. Front Right, Center, Front Left, Back Right, Back Left, etc…), not specific movie effects or voices.

    Still if you want to do it, here’s a quick guide how: http://forum.doom9.org/showthread.php?t=145171&highlight=goldwave

  • Joe

    thanks for clearing that up for me. Great explanation.

  • Stephen T.

    Thanks Adub, I’ll check it out.

  • Atmos

    Thank you for a very useful information.

  • Paulie

    Thanks for the brain food, you have have the lesson skill to be a professor.
    check you out again.

    Thanks Paulie

  • Qamar

    Very nice guide well done

  • carena

    Thanks for the advice above, Adub.

    Unfortunately, PGCDemux didn’t work and neither is DVD Decrypter. The best I got was 45 seconds of audio with Decrypter. All other tries ended up as “I/O Error!” with the following info:

    ScsiStatus: 0×02
    Interpretation: Check condition

    CDB: 28 00 00 03 CE 30 00 00 01 00
    Interpretation: Read (10) – Sector: 249392

    Sense Area: 70 00 03 00 00 00 00 0A 00 00 00 00 02 00 00 00 00 00
    Interpretation: No seek complete

    Do you think the DVD is damaged?

    Thx again for your help.

  • http://adubvideo.net Adub

    Indeed I do think the disk is damaged. An error like that often occurs when there is an interruption in the disk data, such as a scratch or a data disparity.

    However, errors like that can occur due to the copy protection being newer than DVD Decrypter can support. AnyDVD and DVD Fab may be able to process the disk if you continue to have issues with DVD Decrypter.

    I have written several tutorials on the use of both on this site, so feel free to check them if you need help.

  • carena

    Thanks, Adub. I did manage to make an AVI file of the DVD in question a while ago. Is there a way to lift the audio from it instead?

  • carena

    I’ve done some research on removing scratches from DVDs. Since the marks on the DVD are quite small and light, I’m thinking it might worth trying?

  • http://adubvideo.net Adub

    Indeed it’s worth a shot.

    At the same time, it is possible to extract the audio from your AVI file. AVI-Mux GUI should do the trick wonderfully. http://www.alexander-noe.com/video/amg/

  • Kangaloo

    I have many DVD Music Video’s that vary greatly with volume.
    They are all .VOB file format.
    I am forever adjusting the volume from one DVD video to the next with some blasting you out of your seat and some that you can hardly hear.
    I am running them through my PC Windows Media player 12 through an HDMI cable to a TV.
    What can I do to get the volume uniform on all Musiv DVDs???
    Any help here would be greatly appreciated
    Cheers

  • Tom

    Hey, thanks, very good info.

  • Tony

    A very clear and helpful explanation!

  • Snake

    can u plz tell me how to burn a subtitle to mp4 or mkv file quickly….am not asking about hardsubs, but about burning permanently to watch in sony bravia lcd t.v……thanks in advance …..

  • http://adubvideo.net Adub

    Um, the only way to “permanently burn” subtitles onto a video IS to hardsub them. There are only two types of subtitles, hardsubs and softsubs. Hardsubs have the subtitles “burned” on during the encoding, which makes them playable by any device as it’s just normal video, while softsubs are muxed in to the video container. There is a flag in the MKV container, for example, that “forces” the subs to appear on playback, but that is device support dependant, so if your TV doesn’t support softsubs, it doesn’t do a thing.

  • ABc212

    Great Explanation! Thx!

  • Jason

    Excellent Post! Thank you! This was the most informative explanation I have found online. Thanks again.

  • Khalid

    Hi There @ adubvideo, Although this article is way too old it describe exactly what i was looking for, but i have problem, for which i think you might help me, i have downloaded some movies, but those are without subtitles, and downloaded srt files for these movies and when i mux a movie with it’s subtiles using handbrake it does the job but it increases the file size drastically, i.e. for some movies it increase the file size to 1 gb and for one movie it increase 4gb, when i tried to mkvtoolnix, it does the job very neatly without increasing the file size , but my Panasonic home theater can play the movie for 5 seconds and then it stucks, the audio keep progressing but video stucks, any suggestion ?/

  • http://blog.gmc.uy Gervasio Marchand

    Thank you! great article :)