Log in

View Full Version : commandline(s) to remux .mkv into .mp4


hydra3333
25th January 2010, 08:51
Having created a .mkv, I find I have a tool which only accepts .mp4 files as input.

Can some please tell me the (free) commandline only tool(s) to re-mux a .MKV into a .MP4

... and if possible, the commandlines for inclusion in a .BAT file ?

I tried ffmpeg within this .BAT file
@echo on
REM %~1 - expands %1 removing any surrounding quotes (")
REM %~f1 - expands %1 to a fully qualified path name
REM %~d1 - expands %1 to a drive letter only
REM %~p1 - expands %1 to a path only
REM %~n1 - expands %1 to a file name only
REM %~x1 - expands %1 to a file extension only
REM %~s1 - expanded path contains short names only
REM %~a1 - expands %1 to file attributes
REM %~t1 - expands %1 to date/time of file
REM %~z1 - expands %1 to size of file
REM The modifiers can be combined to get compound results:
REM %~dp1 - expands %1 to a drive letter and path only
REM %~nx1 - expands %1 to a file name and extension only

%~d1
CD "%~dp1"
"C:\software\ffmpeg\ffmpeg.exe" -i "%~1" -f mp4 -vcodec copy -acodec copy -y "%~1-mp4.mp4"
pause
by dragging and dropping the .mpv onto it, but got this error
Could not write header for output file #0 (incorrect codec parameters ?)

:thanks:

Edit: the input is .mkv with h264 audio and AC3 audio

Snowknight26
25th January 2010, 18:26
I don't think it'll work with AC3 audio.

sneaker_ger
25th January 2010, 19:58
I get the same error. You'll probably have to combine mkvextract and mp4box for now.

hydra3333
25th January 2010, 21:26
mp4box doesn't seem to support ac3 ...
I'll see if ffmpeg has a build which supports good aac or something, and convert on the fly - any hints ?

sneaker_ger
25th January 2010, 21:34
mp4box does support ac3.

hydra3333
26th January 2010, 03:41
Now I find that the program I want to use doesn't accept a .ac3 in an .mp4 file - only in a .ts file.

What extension would I use with the MKVextract ? eg replacing the ffmpeg line in the above .bat with
"C:\software\mkvtoolnix\mkvextract.exe" tracks "%~1" 1:"%~n1.m4v" 2:"%~n1.ac3"
but is .m4v right ? The result won't play in MPC.

Also, what (free) commandline muxer could I then use to re-multiplex them into a .ts ?

Thanks

sneaker_ger
26th January 2010, 04:03
MPC doesn't have an elementary stream source filter for H.264 - that's why it doesn't work.
It's possible to directly remux mkv to ts with tsMuxer (https://forum.doom9.org/showthread.php?t=142559).

hydra3333
26th January 2010, 06:28
Thanks, I obtained the latest version 1.10.6 from http://www.smlabs.net/tsmuxer_en.html
I couldn't readily figure out the command line or find the help docs, however the gui that came with it was dead easy with its defaults.
Cheers

fangorn
26th January 2010, 10:10
For tsMuxeR you need to create an options file like the GUI saves it and pass it to the Command line version. There are no command line options that I know of.

I created a script that does mux from many input containers to MKV, MP4, TS, M2TS. But it needs bash interpreter and some Linux/UNIX command line tools. It could be possible to get it running in Cygwin though, but I have not tried it yet.