View Full Version : Setting Colormatrix info with x264 for Flash Player
jmartinr
21st May 2011, 22:33
I rotate a lot of SD videos, resulting in a vertical size of 704 pixels. I publish them on a web site with flash. I recently began to realize that this might trip HD-SD colormatrix problems. Indeed, colors looked fishy on my site.
After reading http://forum.doom9.org/showthread.php?t=131717&highlight=bt470bg and http://forum.doom9.org/showthread.php?t=157299&highlight=bt470bg it was clear that the interpretation of the Video Usability Information (VUI) was dependant on the player.
So I did a test encode with --colorprim bt470bg --transfer bt470bg --colormatrix bt470bg (source was PAL-DV) and put it on my side next to an old one. I use JW Player for the Flash video.
The good news is flash respects the info, and the new encode definitely looks better than the old one. You can check it on http://www.roelofs-coaching.nl/matrix-test. You can open the old and the new video and put them next to each other. The bt470bg-one has a deeper red which you can see quite well on the left-hand bottom corner.
yetanotherid
22nd May 2011, 03:52
That's interesting. I've been discussing the subject of colors in another thread so I looked at your video.
What I'm confused about, is why the two videos look different to you when to me they look exactly the same. I opened them both in my browser (Firefox) and downloaded them to my hard drive and opened them with both MPC-HC and VLC and both videos still displayed using the same colors in both players. I'm running XP.
The way I understand it, all SD video will display on a PC using Rec.601 (bt470) so even without the usability information (which I understand is generally ignored when playing video on a PC) both those videos should display using the same colors.... which for me they do. If my understanding is correct then for some reason the video without the usability info must be displaying using different colors for you (R.709?) but it appears not to be for me.
If the source is R.709, then my adding bt470 to the usability info when you convert to SD (and assuming the player obeys it) unless you actually convert the colors while encoding aren't you effectively telling the player to use the wrong colors when playing the encode? Which video displays for you using the same colors as the source?
If the original video was actually bt470 (do you know for sure which color method it uses?) then no color conversion should be required when converting to SD, and as SD video displays on a PC using bt470 anyway, the colors should still be correct without the usability info. With or without it both videos display using the same colors for me.
Assuming your source is R.709 and you added R.709 usability to the encode (not bt470), you didn't convert the colors when encoding and the player respects the usability info (which generally I doubt it will) then in that case the SD encode should display using the same colors as the source.
What's the resolution of the original video? I've not yet been able to work out exactly when a PC decides to switch from bt470 to R.709 (it's not at exactly 720 vertical lines as the general consensus seems to be) but if you're comparing the encode to the source using a PC you mightn't be able to rely on the PC displaying the source video using the correct colors in the first place. For HD video with a width of 1280, the switching point seems to be around 674 vertical lines. For videos of different widths I'm sure that changes. In your case I assume the source is SD so it should display using R.601 on a PC but maybe PCs do respect the color information in mpeg2 streams rather than ignore it as they seem to for h264 video. I've not been able to test that.
I know you referred to flash video and I don't really know anything about what it does or doesn't do, or if it's any different to other types of video containers when it comes to respecting the correct colors when playing on a PC, but I downloaded your videos using two different video download utilities and each time they downloaded as an MP4.
From the messing around with this I've done myself I think it's better to convert the colors when encoding if need be rather than rely on the usability info to correct them on playback. Generally HD is R.709 (although which colors a video camera might use I have no idea) and SD is bt470 (R.601), so generally converting from R.709 to R.601 on the way through should ensure the correct colors on playback. I guess though your original video could be either.
For the record, I encoded a few DVDs using the wrong preset a while back and R.709 color usability info was added to the encode. I also converted those DVDs to XviD/AVI which would display using R.601. Each encode displays using exactly the same colors on my PC so the incorrect usability info is obviously being ignored when playing the x264 encodes. I've kept those encodes for testing and the day I might discover a way to play them on a PC while respecting the incorrect usability info. So far I've not had any luck.
PS Which program do you use for converting? If you're going from HD to SD and the HD source is R.709 (or from SD to SD and the source is R.709) then depending on the program being used it might be easy to convert the colors from R.709 to R.601 while encoding.
yetanotherid
22nd May 2011, 04:17
Just to make sure I know exactly how the video is being displayed on my PC.....
I opened one of the MP4s I downloaded (the one without the usability info) using MPC-HC. I then converted it to XviD while reducing the resolution from 528x704 to 480x640. I'm completely confident the XviD encode will display using bt470 (R.601). Once again, it displays using exactly the same colors as the originals I downloaded from your site so I'm sure for me they both display using bt470. In each case the red sign in the bottom corner looks fairly red. If I add R.709 to Rec.601 color conversion on the way through the red sign starts to look fairly orange. As does the red sleeve on someone's t-shirt. If I convert the other way (R.601 to R.709) skin tones start to look a bit to reddish to me. I suspect R.601 is the correct color for your video.
It'll be interesting to see if anyone else downloads your videos and if they see a color difference between the two.
Chikuzen
22nd May 2011, 06:33
FlashPlayer not always respects info.
http://doom10.org/index.php?topic=1564.msg7601#msg7601
jmartinr
22nd May 2011, 08:51
@Chikuzen
Thanks for the very usefull info. FlashPlayer10.2 with HW acceleration always convert YUV to RGB via BT.601.
But FlashPlayer10.2 without HW acceleration convert YUV to RGB via specified matrix.
(And if you don't specify colormatrix, FP10.2 without HW always convert YUV to RGB via BT.709.
This behavior is the same as FP10.0 and 10.1) I need BT.601, so with a specified colormatrix (bt470) that's what i'll always get with Flash Player :)
@yetanotherid
It's about how Flash Player handles the colors, so you have to look at the videos through the website. I'm not surprised other players do it right. If you look at the videos embedded with a HTML-tag in Safari (if you disable Flash Player that's what you get on my site), then both video's look good. And yes, I'm sure they're BT.601. Source is PAL-DV, filtered through avisynth and encoded with x264.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.