Log in

View Full Version : Problem comparing x264 compressed vs the mpeg2 source


R3Z
7th June 2007, 06:17
Hi Everyone,

I have noticed that its hard to do a direct comparison with the x264 encoded files against the original source files. Using a compare script like the following;

Function compare(Clip original,Clip processed)
{

frameadjust=0
Original = Original.Subtitle("Original")
Processed = Processed.Subtitle("Processed")
interleave(original,processed)

}

a=directshowsource("snow.avs")
b=directshowsource("snow.mp4")
compare(a,b)

or something simpler as;


a=directshowsource("snow.avs")
b=directshowsource("snow.mp4")
stackhorizontal(a,b)


The problem is that the clips never sync. The same framerate and number of frames were used, however the x264 video never matches up.

I am using 4 bframes and 8 reference frames with x264, could this be the cause ? Is there anything i can do to offset the changes made to the stream by x264 ?

Cheers for any suggestions (i did try to search first btw).

PuzZLeR
7th June 2007, 06:37
I am using 4 bframes and 8 reference frames with x264, could this be the cause ?

Yes. Your video is more like slices, or "chunks", unlike the more simple frames of MPEG-2 we're used to. It would be difficult to find an H.264 equivalent frame to the "thinner" ones of MPEG-2. Don't know the tech behind it, but that's the logic though.


Is there anything i can do to offset the changes made to the stream by x264 ?

Well, if I want to compare my BMW to my Porsche, do I remove the features down of one vehicle so they can go the same speed? :)

Good post though. I too however share the same question when wishing to compare clips and look forward to an answer from the next post(s). :thanks: in advance!

foxyshadis
7th June 2007, 07:06
Most likely the problem is somewhere in the directshow chain; the splitter might not be returning all frames. Try using AVCSource, which is frame-accurate. (You have to demux from mp4 first.) Alternately, you can load into avidemux, say, and convert to a lossless avi, since avi is also frame-accurate if no b-frames are involved. Load the avs with avisource or just import.

akupenguin
7th June 2007, 07:08
The H.264 standard uses the terms "slice" and "picture" instead of "frame", but that doesn't mean there's anything different about them. I think they just wanted unambiguous terms for interlacing.
The only feature (of those implemented in x264, at least) that has possible repercussions visible beyond the decoder, is B-pyramid.
4 B-frames? no problem, MPEG-2 can do that too. Multi-ref? no problem, it doesn't even violate vfw.

So the cause of the desync is something else. My first guess would also be directshowsource.

R3Z
7th June 2007, 11:42
Most likely the problem is somewhere in the directshow chain; the splitter might not be returning all frames. Try using AVCSource, which is frame-accurate. (You have to demux from mp4 first.) Alternately, you can load into avidemux, say, and convert to a lossless avi, since avi is also frame-accurate if no b-frames are involved. Load the avs with avisource or just import.

Thanks for your info. After encoding a test stream to RAWAVC (.264) and using AVCSource to compare the frames seem to line up fine. Thats the fix :)

The H.264 standard uses the terms "slice" and "picture" instead of "frame", but that doesn't mean there's anything different about them. I think they just wanted unambiguous terms for interlacing.
The only feature (of those implemented in x264, at least) that has possible repercussions visible beyond the decoder, is B-pyramid.
4 B-frames? no problem, MPEG-2 can do that too. Multi-ref? no problem, it doesn't even violate vfw.

So the cause of the desync is something else. My first guess would also be directshowsource.

I am thankfull for your information too :) Without knowing the real reason its hard to figure things out !

Can i suggest this be added to the faq ? I am sure lots of people have had this issue and were to embarassed to ask about it.

Cheers !