PDA

View Full Version : MONOGRAM x264 Encoder


RadScorpion
27th November 2008, 19:56
Hello,

after making a set of audio encoders I’ve been trying to focus on video a little bit. Here’s the first tryout of a libx264 based encoder filter. Full source code can be found in the local SVN repository. The encoder filter is released just like the x264 library as GNU GPL.

Features:

* accepts YV12 input frames
* constant QP and average bitrate rate control modes (only 1-pass encoding so far)
* built with support for multiple CPU cores
* easy-to-use presets for encoder options
* support for B-frames - PTS and DTS information can be read by the downstream filter using a custom IMediaSampleEx interface (see source code for more info)

From my initial tests the filter worked quite nicely although I suspect there might be some small memory leaks which showed up after running the debug version of the filter for a few hours. If you find something please do let me know.

Source : mm_x264_1.0.1.0_src.zip (1.7 MB) (http://blog.monogram.sk/janos/download/filters/mm_x264_1.0.1.0_src.zip)

Binary : mm_x264_1.0.1.0_bin.zip (341 KB) (http://blog.monogram.sk/janos/download/filters/mm_x264_1.0.1.0_bin.zip)

Enjoy,

Igor

LoRd_MuldeR
27th November 2008, 20:00
Where is CRF mode ??? :D

RadScorpion
27th November 2008, 20:02
In the todo list ;)

LoRd_MuldeR
27th November 2008, 20:06
In the todo list ;)

Nice. Leaving the best mode out, would be a bad idea ;)

I just gave your filter a first attempt, but as soon as I try to run the graph, it crashes on me:

http://img230.imageshack.us/img230/1977/mmx264my4.th.png (http://img230.imageshack.us/my.php?image=mmx264my4.png)

Did I use it in the wrong way? :confused:

RadScorpion
27th November 2008, 20:09
Hm. I don't think you did. Can you try it without the MKV muxer ?
e.g. FFDShow -> x264 Enc -> FFDshow -> Video Renderer.

LoRd_MuldeR
27th November 2008, 20:16
Sorry, I get the same problem:

http://img510.imageshack.us/img510/9779/mmx264part2tw8.th.png (http://img510.imageshack.us/my.php?image=mmx264part2tw8.png)

RadScorpion
27th November 2008, 20:18
Hmm... Could you give me some more info about the file (width, height .... ) or your CPU ?
Have you tried on a different file ?

LoRd_MuldeR
27th November 2008, 20:22
Hmm... Could you give me some more info about the file (width, height .... ) or your CPU ?

Video is 1680x944, a downscaled version of the "Crowdrun" sample. For system details see "My specs" in my signature, please.

Have you tried on a different file ?

Not yet, but I will do later...

RadScorpion
27th November 2008, 20:28
Your system is basically identical to mine. Would it be possible for you to upload the file for me somewhere ?

LoRd_MuldeR
27th November 2008, 20:32
Here you go:
http://www.mediafire.com/?sharekey=a0977474231d0c7dd2db6fb9a8902bda

Also tried a 640x480 Xvid clip, no luck either:

http://img148.imageshack.us/img148/5426/mmx264part3mu7.th.png (http://img148.imageshack.us/my.php?image=mmx264part3mu7.png)

RadScorpion
27th November 2008, 20:37
Could you try this build ?

http://blog.monogram.sk/janos/temp/mmx264.ax

I've disabled all SSE stuff.

LoRd_MuldeR
27th November 2008, 20:41
Could you try this build ?

http://blog.monogram.sk/janos/temp/mmx264.ax

I've disabled all SSE stuff.

Same crash message :(


Here is the debugger output:
[New thread 2064.0x1068]
[New thread 2064.0x804]
[New thread 2064.0x1320]

Program received signal SIGSEGV, Segmentation fault.
[Switching to thread 2064.0x1320]
0x02da9555 in mmx264!DllCanUnloadNow ()
from C:\Downloads\mm_x264_1.0.1.0_bin\mmx264.ax
(gdb) bt
#0 0x02da9555 in mmx264!DllCanUnloadNow ()
from C:\Downloads\mm_x264_1.0.1.0_bin\mmx264.ax
#1 0x02fa7a50 in ?? ()
#2 0x00000009 in ?? ()
#3 0x00000000 in ?? ()

Build obviously has no debugging symbols...

RadScorpion
27th November 2008, 20:46
Are you using any special configuration ? Or just the default one that came with the filter. Somehow I can't think of the right spot where the crash could happen :-\

LoRd_MuldeR
27th November 2008, 20:47
Are you using any special configuration ? Or just the default one that came with the filter. Somehow I can't think of the right spot where the crash could happen :-\

I messed with the settings indeed. I will try defaults now...


[EDIT]

Yup, with default settings it won't crash. Now I need to find the setting that causes the crash ;)


[EDIT²]

As soon as I switch to "CQ" mode and run the graph it will crash!

RadScorpion
27th November 2008, 20:47
Do you think you could run a debug build of the filter ?

LoRd_MuldeR
27th November 2008, 20:53
Do you think you could run a debug build of the filter ?

If you give me one, then yes :D

RadScorpion
27th November 2008, 20:56
As soon as I switch to "CQ" mode and run the graph it will crash!
Awesome. So perhaps I'm doing something wrong when configuring the encoder. Looks like I have to read the x264 source more carefully. Thanks for the help.

RadScorpion
29th December 2008, 13:24
Hello,

after a little struggle with mingw I’m happy to announce a new version of the x264 wrapper filter with these changes:

* libx264 built with mingw
* memory leaks fixed
* CRF support

hopefully this filter should not crash randomly :)

Please do some testing and report if anything goes wrong.

Source : mm_x264_1.0.2.0_src.zip (1.5 MB) (http://blog.monogram.sk/janos/download/filters/mm_x264_1.0.2.0_src.zip)

Binary : mm_x264_1.0.2.0_bin.zip (444 KB) (http://blog.monogram.sk/janos/download/filters/mm_x264_1.0.2.0_bin.zip)

Enjoy,

Igor

Sharktooth
29th December 2008, 16:32
got completely unwatchable video output.

graph:
http://www.webalice.it/f.corriga/stuff/graph.png

settings:
http://www.webalice.it/f.corriga/stuff/x264settings.png

RadScorpion
29th December 2008, 16:55
Did you set the settings before or after connecting to the muxer?
Btw. for the moment try not to use B-Frames - timestamp issues in DShow and so far I'm not sure how it works with muxers like Haali's.

yonta
29th December 2008, 17:17
Strange...
If I set the bitrate to 0 in ABR mode before setting Method to CRF,
the CRF mode seemss to work properly.

And one more thing, RadScorpion.
If I do right-click > Properties twice on mmaacencoder in GraphStudio, it crashes GraphStudio.

RadScorpion
29th December 2008, 17:29
Thanks. I'll investigate.
As for the AAC encoder - you must be having an old version. I have made several bugfixes without announcing them. Try to get the latest binary from the SVN repository.

Sharktooth
29th December 2008, 17:39
Did you set the settings before or after connecting to the muxer?
Btw. for the moment try not to use B-Frames - timestamp issues in DShow and so far I'm not sure how it works with muxers like Haali's.
dont remember... what's the preferable way?

RadScorpion
29th December 2008, 17:42
You should configure the filter before connecting the output pin. Otherwise it will try to change mediatype and some filters might not like that... and having wrong SPS/PPS might be the cause for garbage at the output of the decoder.

Sharktooth
29th December 2008, 17:45
i tried with b-frames = 0 and it's working (haali muxer).

edit: damn, now it worked with b-frames = 3 too...
i dont understand..

RadScorpion
29th December 2008, 17:57
Ok. Gonna take a closer look at the dynamic output format change so it would be possible to change encoder settings with the output pin connected.

Sharktooth
29th December 2008, 19:11
i dont think it's the pin. i've changed the settings even after it was connected and it worked...

RadScorpion
29th December 2008, 19:26
I think it is. The number of B-Frames is not encoded in the SPS/PPS so changing it won't matter. You must have changed the number of reference frames.

RadScorpion
12th May 2009, 12:21
Hello,

another update for the x264 encoder filter is available with the following changes:

* rebuilt with latest libx264
* code clean ups
* added options for weighted prediction, mixed reference frames, adaptive b-frame decisions and usage of b-frames as reference frames
* aspect ratio is preserved from VIDEOINFOHEADER2 structure and encoded in the VUI SAR values.

Source code is available in the SVN repository.

Download binary: mm_x264_1.0.4.0_bin.zip (450 KB) (http://blog.monogram.sk/janos/download/filters/mm_x264_1.0.4.0_bin.zip)

Enjoy,

Igor