Log in

View Full Version : x264 dropping frames in blu-ray encode


surreal120
17th February 2008, 20:50
I am trying to encode an episode of Planet Earth from blu-ray (.m2ts) to x264. My AviSynth script is pasted below. I am not sure what statistics to look at to show this more precisely, but (using a stopwatch) I timed playback of both the encoded video and the unencoded .m2ts to a specific point in the video when the word "Jungles" appears. The encoded video gets there about 10 seconds faster than the unencoded video. Not positive, but the encoded video seems to get even more out of sync as playback goes on. Obviously, this is making it impossible to get audio synced with my encode.


directshowsource("z:\m2ts\jungles\00006.m2ts",audio=false).ConvertToYV12()
Spline36Resize(1280,720)


Any help on this would be GREATLY appreciated!

akupenguin
17th February 2008, 20:58
directshowsource drops frames for some kinds of input

surreal120
17th February 2008, 21:33
Thanks akupenguin - so what should I do? For DVD encoding, I'm used to frameserving using DGIndex, but I haven't had any success getting DGAVCIndex to work with blu-ray files (not even sure if this is what you are implying I should do...)

Guest
17th February 2008, 21:40
Is the video H.264?

There will be a new release of DGAVCIndex later today that is fixed for M2TS (Blu-Ray) files. Watch for it and try that if your video is H.264.

If you don't want to wait, then demux the video using Xport and then use the existing DGAVCIndex.

If your video is VC-1, then what decoder are you using?

surreal120
17th February 2008, 21:54
Video is VC-1. I'm using libavcodec to decode the video. When I load the output stream from xport into DGAVCIndex I get enumerable "Found NALU type ##, len ## unrecognized..." errors, and if I click "No" and try to preview the video I get a "No Video frames found" message.

nurbs
17th February 2008, 22:09
Sure, thats because DGAVCIndex is for indexing AVC/H.264 and doesn't work on VC-1 encoded movies.

Guest
17th February 2008, 22:18
I use the Sonic decoders via DirectShowSource() for VC-1 without any frame-dropping issues. You need to properly specify the frame rate in your DirectShowSource() command!

surreal120
17th February 2008, 22:22
Thanks, I'll try the Sonic decoders. I have tried the following AviSynth script with equivalent results:


DirectShowSource("Z:\m2ts\jungles\00006.m2ts",fps=23.9760431376968,audio=false)
Spline36Resize(1280,720)


Is there a way to load VC-1 streams in DGAVCIndex? Will the new version you mentioned you are releasing later today work for VC-1 .m2ts sources?

Thanks for your help so far (hopefully Sonic decoder will work)!

Guest
17th February 2008, 22:26
DGAVCDec handles only AVC!

I have my working command line for Planet Earth at work and I can't remember whether it was 23.976 or 24. Doesn't EVODemux tell us? Your frame rate looks weird though. Try 23.976 or 24.

surreal120
17th February 2008, 23:17
Ah, that would make sense :) Does EVODemux work for Blu-Ray? Anyway, I will try setting the framerate to 23.976 or 24 and see if that works.

In the meantime, I enabled the Sonic decoders and extracted the VC1 video to an elementary stream using tsremux. Not quite sure what I'm doing here, but I named the stream with a .vc1 extension. This plays back smoothly in MPC and can confirm that Sonic decoders are being used with GraphEdit. But what do I do to get this into AviSynth?

Atak_Snajpera
17th February 2008, 23:41
will try setting the framerate to 23.976 or 24 and see if that works.
most likely 23.976 instead of 24

Guest
17th February 2008, 23:54
But what do I do to get this into AviSynth? DirectShowSource("Z:\m2ts\jungles\00006.m2ts",fps=23.976,audio=false,seek=false,framecount=???)

Replace ??? with the framecount given by EVOdemux.

Do not try to seek. Just encode straight through from the beginning.

surreal120
18th February 2008, 00:06
Thanks guys, I'll give that a try

surreal120
18th February 2008, 16:29
Ok, I tried encoding straight through from beginning to end with fps=23.976. My audio is still out of sync, but I'm now wondering if the video is not actually dropping frames but if the problem lies elsewhere - the time of the final encoded video is 51:06, which is the same as the .m2ts.

I'm now thinking the audio delay could simply be incorrect, but I'm getting some weird results in figuring that out. When I try demuxing the .m2ts in xport, it tells me that the First Audio PTS and the First Video PTS are both the same (FFFF0), but the output from EvoDemux gives drastically different results:


Opening file Jungles.vob
Reading...
File size: 7835 Mbytes.
VC-1 video stream 0 found!
First PTS = 000FFFF0 (+11650ms)
Substream id = 55
Profile = Advanced
Level = 3
Chroma Format = 4:2:0
Size = 1920x1080
Display size = 1920x1080
Aspect ratio = 1:1 (square samples)
Frame Rate = 23.976 (24000/1001)
Dolby Digital audio stream 0 found!
First PTS = 00235423 (+25725ms)
Substream id = 80
MPEG-2 video stream 1 found!
First PTS = 002EE4B0 (+34146ms)
Substream id = E1
Subpicture stream 3 found!
First PTS = 2A052C71 (+7833134ms)
Substream id = 23
Format = 2bitRLE
Extended subpicture stream 28 found!
First PTS = 3A2E92F8 (+10845897ms)
Substream id = 7C
Format = 2bitRLE
Done.


The delay between the audio and video is apparently 14075ms, which I tested and is WAY off. Any ideas? (FYI, not sure if my method of loading the .m2ts into EvoDemux is correct - I just renamed the file to a .evo extention)

Edit: When I load the encoded .mp4 into mkvmerge, it says the video type is avc1, rather than MPEG-4. Is that a clue to anything?

Snowknight26
19th February 2008, 04:46
Make a graph (using graphedit - google it) of Haali Media Splitter -> ffdshow, setting ffdshow to decode VC-1 using libavcodec.

Then, your .avs should look something like this:
directshowsource("graph.grf",audio=false,fps=23.976)

You shouldn't need the framecount as its determined automatically by ffdshow.

Also, H.264 is known as MPEG-4 AVC, MPEG-4, and AVC.

surreal120
26th February 2008, 16:44
Thanks guys for your help - I figured it out! The problem was with ffdshow - I was using tryouts beta 4 - dropped back to one of clsid's builds and everything is working smoothly now. I wasn't even sure I was on the right track before, so really appreciate the help!!