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 14th August 2011, 08:30   #1  |  Link
gwdkwd
Registered User
 
Join Date: Aug 2011
Posts: 3
Fraps, x264, YV12, avisynth, and youtube

Hello.
I would like to convert my fraps videos to x264 without any colorspace conversion.

I hear that fraps does indeed record in yv12, but that it's decoder itself does not decode in yv12, thus forcing a colorspace conversion when converting to x264. So the colors end up worse.

Is there a way around this? I want to upload my fraps videos to youtube while sacrificing the least possible color quality.

I have looked around for solutions, but none of them have worked so far. Take this one, for example:

LoadPlugin("ffms2.dll")
LoadPlugin("ColorMatrix.dll")
FFVideoSource("FRAPS capture.avi", cache=false)
ColorMatrix(inputFR=true)

I have tried using this avisynth script, and the video does not open and I get the following error:
"Avisynth open failure:
ColorMatrix: input to filter must be YV12 or YUV2!"

I have both plugins installed (that is, put into the avisynth plugin folder) and have tried the script with fraps videos that were recorded with "force lossless RBG capture" ticked both on and off.

If it's relevant to any of this, I have ffdshow installed.

Thank you for any help you can provide.
gwdkwd is offline   Reply With Quote
Old 14th August 2011, 23:59   #2  |  Link
mariush
Registered User
 
Join Date: Dec 2008
Posts: 589
You can configure fraps to encode in RGB24 , then use x264 to encode to YUV 4:4:4 which should be almost lossless. However, Youtube will re-encode your video to YV12, 4:2:0 I'm not sure Flash and video cards support hardware decoding of YV 4:4:4 so probably all popular websites will convert to YV12 anyway... unless you host the video yourself it's probably not going to do you any good.

Have you tried using the plain old AVISource ? As the coded is Video For Windows, it should work...
mariush is offline   Reply With Quote
Old 15th August 2011, 09:36   #3  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,988
I'd bring it down into yv12 inside avisynth. Since it has to go to yv12 eventually, you might as well do it at a stage where you have control over the process.

Code:
FFVideoSource("foo.avi") #Assuming this returns RGB24 or RGB32

ConvertToYV12(matrix="rec709") #Assuming you want to make an HD output? Use matrix="rec601" otherwise.
Derek
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline   Reply With Quote
Old 17th August 2011, 00:01   #4  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
If ColorMatrix is giving you an error, you're probably recording in lossless mode (which is true RGB24). Untick that box and you'll get YV12. Use Info() to see what the video is currently.

Using the YV12 directly is a little problematic -- FRAPS uses custom YUV coefficients, so ColorMatrix won't be able to fix your colors to what Youtube expects (TV-range Rec.601 -- even for HD). Also, FRAPS YV12 is TV range, not full range.
__________________
Lanczos4, Spline36, what!? Don't know how to pick a resizer? Take a look at my kernel visualizations.
Want a high-quality, gamma-aware resizer? Check out my ResampleHQ filter.
PhrostByte is offline   Reply With Quote
Old 17th August 2011, 11:47   #5  |  Link
gwdkwd
Registered User
 
Join Date: Aug 2011
Posts: 3
Quote:
You can configure fraps to encode in RGB24 , then use x264 to encode to YUV 4:4:4 which should be almost lossless. However, Youtube will re-encode your video to YV12, 4:2:0 I'm not sure Flash and video cards support hardware decoding of YV 4:4:4 so probably all popular websites will convert to YV12 anyway... unless you host the video yourself it's probably not going to do you any good.

Have you tried using the plain old AVISource ? As the coded is Video For Windows, it should work...
Quote:
I'd bring it down into yv12 inside avisynth. Since it has to go to yv12 eventually, you might as well do it at a stage where you have control over the process.
Thanks for the info, that will help. Although specifically, I want to retrieve the yv12 data from the fraps video, so I can avoid the color shift as much as I can, when encoding with x264.

Quote:
If ColorMatrix is giving you an error, you're probably recording in lossless mode (which is true RGB24). Untick that box and you'll get YV12. Use Info() to see what the video is currently.
Info is telling me that the colorspace is in RGB32. I am certain that I'm not recording in lossless mode.

Quote:
Using the YV12 directly is a little problematic -- FRAPS uses custom YUV coefficients, so ColorMatrix won't be able to fix your colors to what Youtube expects (TV-range Rec.601 -- even for HD). Also, FRAPS YV12 is TV range, not full range.
So, is there any use to using the fraps yv12 data for youtube uploads, then?
gwdkwd is offline   Reply With Quote
Old 17th August 2011, 23:24   #6  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
What version of FFMS2 are you using? Current FFmpeg versions have a broken version of a function used to determine the "best" (least lossy) colorspace to convert to, and the Fraps decoder uses the somewhat unusual and deprecated pixel format YUVJ420P (which in Avisynth terms translates to fullrange I420), so it's entirely possible that something goes wrong during the output format decision and FFMS2 decides to output RGB instead. Very recent FFMS2 beta builds have a workaround for this bug, so try that if you haven't already.
TheFluff is offline   Reply With Quote
Old 25th August 2011, 00:47   #7  |  Link
gwdkwd
Registered User
 
Join Date: Aug 2011
Posts: 3
Thanks. I downloaded the latest version and it's telling me the colorspace is yv12 now. Where do I go from there?
gwdkwd is offline   Reply With Quote
Old 25th August 2011, 01:33   #8  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
I recommend using AviSource to let FRAPS give you RGB. It's the only way to get correct colors.
__________________
Lanczos4, Spline36, what!? Don't know how to pick a resizer? Take a look at my kernel visualizations.
Want a high-quality, gamma-aware resizer? Check out my ResampleHQ filter.
PhrostByte is offline   Reply With Quote
Old 26th August 2011, 12:30   #9  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by PhrostByte View Post
I recommend using AviSource to let FRAPS give you RGB. It's the only way to get correct colors.
A pointless conversion to RGB and back was exactly what he wanted to avoid in the first place. Also, FFmpeg's fraps decoder explicitly sets its output as fullrange, so I'm not sure where you got the idea that fraps in YV12 is always TV range. Maybe the VFW decoer converts to that?

Last edited by TheFluff; 26th August 2011 at 12:43.
TheFluff is offline   Reply With Quote
Old 26th August 2011, 18:53   #10  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
Quote:
Originally Posted by TheFluff View Post
A pointless conversion to RGB and back was exactly what he wanted to avoid in the first place. Also, FFmpeg's fraps decoder explicitly sets its output as fullrange, so I'm not sure where you got the idea that fraps in YV12 is always TV range. Maybe the VFW decoer converts to that?
The problem is that ColorMatrix will not be able to correct your colors to the TV-range Rec.601 that YouTube expects.

FFmpeg's output is using none of the usual YUV coefficients. I don't know if this is a FFmpeg bug or if FRAPS itself just uses something weird.
__________________
Lanczos4, Spline36, what!? Don't know how to pick a resizer? Take a look at my kernel visualizations.
Want a high-quality, gamma-aware resizer? Check out my ResampleHQ filter.
PhrostByte is offline   Reply With Quote
Old 26th August 2011, 20:07   #11  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
Hmm, i am very interested in this aswell, as i am also trying to prevent the stupid YV12->RGB32->YV12 Conversion:S
I have tried Directshowsource, but it´s the same thing, it decodes as TV Range (i think) when it should be PC Range (or if it´s vice versa).
zerowalker is offline   Reply With Quote
Old 26th August 2011, 22:39   #12  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by PhrostByte View Post
The problem is that ColorMatrix will not be able to correct your colors to the TV-range Rec.601 that YouTube expects.

FFmpeg's output is using none of the usual YUV coefficients. I don't know if this is a FFmpeg bug or if FRAPS itself just uses something weird.
FFmpeg does nothing re: the actual sample values. AFAICT the entire FRAPS decoder is basically just a Huffman decoder with a few funny twists on it, so whatever values FRAPS put in there should get back out in the same state. How do you know it's not using the usual coefficients, though?
TheFluff is offline   Reply With Quote
Old 28th August 2011, 17:34   #13  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
Quote:
Originally Posted by TheFluff View Post
How do you know it's not using the usual coefficients, though?
Compare an RGB capture and a YV12 capture. Decode the YV12 twice—once with AviSource() using FRAPS1, and once with FFVideoSource().ConvertToRGB().

Play with the matrix all you like in ConvertToRGB()—you won't be able to match the colors. The closest I've come is with TV-range Rec.709.
__________________
Lanczos4, Spline36, what!? Don't know how to pick a resizer? Take a look at my kernel visualizations.
Want a high-quality, gamma-aware resizer? Check out my ResampleHQ filter.
PhrostByte is offline   Reply With Quote
Old 28th August 2011, 23:02   #14  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by PhrostByte View Post
Compare an RGB capture and a YV12 capture. Decode the YV12 twice—once with AviSource() using FRAPS1, and once with FFVideoSource().ConvertToRGB().

Play with the matrix all you like in ConvertToRGB()—you won't be able to match the colors. The closest I've come is with TV-range Rec.709.
A qualified guess says it's sRGB, but I don't know how to prove that theory.
TheFluff is offline   Reply With Quote
Old 29th August 2011, 01:15   #15  |  Link
PhrostByte
Grand Fruitioner
 
PhrostByte's Avatar
 
Join Date: Mar 2004
Location: Chicago, IL
Posts: 115
Quote:
Originally Posted by TheFluff View Post
A qualified guess says it's sRGB, but I don't know how to prove that theory.
sRGB mapped to YV12? I don't think so.
__________________
Lanczos4, Spline36, what!? Don't know how to pick a resizer? Take a look at my kernel visualizations.
Want a high-quality, gamma-aware resizer? Check out my ResampleHQ filter.
PhrostByte is offline   Reply With Quote
Old 12th November 2011, 17:25   #16  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
So there is still no solution for this;O?
zerowalker is offline   Reply With Quote
Old 14th November 2011, 21:08   #17  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
You use RGB with fraps and convert to TV-range Rec.601 YV12 in avisynth (for upload to Youtube). The extra color space conversion, if there is one, is much preferred to using incorrect coefficients.
Asmodian is offline   Reply With Quote
Old 15th November 2011, 18:19   #18  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,121
ehm, i convert to rec.709, it makes the right colors i think, but i guess you mean that youtube will change it into Rec.601 not matter what;D?
zerowalker is offline   Reply With Quote
Old 15th November 2011, 21:57   #19  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
If your resolution is >=720p and you are not uploading to youtube use rec.709. <720p or uploading to youtube use Rec.601. This is from what I have read about youtube here, not my personal experiance with youtube.
Asmodian is offline   Reply With Quote
Old 16th November 2011, 00:55   #20  |  Link
naoan
Registered User
 
Join Date: Oct 2009
Posts: 151
Strangely I found Rec601 to be the closest to the fraps RGB than any other matrix, even for >720p (though I haven't tried capturing <720p)

Here's comparison, using converttoyv12, matrix :

RGB http://i.minus.com/iVwzNF5ComoHr.png

Rec601 http://i.minus.com/ibmq7Nip0uyYl7.png

PC.601 http://i.minus.com/iuDNl3aVtHqiM.png

Rec709 http://i.minus.com/ipoQYVmGYqiF2.png

PC.709 http://i.minus.com/icwukCAqr1wJo.png

I also have to add --colormatrix bt470bg --fullrange off parameter on x264 or else madvr will treat it as fullrange BT.709 and shows it wrong.
naoan is offline   Reply With Quote
Reply

Tags
avisynth, decoder, fraps, x264, yv12

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 14:15.


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