Log in

View Full Version : MP4Box worst video tool ever?


stax76
15th March 2015, 19:08
I don't know when I started to use mp4box in StaxRip, could be ten years, I remember it was a major pain to use from the beginning and it never changed, there are always weird problems I need to workaround. Best example is it writes files to the system temp dir but only when the command line is executed from my application and not when it's executed from the command shell, it does that even when I use the -tmp switch like so:

"C:\Daten\Projekte\VS\VB\StaxRip\bin\Applications\MP4Box\MP4Box.exe" -tmp "C:\Daten\Temp\test temp files\\" -single 2 -out "C:\Daten\Temp\test temp files\test - ID2.m4a" "C:\Daten\Temp\test.mp4"

The above command line executed by StaxRip result in this file:

C:\Users\Frank\AppData\Local\Temp\gpac_00432c10.tmp

Apparently the developers don't care simply closing and ignoring bug reports:

https://github.com/gpac/gpac/issues/61

Almost everyday I get MP4 related feedback for StaxRip, as soon as I read the word MP4 I start to think please not MP4Box again...

Sorry about the rant.

LoRd_MuldeR
15th March 2015, 19:25
If MP4Box ignores the "-tmp" switch and uses the system temp dir instead, how does it detect the system temp dir?

Most likely via TEMP or TMP environment variable! If so, then you could simply set these environment variables for the child process as desired, when you launch MP4Box from your main program.

Note that even the GetTempPath() system function will evaluate TEMP or TMP environment variables. So, if MP4Box uses that function, setting the environment variables still works.

stax76
15th March 2015, 19:45
I don't know if it's possible to set the variable, maybe using pinvoke, I think I go for cleaning like so:

cmd.exe /C del %temp%\gpac_*.tmp

LoRd_MuldeR
15th March 2015, 20:15
I don't know if it's possible to set the variable, maybe using pinvoke, I think I go for cleaning like so:

cmd.exe /C del %temp%\gpac_*.tmp

I don't know how exactly you create the child process.

But if you use native Win32 API, then the CreateProcess() (https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx) function allows you to set the environment variables for the child process easily. See the lpEnvironment parameter for details!

The same is possible with the QProcess class from the Qt framework, or the Process class from the Microsoft.NET framework.

stax76
15th March 2015, 20:19
I do everything with the .NET Process class.

LoRd_MuldeR
15th March 2015, 20:21
I do everything with the .NET Process class.

Then have a look at:
https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.environmentvariables%28v=vs.110%29.aspx

Example code here:
http://stackoverflow.com/a/14582921

stax76
15th March 2015, 20:46
It works, Nice!

Kurtnoise
16th March 2015, 08:32
I don't know when I started to use mp4box in StaxRip, could be ten years, I remember it was a major pain to use from the beginning and it never changed, there are always weird problems I need to workaround. Best example is it writes files to the system temp dir but only when the command line is executed from my application and not when it's executed from the command shell, it does that even when I use the -tmp switch like so:

A good start, instead of bashing tools and/or people, is to learn how to build the correct command line...:rolleyes:

Anyway, if you dont like this tool, there are few others...but that seems to be too hard for you to search such tools around here.

hello_hello
16th March 2015, 17:46
Why doesn't MP4Box just read and write like other muxing software? Extracting, creating iso images (from memory) then writing an MP4 file...... if nothing else it's reasonably slow.

Kurtnoise
17th March 2015, 06:17
What do you mean exactly ? This is what it does...read each streams to grab information and create a ISO file format concerning the muxing.

No need to have iso images or something like that...

Rumbah
22nd March 2015, 22:45
Well, I guess he*d like that mp4box does a 2 pass run for streaming, but in the first pass only saves the generated meta data or something like that (in memory) and then does the actual iso conversion on the fly in the muxing second pass without writing gigabytes of temp files.


PS: Could you name other good mp4 muxers? I searched for it but didn't find anything but mp4creator that didn't work that well for me.

LoRd_MuldeR
22nd March 2015, 22:56
PS: Could you name other good mp4 muxers? I searched for it but didn't find anything but mp4creator that didn't work that well for me.

L-SMASH comes to my mind:
https://github.com/l-smash/l-smash

Well, I guess he*d like that mp4box does a 2 pass run for streaming, but in the first pass only saves the generated meta data or something like that (in memory) and then does the actual iso conversion on the fly in the muxing second pass without writing gigabytes of temp files.

Well, the challenge with muxing an MP4 file is that the MP4 format requires global tables, which contain the exact size and the exact position of each sample (frame) in the file!

Since you cannot know this in advance, you either have to write the tables at the very end of the file, which makes "streaming" or "progressive download" impossible, or you have to re-write the entire file at the end.

GMJCZP
23rd March 2015, 13:09
With My MP4Box GUI I've tried to create a mp4 file with a subtitle track, and always happens that the last subtitle gets stuck to the end of the video, it seems the culprit is MP4Box, since I have tended to resort to Yamb with an older version of MP4Box and it does well.

Rumbah
23rd March 2015, 15:37
I get that you need 2 passes to get the relevant info in the first pass for streaming friendly muxing.

My idea was to only collect these informations in the first pass (position of each frame, etc ) without writing anything to disk. Then in the 2nd pass convert the input file on the fly to ISO and mux it with the help of the information gathered in the first pass.


Normally if I have a 10gb raw h264 file, in the first pass mp4box creates a 10gb temp iso file and then muxes it into the final mp4 file. So you have to write 20 gb to disk which is much more time consuming than only 10gb.