I have a question regarding framerate changes when copying H.264 video streams from MKV container to MP4.
I know the process to do it. I've used FFmpeg and MP4box (sometimes using YAMB GUI and other times just CLI). Copying video streams with FFmpeg is very convenient when the source videos have VFR and FFmpeg has no problem reading it, while with MP4Box things happen irregular situations that vary in each version but in general MP4Box works better only when input and output videos are CFR and most of the time it is not necessary to specify the FPS number because in recent versions of MP4Box it automatically detects the speed and number of frames from input videos. However, when copying CFR videos with FFmpeg, all input videos are treated as it were VFR videos and that's why when checking with MediaInfo it says that the output videos were changed to VFR and shows the different numbers of original frame rate, number of minimum frame rate and number of maximum frame rate. Is there a way to make FFmepg better differentiate and detect when input videos are CFR or VFR to prevent changes for output video streams that were copied?
The FFmpeg command line that I generally use is more or less like this.
I know that everything can be solved with -r [fps] but that would mean having to modify the command line every time I want to do batch conversion for several files and I want to avoid that, that's why I already have .bat files made with variables to keep things simple.Code:FOR %%I in (%inputdir%\*.MKV) DO "%ffmpeg%" -i "%%I" -codec copy "%outputdir%\%%~nI.mp4"
+ Reply to Thread
Results 1 to 15 of 15
-
-
-
After having read all that thread and doing other tests with more current FFmpeg and MP4Box bin, I came to the conclusion that currently the only way to get a video that keeps the same framerate when copying the video streams, first is to demux the H.264 video and then mux the raw videos to the new container. I don't like that because it means having more temporary files (which means having more storage space). With MP4Box I can understand that it is necessary to have raw H264 video because MP4Box doesn't have support to open MKV container and copy video streams. Luckily, MP4Box can now detect when a video is CFR and VFR, so there's almost no need to specify the fps number as before, because otherwise the new video would default to 25 fps. Even so, FFmpeg should get better at copying video streams.
-
GPAC/MP4Box maintainer here. In general if you see any weird content we're always happy to help at https://github.com/gpac/gpac/issues
> MP4Box doesn't have support to open MKV container
It does since GPAC 0.9 (circa 2019).
> it is necessary to have raw H264 video
By going back to raw without duming the original timestamps, you take the risk of a sligh desync. MP4Box allows to reparse for you:Code:-add src.mkv --reparse
-
Since 2019? Wow, I didn't know that and the strangest thing is in GUI tools like MeGUI that use MP4Box as MP4 Muxer, MKV is never mentioned as a supported file for video input and FLAC is also not mentioned among supported audio files. In fact, I also didn't know that the MP4 container could already support FLAC audio from a few years ago and until recently I found out because I read it in a question made to FFmpeg support, so I even tested with MP4Box and my surprise was that it supported FLAC audios but it never occurred to me to test with an input MKV file.
The parameter --reparse does not appear in the help info even if I run mp4box.exe -h all. Even in the latest versions of MP4Box, the way that the help info is displayed has changed a lot and in some cases (as -h format) it says to consult it using gpac.exe but the problem is that I only use MP4Box standalone (in fact, I am using a compiled version with Media AutoBuild Suite and other times I copy MP4Box.exe that is included in MeGUI) -
Thanks for the feedback. We made a lot of work to make GPAC more useful, safer, cleaner, and better documented. The Website should update soon. However it's hard to deal with such a level of complexity and keep everyone up to date. Let me know if you have suggestions (could be to post on this forum at each feature/release, etc.).
I'm also wondering if providing a GUI could make it easier for people to interact with the tool. There could be a WebAssembly playground from the Website or a "help center" able to centralize ressources. Ideas welcome
> The parameter --reparse does not appear in the help
The discoverability of the options is a real concern. The 'reparse' option doesn't belong to the MP4Box application, it belongs to a third-party module which MP4Box may leverage. For now you can typeCode:MP4Box -h reparse
-
Although it is important to update documentation on website, don't neglect the info that is displayed when run mp4box.exe -h. As I mentioned, that has changed so much in the last years and versions that I feel like some info has been lost that is now only displayed with gpac.exe. I remember that before when I ran mp4box.exe -h all I could find a list of compatible formats but now that list no longer appears and that's why I'm not surprised that I didn't find out about things like the current support with MKV or FLAC.
In fact, there is a problem with MP4Box that goes back years and has not been fixed until now. It has to do with the tags of the streams. The problem comes more or less since MP4Box 0.6.0, when "name=" is not set as title for each stream, somehow MP4Box adds a title but the content is none other than a copied part of the command line used or the GPAC version number. The only way to avoid that is by adding "name=" but leaving the field blank and as the last (or single) of all parameters set for tracks after set others like language.
A GUI that is aware of MP4Box updates has always been needed. YAMB has always struck me as one of the best GUIs using MP4Box but, besides not being updated for many years, I was limited to using a single file per session and usually I work with multiple files and do batch conversion. My MP4Box GUI on the other hand, had other limitations such as not being able to work correctly with VFR videos. MeGUI's MP4 Muxer also has the same limitations despite using the most recent MP4Box bin in every MeGUI release.
Sorry, but MP4Box gives an error with a red text that says
Code:Option -reparse unknown, please check usage.
-
Noted, we'll think about this.
Note that you can get the format list this way:
Code:$ MP4Box -h format see [filters documentation](Filters), `gpac -h codecs`, `gpac -h formats` and `gpac -h protocols`
-
Well, now I understand why MeGUI can't take advantage of the capabilities that MP4Box currently has, MeGUI only uses the standalone MP4Box, not the full GPAC package which is only available by downloading installers. MP4Box is dependent on external filters to work (for import MKV it's like this) instead of having everything built in static binary. Even if I were to build MP4Box again with MABS, it would still have the same static bin that is missing features that are only in GPAC packages. It's a shame.
-
Nope, you can make a static build that embeds the modules
That's what MABS seems to do btw: https://github.com/m-ab-s/media-autobuild_suite/blob/master/build/media-suite_compile.sh#L1486. Let us know if you see any issue.
-
Well, It has taken me a while to do it because errors that always happen when run MABS but I could build a new static MP4Box. However, I still get the same error.
Code:[core] Creating default credential key in I:\MP4Box/creds.key, use -cred=PATH/TO_FILE to overwrite Filter fin failed to setup: Filter not found for the desired type [Importer] Error probing \CS\input\input.mkv Failure while importing import: Filter not found for the desired type Error importing \CS\input\input.mkv#1: Filter not found for the desired type
-
Code:
$ MP4Box -h cred -cred (string): path to 128 bits key for credential storage
Since GPAC 0.9 (in 2020) we have a new architecture that allows MP4Box to be more flexible. So it can also process remote or live sources. Happy to answer your questions if you have some
We are also preparing some news, I should come and post here more often! -
-
Yes. In addition we introduced a new tool called "gpac". To download a content just do "gpac -i INPUT -o OUTPUT". For example "gpac -i http://..../xxx.mpd -o dump.mp4".
You can also dump all the qualities or transcode on-the-fly. You can find some command-lines here.
Let me know if you have questions or ideas. I think we've made a lot of things (and we are now the main packager of Netflix) but we did not necessarily advertised it on the right channels. Any advice welcome
We also made a survey. Despite what's written it is not too late to fill it!
Similar Threads
-
Best way to change .avi frame rate as batch process?
By cluelessScientist in forum Newbie / General discussionsReplies: 13Last Post: 26th Feb 2023, 10:42 -
Video capture frame rate vs. final output file frame rate
By Theodore in forum Capturing and VCRReplies: 5Last Post: 18th Apr 2021, 17:48 -
ffmpeg change frame rate on muxing not working,...
By Selur in forum Newbie / General discussionsReplies: 2Last Post: 10th Dec 2020, 07:42 -
Need variable frame rate ffmpeg
By Budman1 in forum Video ConversionReplies: 15Last Post: 9th Mar 2020, 05:10 -
FFmpeg is changing the frame rate to Variable when copying video?
By kkiller23 in forum Newbie / General discussionsReplies: 5Last Post: 1st Dec 2019, 13:14