Log in

View Full Version : X264 color space problem


vineet
9th August 2010, 07:42
Hey guys

I am encoding my videos using x264 and some of these videos have an odd resolution, something like 1223*1042 or smthn. Whenever I try x264 it gives me a colorspace incompatibility message(this resolution is not compliant with colorspace i420).
I am not even able to resize my videos


As I am under a deadline, any help would be much appreciated.

nurbs
9th August 2010, 08:21
1223*1042 x264 uses YV12 colorspace so you need even resolutions. Mod2 will do IIRC.

vineet
9th August 2010, 08:52
x264 uses YV12 colorspace so you need even resolutions.

Dude, I do need to convert these files. Can I somehow reduce or increase the resolution by say, 1 pixel, using ffmpeg or smthn and then convert using x264.


Mod2 will do IIRC

I have no idea what that means, am not an expert. Could you please give a little detail on that.

J_Darnley
9th August 2010, 10:16
Use the crop or resize (or pad if you have a patched version) filters that x264 now has. With "mod2" he means that the frame dimensions must be a multiple of 2.

vineet
9th August 2010, 11:12
Nope, cropping parameters have to be a multiple of 2. So odd dimensions stay odd. Most probably, same is true with padding. Any other ideas??

Dark Shikari
9th August 2010, 11:22
Nope, cropping parameters have to be a multiple of 2. So odd dimensions stay odd. Most probably, same is true with padding. Any other ideas??That shouldn't be the case; if the video is in a colorspace that allows non-mod2 resolutions, the crop filter should be able to crop it. If it isn't in a colorspace that allows non-mod2 resolutions, it can't possibly be non-mod2.

Sounds like a bug in the crop filter.

J_Darnley
9th August 2010, 11:24
Nope, cropping parameters have to be a multiple of 2. So odd dimensions stay odd. Most probably, same is true with padding. Any other ideas??

What colourspace is the input video and what --vf options did you use?

[EDIT] I just tested with 1223x1024 rgba input and there was no problem cropping 1 from the left.

vineet
9th August 2010, 12:47
I wonder if thats possible. Here is the error I get. Not all the flags I use, but just to give you an idea.

C:\x264>x264 input.avi --profile high10 --vf crop:1,0,0,0 -o cropped.mp4
ffms [info]: 523x361p 0:1 @ 24/1 fps (vfr)
resize [error]: resolution 523x361 is not compliant with colorspace i420

Secondly, here is a link which says its not possible to crop 1 pixel.

http://mewiki.project357.com/wiki/X264_Settings#crop

Can you share your code please?

J_Darnley
9th August 2010, 12:59
That link is correct for the most common colourspace but wrong in general.

All the x264 source code is available. I just made a test video using avisynth

vineet
9th August 2010, 13:00
That shouldn't be the case; if the video is in a colorspace that allows non-mod2 resolutions, the crop filter should be able to crop it. If it isn't in a colorspace that allows non-mod2 resolutions, it can't possibly be non-mod2.

Sounds like a bug in the crop filter.

Say that the video is in a non-mod2 colorspace, so is it possible to bring it to a mod2 colorspace during a single pass encode. I just posted the error I get, says smthn bout colorspace i420.

kemuri-_9
9th August 2010, 13:01
that error is not even related to crop.


the problem is related to your input colorspace, you obviously some colorspace that is unrecognized by the rest of the filtering system and so it is choosing to convert it to the default i420 one.
but input source has non mod2 widths and this is incompatible with i420, so the error occurs.


but anyways crop works as intended:

$ ./x264 -o NUL ../foreman_cif_352x288.yuv --vf crop:1,0,1,0
yuv [info]: 352x288p 0:0 @ 25/1 fps (cfr)
crop [error]: left crop value `1' is not a multiple of 2

$ ./x264 -o NUL ../foreman_cif_352x288.yuv --vf resize:csp=bgr/crop:1,0,1,0/resize:csp=i420
yuv [info]: 352x288p 0:0 @ 25/1 fps (cfr)
resize [warning]: converting from yuv420p to bgr24
crop [info]: cropping to 350x288
resize [warning]: converting from bgr24 to yuv420p
....
encoded 300 frames, 150.00 fps, 426.35 kb/s

vineet
9th August 2010, 13:04
That link is correct for the most common colourspace but wrong in general.

All the x264 source code is available. I just made a test video using avisynth

So, is it possible to get over this error only by using AviSynth. I dont really use it currently, can you share your avs script please?

vineet
9th August 2010, 13:38
that error is not even related to crop.


the problem is related to your input colorspace, you obviously some colorspace that is unrecognized by the rest of the filtering system and so it is choosing to convert it to the default i420 one.
but input source has non mod2 widths and this is incompatible with i420, so the error occurs.


but anyways crop works as intended:

$ ./x264 -o NUL ../foreman_cif_352x288.yuv --vf crop:1,0,1,0
yuv [info]: 352x288p 0:0 @ 25/1 fps (cfr)
crop [error]: left crop value `1' is not a multiple of 2

$ ./x264 -o NUL ../foreman_cif_352x288.yuv --vf resize:csp=bgr/crop:1,0,1,0/resize:csp=i420
yuv [info]: 352x288p 0:0 @ 25/1 fps (cfr)
resize [warning]: converting from yuv420p to bgr24
crop [info]: cropping to 350x288
resize [warning]: converting from bgr24 to yuv420p
....
encoded 300 frames, 150.00 fps, 426.35 kb/s


Ok, The videos are from a playblast of 3D software, Maya. Is there a way I could change the colorspace to non-mod2 and then encode my video in that colorspace.

Guest
9th August 2010, 13:42
Can you post a link to a sample unprocessed input file that shows the problem?

kemuri-_9
10th August 2010, 03:17
It looks like you're on a windows system so I've made a patch and applied it to a win32 build here (http://kemuri9.net/dev/x264/experimental/x264.zip)

it should now try and convert your unknown input colorspace source to i444 which will allow the non mod2 dimensions you require.
this should get you past your current issue and allow you to crop your source to mod2 dimensions to become i420 compliant for encoding with libx264.

If it works, I'll get it added to Dark_Shikari's local commit tree

vineet
10th August 2010, 08:09
It looks like you're on a windows system so I've made a patch and applied it to a win32 build here (http://kemuri9.net/dev/x264/experimental/x264.zip)

it should now try and convert your unknown input colorspace source to i444 which will allow the non mod2 dimensions you require.
this should get you past your current issue and allow you to crop your source to mod2 dimensions to become i420 compliant for encoding with libx264.

If it works, I'll get it added to Dark_Shikari's local commit tree

It worked dude, thanks a lot.

It would be even better if x264 could directly adjust the colorspace during encode, as it does when crop filter is applied and publish non mod2 resolution, if its compatible with colorspace or automatically crop one pixel if its not. Thanks again for this.

kemuri-_9
10th August 2010, 12:35
It would be even better if x264 could directly adjust the colorspace during encode, as it does when crop filter is applied and publish non mod2 resolution, if its compatible with colorspace or automatically crop one pixel if its not. Thanks again for this.

huh?
the crop filter does not adjust the colorspace at all, it just crops pixels based on the current colorspace,
you use the resize filter to change colorspaces, which is what x264cli is using to do such things.

i'm not too thrilled about "automatic cropping", as we don't particularly know which pixels would be the "best" to crop for every source out there.
though I will probably have a discussion with Dark_Shikari about this eventually and see what his opinions are.
unless he just answers back here...