View Full Version : Fraps, x264, YV12, avisynth, and youtube
gwdkwd
14th August 2011, 08:30
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.
mariush
14th August 2011, 23:59
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...
Blue_MiSfit
15th August 2011, 09:36
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.
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
PhrostByte
17th August 2011, 00:01
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.
gwdkwd
17th August 2011, 11:47
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...
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.
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.
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?
TheFluff
17th August 2011, 23:24
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.
gwdkwd
25th August 2011, 00:47
Thanks. I downloaded the latest version and it's telling me the colorspace is yv12 now. Where do I go from there?
PhrostByte
25th August 2011, 01:33
I recommend using AviSource to let FRAPS give you RGB. It's the only way to get correct colors.
TheFluff
26th August 2011, 12:30
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?
PhrostByte
26th August 2011, 18:53
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.
zerowalker
26th August 2011, 20:07
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).
TheFluff
26th August 2011, 22:39
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?
PhrostByte
28th August 2011, 17:34
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.
TheFluff
28th August 2011, 23:02
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.
PhrostByte
29th August 2011, 01:15
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.
zerowalker
12th November 2011, 17:25
So there is still no solution for this;O?
Asmodian
14th November 2011, 21:08
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.
zerowalker
15th November 2011, 18:19
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?
Asmodian
15th November 2011, 21:57
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.
naoan
16th November 2011, 00:55
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.
Kein
3rd March 2015, 14:15
Relevant question - unable to open FRAPS video YV12 (yuvj420p FR) with ffms2, it just loads the audio:
FFVideoSource("fraps.avi")
FFAudioSource("fraps.avi")
Info()
sneaker_ger
3rd March 2015, 14:19
a=FFAudioSource("fraps.avi")
v=FFVideoSource("fraps.avi")
AudioDub(v, a)
Kein
3rd March 2015, 14:37
Still can't open the video, only audio. This is weird, i open it just fine with ffmpeg plugin in Vdub.
UPD: nvm, got it working in Vdub by reinstalling latest version of ffms2 (ws on 2.18). That being said, MPHC play video even with Haali selected.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.