Log in

View Full Version : Does --video-filter override --sar in x264?


zambelli
12th November 2010, 02:04
I'm trying to produce a series of H.264 encodes using x264 and for the purposes of testing I need to encode them as square pixel (either no SAR or SAR set to 1:1) even when the sources are anamorphic. Because the encoding is being done in batch it's most convenient for me to do the resizing inline using x264's "--video-filter resize" argument (as opposed to modifying the source Avisynth script).

Howver, it appears that when I use both "--video-filter resize" and "--sar" as arguments, the result is not what I expect at all.

For example, my source is 1920x816 in size (2.35:1 DAR). When I use the following command line:

x264_64.exe --pass 2 --bitrate 350 --video-filter resize:320,176 --sar 1:1 --ssim --output test.mp4 --profile high --preset slower --tune animation --keyint 48 --min-keyint 48 --no-scenecut source.avs

I get the following SAR as result:

x264 [info]: using SAR=22/17

So even though I explicitly specified SAR 1:1 on the command line, it seems that the DAR difference between 1920x816 and 320x176 is being used as the SAR.

What's interesting is that if I use the following command line:

x264_64.exe --pass 2 --bitrate 350 --video-filter resize:320,176 --sar 2:1 --ssim --output test.mp4 --profile high --preset slower --tune animation --keyint 48 --min-keyint 48 --no-scenecut source.avs

As a result I get:
x264 [info]: using SAR=33/17

So it would appear that x264 is using the 1920x816/320x176 DAR difference as SAR and then multiplying it by my user SAR.

My questions are:
1. Is this a bug or is it by design?
2. How can I completely override the SAR while still using "--video-filter"?


I'm using x264 build 0.107.1745 from Oct 10 2010.

P.S. It's nice to be back on Doom9 after a long break. :)

sneaker_ger
12th November 2010, 02:19
It is by design.
Use the following to override:
--vf resize:320,176,1:1
(read x264's fullhelp for all resize parameters)

Dark Shikari
12th November 2010, 03:37
--sar is the SAR of the input, AFAIK.

zambelli
12th November 2010, 04:05
It is by design.
Use the following to override:
--vf resize:320,176,1:1
(read x264's fullhelp for all resize parameters)
Ah! That did the trick! Thank you.

I didn't think to look for SAR info in the --video-filter help because I had assumed --sar was the parameter that controlled it.

--sar is the SAR of the input, AFAIK.
Yep, that makes sense now. I don't think it's entirely obvious from the documentation though - the help text could probably benefit from some clarification.

Thanks, guys!

IppE
12th November 2010, 08:27
From what I've tested by default the filter writes SAR so that it plays in the correct aspect ratio no matter how you resize it.

sneaker_ger
12th November 2010, 18:20
Yes, that's true. This behavior is also documented in the help, I recommend everyone wanting to use the resize filter to read it.

zambelli
12th November 2010, 23:29
Yes, the default functionality seems to be to automatically set the SAR to the difference between inpur DAR and resized DAR. Though I don't think that's obvious from the help (I don't think users can figure it out without trial and error) and I think the help could be clearer on the fact that --sar is related to the SAR of the input rather than the output.

I think the design is fine - but I think the documentation doesn't make the behavior totally clear.

Sharc
13th November 2010, 00:16
^^^
http://mewiki.project357.com/wiki/X264_Settings#video-filter