PDA

View Full Version : xml to CLI for x264 commands


jult
23rd July 2008, 02:41
Is there an easy way to convert all the settings from an example (megui profile) like this:
<?xml version="1.0"?>
<GenericProfileOfVideoCodecSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>CE-QuickTime</Name>
<Settings xsi:type="x264Settings">
<EncodingMode>4</EncodingMode>
<BitrateQuantizer>1000</BitrateQuantizer>
<KeyframeInterval>250</KeyframeInterval>
<NbBframes>1</NbBframes>
<MinQuantizer>10</MinQuantizer>
<MaxQuantizer>51</MaxQuantizer>
<Turbo>true</Turbo>
<V4MV>false</V4MV>
<QPel>false</QPel>
<Trellis>false</Trellis>
<CreditsQuantizer>40</CreditsQuantizer>
<Logfile>.stats</Logfile>
<CustomEncoderOptions />
<FourCC>1</FourCC>
<Zones />
<MaxNumberOfPasses>3</MaxNumberOfPasses>
<NbThreads>0</NbThreads>
<QuantizerCRF>1000</QuantizerCRF>
<EncodeInterlaced>false</EncodeInterlaced>
<NoDCTDecimate>false</NoDCTDecimate>
<PSNRCalculation>false</PSNRCalculation>
<noFastPSkip>false</noFastPSkip>
<NoiseReduction>0</NoiseReduction>
<MixedRefs>false</MixedRefs>
<X264Trellis>1</X264Trellis>
<NbRefFrames>5</NbRefFrames>
<AlphaDeblock>0</AlphaDeblock>
<BetaDeblock>0</BetaDeblock>
<SubPelRefinement>5</SubPelRefinement>
<MaxQuantDelta>4</MaxQuantDelta>
<TempQuantBlur>0</TempQuantBlur>
<BframePredictionMode>3</BframePredictionMode>
<VBVBufferSize>-1</VBVBufferSize>
<VBVMaxBitrate>-1</VBVMaxBitrate>
<METype>2</METype>
<MERange>16</MERange>
<MinGOPSize>25</MinGOPSize>
<Profile>1</Profile>
<Level>15</Level>
<IPFactor>1.4</IPFactor>
<PBFactor>1.3</PBFactor>
<ChromaQPOffset>0</ChromaQPOffset>
<VBVInitialBuffer>0.9</VBVInitialBuffer>
<BitrateVariance>1.0</BitrateVariance>
<QuantCompression>0.6</QuantCompression>
<TempComplexityBlur>20</TempComplexityBlur>
<TempQuanBlurCC>0.5</TempQuanBlurCC>
<SCDSensitivity>40</SCDSensitivity>
<BframeBias>0</BframeBias>
<Deblock>true</Deblock>
<Cabac>true</Cabac>
<WeightedBPrediction>false</WeightedBPrediction>
<AdaptiveBFrames>true</AdaptiveBFrames>
<BFramePyramid>false</BFramePyramid>
<BRDO>true</BRDO>
<biME>false</biME>
<ChromaME>true</ChromaME>
<P8x8mv>true</P8x8mv>
<B8x8mv>true</B8x8mv>
<I4x4mv>true</I4x4mv>
<I8x8mv>false</I8x8mv>
<P4x4mv>false</P4x4mv>
<AdaptiveDCT>false</AdaptiveDCT>
<SSIMCalculation>false</SSIMCalculation>
<Lossless>false</Lossless>
<QuantizerMatrix>Flat (none)</QuantizerMatrix>
<QuantizerMatrixType>0</QuantizerMatrixType>
<DeadZoneInter>21</DeadZoneInter>
<DeadZoneIntra>11</DeadZoneIntra>
</Settings>
</GenericProfileOfVideoCodecSettings>
to the commandline options for x264 encoder?

I've been trying hard to use an encoder bat file that uses x264.exe (yes, I know, VfW) and would very much like to be able to use (convert) some of those wonderful MeGUI profiles into command line options for some scripts I need to use.

For example, I would like to incorporate the above into:

x264.exe --crf 16 --bitrate 1590 --keyint 225 --min-keyint 25 --ref 10 --mixed-refs --bframes 2 --b-pyramid --b-rdo --bime --weightb --me esa -merange 64 --subme 7 --partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --no-cabac --no-psnr --no-ssim --threads auto --thread-input --progress --output

so that it results in a Quicktime compatible file. (I don't use QT myself, but I need it for a certain group of people..)

Thanks in advance!

Dark Shikari
23rd July 2008, 02:54
Just open the profile in MeGUI and the commandline will display in the settings app.

jult
23rd July 2008, 03:08
OK, now I feel silly ;-)
Wasn't aware it was that simple. By the way, it's not in the settings tab, but visible when clicking the [config] button next to the video profile option on the main screen.

Great, thanks. I love x264. Keep up your amazing work on this codec.

jult
23rd July 2008, 12:45
So, if this makes x264 output QuickTime compatible;
--pass 2 --bitrate 1000 --stats ".stats"
--ref 5 --bframes 1 --b-rdo --direct auto --subme 6 --trellis 1
--analyse p8x8,b8x8,i4x4 --me umh --no-psnr --no-ssim

what part of this is incompatible with QT?:--bitrate 800 --keyint 225 --min-keyint 25
--ref 10 --mixed-refs --bframes 2 --b-pyramid --b-rdo --bime --weightb
--me esa -merange 32 --subme 7
--partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --no-cabac --no-psnr --no-ssim

Any idea? (I'd like to merge the two without breaking QT compatibility)

Sharktooth
23rd July 2008, 13:00
CRF 16 and bitrate 800???!??!??
plain wrong you cant use both.
also you cant merge the settings. the megui QT preset has the maximum working settings for QT for windows.
altering most of those (obviosly, except those which do not intefere with decoding) will make the encode NOT working (at least on windows).

jult
23rd July 2008, 13:33
CRF 16 and bitrate 800???!??!??
plain wrong you cant use both.LOL, it works though. I was just experimenting with that a bit. What's the lowest CRF to use when you want to reach around 800 kbit/s, according to you?

also you cant merge the settings. the megui QT preset has the maximum working settings for QT for windows. altering most of those (obviosly, except those which do not intefere with decoding) will make the encode NOT working (at least on windows).Meaning you can merge them. Of course one can merge those settings, which is why I was asking.
And I was asking this precisely because it is totally unclear WHICH commands make it 'QT compatible'. I'd like to know, so I can use that info to my advantage. Do you have a discussion you know about that talks about this? I could not find it.

By the way, if it's only for QT in Windows, you should mention this! I require this info for QT on Macs.

Sharktooth
23rd July 2008, 13:40
CRF is not related to bitrate. it all depends on the source.
for x264 settings that do not influence playback :search:
QT for win is the minimum common denominator... QT on mac is almost able to play everything... thank apple for the BS they make...

jult
23rd July 2008, 14:19
As I understood it, and I've done a lot of reading regarding the CRF parameter, it is optimal when doing singlepass encodes, and the option is mutually exclusive with bitrate, in which case the bitrate operates as a type of ABR with 1pass.

By the way. Using the command exactly as from the profile:
x264.exe --pass 2 --bitrate 1000 --stats ".stats" --ref 5 --bframes 1 --b-rdo
--direct auto --subme 6 --trellis 1 --analyse p8x8,b8x8,i4x4 --me umh --threads auto --thread-input
--progress --no-psnr --no-ssim --output "%%~na.h264" "%%a"

I get this error:

x264 [error]: ratecontrol_init: can't open stats file

and I see no reason whatsoever why it can't write in that folder, there's enough room for a zillion stats files. What's up with that error?

Sharktooth
23rd July 2008, 15:01
you need the 1st pass to create the stats file...

jult
23rd July 2008, 15:33
Yes thanks, just found out. Must say it's kind of weird one still has to operate it like that. You already tell it to do 2 passes, why the requirement of an extra commandline, when you do the exact same thing in the two passes? How many use a different commandline for the first pass?

Dark Shikari
23rd July 2008, 15:33
x264 [error]: ratecontrol_init: can't open stats file

and I see no reason whatsoever why it can't write in that folder, there's enough room for a zillion stats files. What's up with that error?It didn't say it can't write the file--it can't read it (it can't open it). That's on the second pass, when its trying to read the passfile from the first pass... which means you forgot to run your first pass.

Sharktooth
23rd July 2008, 15:36
--pass 2 tells x264 to do a second pass... not a 2 pass encode.
it needs --pass 1 before...
it have to run 2 different times, 1 (1st pass) to collect the stats and the 2 (2nd pass) to make the real encode.
MeGUI can automate the 2 passes thing modifing the first pass parameters to have a turbo/fast first pass (if the user choses it) without loosing too much quality. other GUIs automate the multipass thing as well.

jult
23rd July 2008, 15:51
Sure, I remember all that from operating mencoder and ffmpeg, which both do it the same way (using the first pass only to determine max values and such).
I just forgot I got this command not as is, but as used by MeGUI.
(Assumed it could not write the .stats file, because I didn't see it generated..)