View Full Version : undesired 23.976fps --> x264 --> mp4 --> 25fps
redfordxx
12th December 2005, 15:42
Hi
I have strange experience. I encode 23.976 video via x264 into mp4. The MP4 container, how to say it, "pretends" it is 25fps.
Is that normal? Can it be due to some wrong settings?
When I mux it mp4-->mkv, then it is OK...
Thanx
R.
quake74
12th December 2005, 16:13
IIRC mp4box muxes everything at 25fps by default, you need to use the -fps option to change it.
redfordxx
12th December 2005, 16:16
IIRC mp4box muxes everything at 25fps by defaultThis is directly from x264 w/o MP4box.
bond
12th December 2005, 16:38
what tells you that the .mp4 is 25fps?
DeeGee
12th December 2005, 17:09
Haali Media Splitter reports the fps always as 25fps (on any mp4 file) to ffdshow at least. But ffdshow still plays the file at correct fps. Noticed this on one 60fps file that played fine, but the fps was still reported as 25fps.
stephanV
12th December 2005, 17:15
Haali's splitter has an option called "Force fake 25 fps in media type", that could be it?
redfordxx
12th December 2005, 17:40
what tells you that the .mp4 is 25fps?
When I open
mp4-->avs-->VDMPEG
for example. Has different framecount too. During playback too, but I have to check again when I get home.
redfordxx
12th December 2005, 23:26
Haali's splitter has an option called "Force fake 25 fps in media type", that could be it?
I have set NO...
bond
12th December 2005, 23:28
mp4info from mpeg4ip should tell you the real framerate of the .mp4
redfordxx
13th December 2005, 09:26
mp4info from mpeg4ip should tell you the real framerate of the .mp4I didn't try mp4info (don't have it) but mp4box info writes scale 2997. So I suppose it's related to 2997/125=23.976, although the 125 is not mentioned.
However, nice to know the "real" framerate but when the delivered framerate is different, the delivered framecount is different and there are some grey frames at the end, the info itself doesnot help.
You have correct fps directly from x264.exe into mp4?
AVI works fine (when muxed with AVS2AVI with correct fps parameter)
redfordxx
13th December 2005, 20:46
I tried this but didn't help:"mp4box" -add test25.mp4 -fps 23.976 -new test24.mp4is the commandline correct?
bond
14th December 2005, 00:01
You have correct fps directly from x264.exe into mp4?no you dont. simply use mp4info and tell use what framerate the mp4 has ;P
I tried this but didn't help:"mp4box" -add test25.mp4 -fps 23.976 -new test24.mp4is the commandline correct?no. mp4box doesnt let you change the fps that way. you need to demux and remux the video
redfordxx
14th December 2005, 01:37
simply use mp4info and tell use what framerate the mp4 hasI don't have it and don't know where to get it. But MP4UI says it is 23.976fps
mp4box doesnt let you change the fps that way. you need to demux and remux the videowhat options should I use correctly?
MeteorRain
14th December 2005, 02:52
what options should I use correctly?
well, since RAW format doesn't contain FPS info, you should extract the raw out, and remux it into mp4.
redfordxx
14th December 2005, 09:54
1. I exported Track 1 to raw *.h264 (hope correctly) and then back, but didn't help. Can you please post exact commandline, so I can be sure, there's no mistake?
2. Other thing: when I converted the *.h264 to avi with AVC2AVI with parameter -f 23.976, the result video was 23.975 with correct framecount and different time.
When I use -f 23.976001, it's OK (I obtain 23.976). Maybe some rounding error? (All my test videos have <1000frames, but I doubt that's the reason)
3. When I have finally the x264 in avi, another think is wierd:
frame 0 is OK,
frames 1,2 are blank (frame 0 is repeated, when I am lucky)
frames 3,4,... contain source frame 1,2,...
last two frames are missing.
When I trim and join the video in avs suitably, it can be partially fixed. Example with 1000frames long clip:
s=AVISource("test.avi")
t1=s.trim(500,999)+s.trim(0,499)
t2=t1.trim(500,999)+t1.trim(0,499)
t3=t1.trim(502,999)+t1.trim(0,501)Clip s has the problems I mentioned above.
Clip t1 has all frames. Frames 500,501 are the last ones, frames 502,503,504 are the first.
Clip t2 has two frames from the middle in the beginning, although it seems to be the the inverse operation of the previous.
Clip t3 has all frames on correct places, except the frame 0.
The longer I experiment, the more problems I discover, uh oh. Can any1 reproduce the errors 2 or 3? And please help with 1.
Doom9
14th December 2005, 11:03
haali or mpc's internal splitter, the only way I've gotten the proper fps reported was by using ateme's splitter instead. But just because MPC reports something doesn't mean you have to trust it.. e.g. if you mux audio to that 23.976fps source and it's in synch, then obviously the indicator is plain wrong.
3. When I have finally the x264 in avi, another think is wierd:
frame 0 is OK,
frames 1,2 are blank (frame 0 is repeated, when I am lucky)
frames 3,4,... contain source frame 1,2,...
last two frames are missing.
that's normal behavior. Bond can give you the full rant about AVC in AVI, or anything with B-frame for that matter. If you don't want this behavior, don't use AVI, use MP4 or MKV.
redfordxx
14th December 2005, 11:29
haali or mpc's internal splitterAnd when I open mp4 via avs, haali is involved?the only way I've gotten the proper fps reported was by using ateme's splitter instead.I already know ateme enc is expensive. Is the splitter free?that's normal behavior. Bond can give you the full rant about AVC in AVI, or anything with B-frame for that matter. If you don't want this behavior, don't use AVI, use MP4 or MKV.I don't want to blindly stick to AVI. I tried MP4 first. I just want to have container with correct framecount and length of the video and correct seeking. Both in playback and avs.
So I try to find ateme. Is that somewhere to download, or is that in Nero 7 Premium? (I installed only Burning ROM and not Showtime, coz I don't want more and more players... so maybe I have it but not installed)
Doom9
14th December 2005, 12:59
And when I open mp4 via avs, haali is involved?whichever splitter is normally handling your MP4s is.. directshowsource does nothing other than render the mp4.
Is the splitter free?No
Once again I fail to see your problems.. it's a perpetual thing with you isn't it.. you try something, don't really think it through get stuck, and instead of just listening what other people with some experience have you say, you twist and turn and make everything much worse.
You should adopt the following rule of describing a problem:
1) This is what I'm doing (step by step, detailed)
2) This is what I want to do
3) This is what I expect will happen
4) and this is what happens instead.
Keep it simple and try again. There's a lot more I could say that would just show that you don't really get what you're doing, you probably don't know it yourself / or making a hell of a bad job at trying to tell us.
redfordxx
14th December 2005, 13:46
1) encode x.avi --> x.avs --> x264 --> x.mp4
Make script x.mp4.avs:DirectShowSource("x.mp4")Open x.mp4.avs in VD-MPEG
View file information.
2) Make avs script from mp4 file.
3) See the framecount, framerate (23,976)and length of x.mp4.avs equal to x.avs
4) See the higher framecount, higher framerate (25.000) and same length compared to x.avs
(that is not only about seeing the info, the problem is real:there are more frames, IIRC some of them are grey, seeking is not exact, i.e. sometimes, when I play to frame X and jump to frame X, I see different frame)
redfordxx
14th December 2005, 14:04
1) export mp4box -raw 1 x.mp4 -->x_track1.h264
avc2avi -i x_track1.h264 -o x.avi -f 23.976Open x.avi in VD-MPEG
View file information.
2) Trying if that won't help, when having problems with fps in mp4
3) fps=23.976, length, framecount equal
4) fps=23.975, longer, framecount equal
(plus the issue with the first and last two frames, but OK, taken for granted)
Workaround (not tested on longer videos >1000frames):
1) exportmp4box -raw 1 x.mp4 -->x_track1.h264
avc2avi -i x_track1.h264 -o x.avi -f 23.97601Open x.avi in VD-MPEG
View file information.
4) fps=23.976, length, framecount equal
(plus the issue with the first and last two frames, but OK, taken for granted)
+asking whether anyone can reproduce it and whether it is bug of avc2avi
Doom9
14th December 2005, 15:42
DirectShowSource("x.mp4")And the alarms go off. DirectShowSource without FPS is like soup without salt.. just don't, don't you ever dare to even think of it.
I have disabled my ateme filter so that ffdshow handles everything, created this avisynth script: directshowsource("matrix-xvid.mp4", 23.976), loaded it in VDub, and it shows the proper framerate and number of frames. But playing it in a media player reports the wrong framerate, even though the audio always stays in synch (and so clearly what my media player reports is not accurate and I shall not ever trust it)
However, you're approaching the whole thing completely wrong. You need to use mp4box to get info from your mp4 file.. it'll know what's actually in that file. What VDub reports is only what DirectShow reports, so if your DS splitter reports the wrong FPS, you're screwed. It also make no sense to go through two filter chains to find that information.
Furthermore, you cannot compare that script frame by frame with your AVI. Why not? Your AVI might contain differnt frame order (if it has b-frames for instance), and I'm afraid the go to function of DirectShow are generally not properly implemented in most filters, meaning if you go to frame X in codec X, it will be different from frame X in codec Y. That doesn't mean that when you play the file linearly it will be wrong, but if you use the go to functionality it will. Please do not argue here, I have grown many gray hairs during many codec comparisons about this.. just accept it as a fact of life and move on.
Last but not least, unless any codec uses packed bitstream to put B-frames into AVI, you're going to lose frames (and in that case, frame X is effectively not equal if you're looking at the same source encoded using the same codec but put into two different containers).
redfordxx
14th December 2005, 16:29
Thanks a lot for your patience and valueable answer.
When speaking about framerate I have small question: When encoding wmv-->avs-->x264-->mp4, I have to ChangeFPS to standard...
For any compatibility, standards and other reasons is better:
a) 23976/1000
b) 24000/1001
c) doesnot matter
Furthermore, you cannot compare that script frame by frame with your AVI.My original.avi is Lagarith lossless, so only Keyframes, so I guess no problem.
BTW: I don't know, whether it is good or bad in compression, but it is the first one, which worked smoothly in YV12 for me. ;)
Haali
14th December 2005, 21:59
Note that the mp4 container does not store fps anywhere and relies only on individual frame timestamps for playback. Some codecs also store fps in their bitstream, but it is not required to match timestamps. So technically the only way to reliably determine file fps is to examine data in ctts and stts boxes of your mp4 file. The value shown in DShow players will be always 25fps when you use ffdshow because that's the value it uses when source fps is unknown.
redfordxx
15th December 2005, 01:10
@haali:
wow quite new info...
so the mpeg4ip info mentioned above maybe does not read the fps from the mp4 but calculates it based on length info
@doom9
after entering fps:everything is ok except that few frames at the end are missing
(grey in VDub, less drawn frames in MPC stat...)
redfordxx
10th January 2006, 19:40
After some experience, I have to add a question, coz the recommendation
And the alarms go off. DirectShowSource without FPS is like soup without salt.. just don't, don't you ever dare to even think of it. does not seem to me so black-white. I would like to know what's happening behind...
It seems to me, that the result of:
directshowsource("matrix-xvid.mp4", 23.976)
should be the same as
directshowsource("matrix-xvid.mp4").ChangeFPS(23.976)
provided they have not different frame drop or frame add algo's.
At least for original fps<25 (now referring to Haali's statement).
When I opened file.mp4 which was 23.976, the reported framecount was higher than it should be.
When I open 30fps file without fps parameter, would it decimate it?
Well and last but not least, it is all nice, until I come to file with variable framerate. I can't enter any fps... So I will have always borked file seeking in avisynth?
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.