Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I think that everybody knows that problem about downloading 480p & 1080p videos from Youtube, and that the only way available for many Download programs is to download the Video and Audio Tracks Separately , then Mux them together into one container.

There is a ffmpeg code to Multiplex (one by one) the .m4a & .m4v tracks into one .mp4 container

Here's the Code:

ffmpeg -i "file name.m4v" -i "file name.m4a" -acodec copy -vcodec copy "file name.mp4"

But How to BATCH multiplex Many .m4a & .m4v files ?

Thanks in advance...

share|improve this question
up vote 2 down vote accepted

Use a for loop. This example is for bash and uses bash variable manipulation, but it can be adapted for other unix/linux-type shells.

Note: this assumes that you are in the directory with the files, and that both video and audio files are present with the same name, differing only by extension (.m4v -- video, .m4a -- audio).

for v in *.m4v; do ffmpeg -i "${v}" -i "${v//.m4v/.m4a}" -acodec copy -vcodec copy "${v//.m4v/.mp4}"; done


for v in *.m4v Perform the following actions on every file ending in '.m4v'. v is a variable name that will be assigned every video file in the current directory, one at a time, by bash. bash will automatically convert the *.m4v into a list of .m4v files in the current directory and feed them into the for loop. You do not need to input file names manually.

Variable v holds a different video file name on each loop iteration, for example "video_file_1.m4v", then "video_file_2.m4v", etc. The ${v//pattern/replacement} tells bash to find occurrences of pattern and replace them with replacement. For example, ${v//.m4v/.mp4} will convert the file name "video_file_1.m4v" to "video_file_1.mp4".

share|improve this answer
Thanks savanto for your Reply, unfortunately, your code didn't work for me .. actually I've been using ffmpeg for just 4 days, so I'm not that advanced user and honestly I Couldn't understand about half of your answer! (Forgive my ignorance). would you please tell me more specific steps to get that job done? Really appreciate your help..thanks – KorkOoO Jun 4 '14 at 3:15
@ENG.KARIM I've added a more thorough explanation to the answer, please take a look. The answer assumes that you are on a unix/linux system, that you are using bash (if you are not sure, type bash), that you cd to the directory with the video files (cd /path/to/video/files), and that every video file has a corresponding audio file (video_file_1.m4v, video_file_1.m4a). If these hold, you simply need to paste the command from the answer into your terminal -- no modifications needed! The file names will be read automatically and ffmpeg executed on each one. – savanto Jun 4 '14 at 5:55
@ENG.KARIM If you are still getting errors, please post them, so that I can tell what's going on. – savanto Jun 4 '14 at 5:59
thanks a lot for your concern savanto.. I think you should know that actually 1.I'm on a windows system 2.all the video and audio files are in one folder (D:\Tubes), and I can get into its Path by using a context menu RegKey Called "open command pormot here" instead of "cd FolderName" , so I assure you that I'm in the right folder path and all the files that need to me Multiplexed are included .. the problem is when i try to use your code , I get this: "v was unexpected at this time." so, did i make something wrong ? – KorkOoO Jun 6 '14 at 3:13
The above code is for unix or linux type shells, so it will not work on Windows. You will need either Cygwin to run the above code, or else use syntax appropriate for a Windows shell. Which, unfortunately, I cannot help you with. Please retag your question -- the "youtube" tag is completely unnecessary, while a "windows" tag will get your question more exposure to people who can help you. – savanto Jun 6 '14 at 3:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .