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. |
10th February 2012, 21:32 | #41 | Link |
Registered User
Join Date: Nov 2005
Posts: 693
|
Fraps' decoders? Plural??
Huh?! What are you talking about? Perhaps I don't understand correctly, but with Fraps' normal recording method, it creates Fraps-file in YV12 (yuvj420p to be precise) and with AVISource() in Avisynth, or by opening the FPS1(yuvj420p)-file directly with VirtualDub, Fraps' own decoder is used.
__________________
My hobby website |
10th February 2012, 23:36 | #42 | Link | |
Registered User
Join Date: Dec 2011
Posts: 1,812
|
Quote:
Somehow the results of simply open the file in VD and open it in VD via AVS script differed in the past. But now it has worked. I can't say what went wrong. Will try feeding x264 with a proper script in which the official FRAPS decoder is used... |
|
10th February 2012, 23:55 | #43 | Link |
Registered User
Join Date: Nov 2005
Posts: 693
|
For your FPS1(bgra) videos that wouldn't be a problem, but I think we can all agree now, after the whole discussion in this thread, for FPS1(yuvj420p) the use of FFmpegSource is much more preferable than AVISource (Fraps' own decoder through VFW)!
__________________
My hobby website |
11th February 2012, 00:01 | #44 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
Is the colorspace conversion worse , or is banding from levels conversion worse? ffms2 outputs full range Y'CbCr - if you scale to "legal" range you will get quantization (look at the histogram, and in shadows) (or if you use smoothlevels instead of levels, it will smoothen out, but then at the expense of more dithering noise - that's why the bitrate required is higher) |
|
11th February 2012, 00:52 | #45 | Link |
Registered User
Join Date: Nov 2005
Posts: 693
|
You're right, I should've said: FFmpegSource for quality, AVISource for speed.
I noticed it too, the higher required bitrate with SmoothLevels, but I can perfectly live without it, especially because it's very slow. Although MediaWiki says "this is the same as ColorYUV(levels="PC->TV")", I noticed when I compared level histograms for Levels(0, 1, 255, 16, 235, coring=false) ColorMatrix(mode="rec.709->rec.601", clamp=0) and ColorYUV(levels="PC->TV") ColorMatrix(mode="rec.709->rec.601", clamp=0) I noticed there's still a slight difference. Because I'm not all that into this technical colour stuff, which one would you prefer? Since you're the one who suggested to use SmoothLevels and ColorMatrix in a thread I linked to on the previous page, would you mind answering the couple of questions (at the end of the post) I have about these filters?
__________________
My hobby website |
11th February 2012, 01:10 | #46 | Link | |||
Registered User
Join Date: Sep 2007
Posts: 5,377
|
Quote:
Quote:
Quote:
|
|||
11th February 2012, 01:15 | #47 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Levels() on a YUV clip scales chroma by the same ratio as luma, so the call above does not map chroma [0, 255] exactly to [16, 240], but ColorYUV(levels="PC->TV") does. |
|
11th February 2012, 14:30 | #48 | Link | |
Registered User
Join Date: Nov 2005
Posts: 693
|
Thanks you two!
Quote:
ColorYUV(levels="PC->TV") ColorMatrix("rec.709->rec.601", clamp=0) vs. ColorYUV(levels="PC->TV") ColorMatrix("rec.709->rec.601") P.s. I noticed something weird in AvsP: When I tried to compare 'clamp=0' vs. no clamp-entry with SmoothLevels() on 2 different tabs, refreshing the preview of either tab constantly shows a slightly different levels histogram. Removing one of the tabs with the SmoothLevels() entry, and the levels histogram becomes static again upon refreshing. To reproduce, just open 2 tabs, copy-paste the exact same script with SmoothLevels() there and F5 the preview. Just thought I'd mention.
__________________
My hobby website |
|
11th February 2012, 15:09 | #49 | Link |
Registered User
Join Date: Nov 2005
Posts: 693
|
For anyone interested, I did some speed tests with AVSMeter:
Code:
AVSMeter v1.17 by Groucho2004 AviSynth 2.60, build:May 25 2011 [19:58:41] Number of frames: 375 Length (h:m:s.ms): 00:00:15.000 Frame width: 640 Frame height: 480 Framerate: 25.000 (25/1) Progressive: Yes Colorspace: RGB32* / YV12** AVISource (Fraps's own decoder) - fps (avg): 79.24 * FFMpegSource2 ConvertToRGB("PC.709") - fps (avg): 55.02 * FFMpegSource2 Levels(0, 1, 255, 16, 235, coring=false) ColorMatrix("rec.709->rec.601", clamp=0) - fps (avg): 90.08 ** FFMpegSource2 ColorYUV(levels="PC->TV") ColorMatrix("rec.709->rec.601", clamp=0) - fps (avg): 97.10 ** FFMpegSource2 SmoothLevels(preset="pc2tv", chroma=100) ColorMatrix("rec.709->rec.601", clamp=0) - fps (avg): 4.96 **
__________________
My hobby website |
12th February 2012, 22:24 | #50 | Link |
Registered User
Join Date: Nov 2005
Posts: 693
|
Although it's great to know now that with Avisynth the colour-issue can be fixed, I'd like to get back at my original post; trying to do the same thing directly with x264.exe or ffmpeg.exe, without the help of Avisynth. I've done quite some testing with ffmpeg and x264 and these are my findings.
For ffmpeg I used the following command-line: Code:
ffmpeg.exe -i "<path>\FPS1(yuvj420p)_sample.avi" -pix_fmt yuv420p -color_primaries 5 -color_trc 5 -colorspace 5 -an -vcodec libx264 -qp 28 -x264opts force-cfr "<path>\FPS1(yuvj420p)_sample(ffmpeg).mkv" Code:
x264.exe -q 28 --range tv --colorprim bt470bg --transfer bt470bg --colormatrix bt470bg --input-range pc --force-cfr --acodec none -o "<path>\FPS1(yuvj420p)_sample(x264_ffms).mkv" "<path>\FPS1(yuvj420p)_sample.avi" _________ffmpeg____________________x264 - First of all; despite the new FFmpegSource 2.17 being incorporated in the rev2164 JEEB build of x264.exe I used, I'm still being shown ffms [info]: color matrix: undef. Seems detecting color-matrices in Fraps files is for FFMS a bit more difficult than for other formats. - Both encoders here produce the same file. For the range conversion -pix_fmt yuv420p and --range tv --input-range pc seem to do the same thing. Strange it's not possible to enter --output-csp yuv420p for x264. (--input-csp yuvj420p --output-csp i420 doesn't work. Neither does --vf resize:csp=i420) P.s. I've read several times on the internet, including PhrostByte's post, about this so-called command --fullrange on/off command. Could this command perhaps be replaced by --range tv --input-range pc, because x264 returns an error. - Both encoders here produce the same file, except that only the file produced by x264 actually has the "Color primaries", "Transfer characteristics" and "Matrix coefficients" entries in it. Back in dec 2010 these parameters didn't even appear to be working for ffmpeg. But in the end it doesn't matter, because neither MPC-HC, nor FFmpegSource (in Avisynth) seem to respect these entries. Apart from these colorimetric settings, I haven't found any commands that do the luma conversion directly, in either ffmpeg or x264. So to summarize: PC->TV no problem with ffmpeg and x264, but for BT.709->BT.601 you really need Avisynth (at the moment).
__________________
My hobby website Last edited by Reino; 20th August 2014 at 10:45. Reason: cosmetics |
13th February 2012, 00:53 | #51 | Link | |
VR, 3D & HDR UHD fan
Join Date: Mar 2006
Location: Sofia, Bulgaria
Posts: 53
|
Quote:
|
|
13th February 2012, 02:13 | #52 | Link | |
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
Quote:
Code:
subtitle(string(FFCOLOR_SPACE)) In both of your example cases you explicitly flag the output with metadata indicating it as bt470bg, but the input is known to be bt709. In neither case do you instruct swscale to actually do any color matrix conversions (AFAIK you have to do this by hand, neither application will do it automatically; JEEB's patched x264 might, but only if the source colorimetry is definitely known (i.e. not undef)). To my knowledge, neither ffmpeg nor x264 expose any settings that will let you manually override the input/output colorimetry, so your conclusion is essentially correct. FFMS2 will respect colorimetry metadata and tell swscale about it as appropriate, but that only affects processing if you tell it to output a non-default colorspace or resolution, since it'll try to avoid rescaling the image if possible. In the Fraps case the input is YV12, which can be output directly to both Avisynth and x264, so no rescaling will take place (x264 will not use FFMS2 for rescaling anyway though; it uses swscale directly). |
|
13th February 2012, 12:50 | #53 | Link |
Registered User
Join Date: Nov 2005
Posts: 693
|
@ Zerofool: Ah, ok thanks! Didn't know the repository was on the videolan website. Google didn't return any useful results at least.
@ TheFluff: Since Fraps has no colormatrix metadata as you mentioned, I take it the value returned by FFCOLOR_SPACE (value 2, which if I'm correct corresponds with ColorMatrix()'s source=2 (Rec.601) parameter) is just as unreliable as ffms in x264, because the Fraps file is BT.709 afterall. But interesting nonetheless, because while reading the FFmpegSource wiki I was already wondering how to utilize these variables. Thanks. I'm still pretty new to this. The input is indeed BT.709, but I've read bt470bg corresponds with BT.601 (which is the desired output of course), or isn't it? So that why I used these 3 color parameters. These aren't part of swscale? As I've mentioned already, I haven't found any other parameters/commands to do luma conversions, so when you say "In neither case do you instruct swscale to actually do any color matrix conversions", I'm beginning to wonder if I've overlooked something . [edit]1 more Avisynth question: To match colors as closely as possible, which one would be preferred? Code:
ColorYUV(levels="PC->TV") ColorMatrix(dest=2, clamp=0) or ColorMatrix(dest=2, clamp=0, inputFR=true)
__________________
My hobby website Last edited by Reino; 13th February 2012 at 13:14. |
13th February 2012, 18:08 | #54 | Link | |||
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
Quote:
Quote:
Quote:
Last edited by TheFluff; 13th February 2012 at 18:28. |
|||
13th February 2012, 18:46 | #55 | Link |
Registered User
Join Date: Nov 2005
Posts: 693
|
"Matches the values used by ColorMatrix() as input." on the Avisynth mediawiki is quite confusing then.
I know these only add metadata, but it seems atm these parameters are the only ones available that have anything to do with luma conversion. Are you saying; swscale is capable to do a direct BT.709->BT.601 conversion, but x264 hasn't correctly incorporated it yet and thus can't provide proper parameters for it? P.s. Funny then. Although categorized as a "Video Usability Info"-parameter, --range should in fact be an "Input/Output"-parameter, because it directly influences the video instead of only adding metadata.
__________________
My hobby website |
13th February 2012, 19:18 | #56 | Link | ||
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
Quote:
Quote:
Are you sure it really does that? |
||
13th February 2012, 19:41 | #57 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,377
|
The FFMBC branch has a colormatrix filter . I think it's actually from avisynth, as vf_colormatrix.c in the libavfilter folder suggests
http://code.google.com/p/ffmbc/ Quote:
I think the ffmbc syntax was -vf colormatrix=bt709:bt601 -vf colormatrix=bt601:bt709 Maybe it can be merged into x264 / ffmpeg ? |
|
13th February 2012, 19:42 | #58 | Link |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
|
13th February 2012, 21:39 | #59 | Link |
Registered User
Join Date: Nov 2005
Posts: 693
|
Yes, and since the input is already correctly being detected as full-range, I've noticed --input-range pc isn't needed. Instructing x264 with --range tv is enough.
I'm sorry to bother you again with Avisynth, but to match colors as closely as possible, apart from SmoothLevels, which one would you prefer? ColorYUV(levels="PC->TV") ColorMatrix(dest=2, clamp=0) or ColorMatrix(dest=2, clamp=0, inputFR=true) Speed-wise it doesn't matter at all, but the levels histogram of the latter more resembles the one from Fraps' VFW decoder. o_O
__________________
My hobby website |
15th October 2012, 21:02 | #60 | Link |
Registered User
Join Date: Nov 2005
Posts: 693
|
Feeding x264 an Avisynth-script.
I'm still not sure which one of these two I would choose: Code:
FFMpegSource2 ColorYUV(levels="PC->TV") ColorMatrix() - fps (avg): 94.74 FFMpegSource2 ColorMatrix(clamp=0, inputFR=true) - fps (avg): 88.53 Code:
FFMpegSource2 FFMpegSource2 ColorYUV(levels="PC->TV") histogram almost Levels(0, 1, 255, 16, 235, coring=false) ColorMatrix() --> identical to: ColorMatrix() FFMpegSource2 FFMpegSource2 ColorYUV(levels="PC->TV") SmoothLevels(preset="pc2tv", chroma=100) ColorMatrix(clamp=0, inputFR=true) --> histogram resembles: ColorMatrix()
__________________
My hobby website |
|
|