Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th August 2010, 07:42   #1  |  Link
vineet
Registered User
 
Join Date: Jul 2010
Posts: 9
X264 color space problem

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.
vineet is offline   Reply With Quote
Old 9th August 2010, 08:21   #2  |  Link
nurbs
Registered User
 
Join Date: Dec 2005
Posts: 1,460
Quote:
Originally Posted by vineet View Post
1223*1042
x264 uses YV12 colorspace so you need even resolutions. Mod2 will do IIRC.
nurbs is offline   Reply With Quote
Old 9th August 2010, 08:52   #3  |  Link
vineet
Registered User
 
Join Date: Jul 2010
Posts: 9
Quote:
Originally Posted by nurbs View Post
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.


Quote:
Originally Posted by nurbs View Post
Mod2 will do IIRC
I have no idea what that means, am not an expert. Could you please give a little detail on that.
vineet is offline   Reply With Quote
Old 9th August 2010, 10:16   #4  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
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.
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.
J_Darnley is offline   Reply With Quote
Old 9th August 2010, 11:12   #5  |  Link
vineet
Registered User
 
Join Date: Jul 2010
Posts: 9
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??
vineet is offline   Reply With Quote
Old 9th August 2010, 11:22   #6  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by vineet View Post
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.
Dark Shikari is offline   Reply With Quote
Old 9th August 2010, 11:24   #7  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
Quote:
Originally Posted by vineet View Post
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.
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.

Last edited by J_Darnley; 9th August 2010 at 11:34.
J_Darnley is offline   Reply With Quote
Old 9th August 2010, 12:47   #8  |  Link
vineet
Registered User
 
Join Date: Jul 2010
Posts: 9
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?
vineet is offline   Reply With Quote
Old 9th August 2010, 12:59   #9  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
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
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.
J_Darnley is offline   Reply With Quote
Old 9th August 2010, 13:00   #10  |  Link
vineet
Registered User
 
Join Date: Jul 2010
Posts: 9
Quote:
Originally Posted by Dark Shikari View Post
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.
vineet is offline   Reply With Quote
Old 9th August 2010, 13:01   #11  |  Link
kemuri-_9
Compiling Encoder
 
kemuri-_9's Avatar
 
Join Date: Jan 2007
Posts: 1,348
that error is not even related to crop.

[Edit]
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.
[/Edit]

but anyways crop works as intended:
Code:
$ ./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
__________________
custom x264 builds & patches | F@H | My Specs

Last edited by kemuri-_9; 9th August 2010 at 13:07.
kemuri-_9 is offline   Reply With Quote
Old 9th August 2010, 13:04   #12  |  Link
vineet
Registered User
 
Join Date: Jul 2010
Posts: 9
Quote:
Originally Posted by J_Darnley View Post
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 is offline   Reply With Quote
Old 9th August 2010, 13:38   #13  |  Link
vineet
Registered User
 
Join Date: Jul 2010
Posts: 9
Quote:
Originally Posted by kemuri-_9 View Post
that error is not even related to crop.

[Edit]
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.
[/Edit]

but anyways crop works as intended:
Code:
$ ./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.
vineet is offline   Reply With Quote
Old 9th August 2010, 13:42   #14  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Can you post a link to a sample unprocessed input file that shows the problem?
Guest is offline   Reply With Quote
Old 10th August 2010, 03:17   #15  |  Link
kemuri-_9
Compiling Encoder
 
kemuri-_9's Avatar
 
Join Date: Jan 2007
Posts: 1,348
It looks like you're on a windows system so I've made a patch and applied it to a win32 build here

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
__________________
custom x264 builds & patches | F@H | My Specs

Last edited by kemuri-_9; 10th August 2010 at 03:19.
kemuri-_9 is offline   Reply With Quote
Old 10th August 2010, 08:09   #16  |  Link
vineet
Registered User
 
Join Date: Jul 2010
Posts: 9
Quote:
Originally Posted by kemuri-_9 View Post
It looks like you're on a windows system so I've made a patch and applied it to a win32 build here

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.

Last edited by vineet; 10th August 2010 at 09:42.
vineet is offline   Reply With Quote
Old 10th August 2010, 12:35   #17  |  Link
kemuri-_9
Compiling Encoder
 
kemuri-_9's Avatar
 
Join Date: Jan 2007
Posts: 1,348
Quote:
Originally Posted by vineet View Post
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...
__________________
custom x264 builds & patches | F@H | My Specs
kemuri-_9 is offline   Reply With Quote
Reply

Tags
colorspace, resizing, resolution, x264

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:39.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.