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 > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 12th June 2019, 05:39   #1  |  Link
orion44
None
 
orion44's Avatar
 
Join Date: Jul 2007
Location: The Background
Posts: 190
RGB to YV12 video encoding - colors are off...

I recorded a game with MAME's native recorder. The output video (sf2.avi) is in the following format:

Quote:
Video
ID : 0
Format : RGB
Codec ID : 0x00000000
Codec ID/Info : Basic Windows bitmap format. 1, 4 and 8 bpp versions are palettised. 16, 24 and 32bpp contain raw RGB samples
Duration : 26 min 43 s
Bit rate : 118 Mb/s
Width : 384 pixels
Height : 224 pixels
Display aspect ratio : 1.714
Frame rate : 59.610 FPS
Bit depth : 8 bits
Bits/(Pixel*Frame) : 23.039
Stream size : 22.1 GiB (95%)
I then used avisynth:

Quote:
AVISource("D:\Project\sf2.avi", audio=false)
PointResize(960,720)
to encode with x264:

Quote:
x264 --profile high --level 3.2 --preset slow --pass 1 --stats D:\Project\stats.log --bitrate 1000 -I 600 -i 60 -o D:\Project\1stPass.mkv "D:\Project\AviSynth Scripts\AVISource.avs"
x264 --profile high --level 3.2 --preset slow --pass 2 --stats D:\Project\stats.log --bitrate 1000 -I 600 -i 60 -o D:\Project\2ndPass.mkv "D:\Project\AviSynth Scripts\AVISource.avs"
pause
During the encoding, I got the following warning:

Quote:
resize [warning]: converting from bgr24 to yuv420p
The x264 encoded video has colors which are slightly off.

Example:

Screenshot taken directly from game. Looks good:

http://u.cubeupload.com/ClearSky/2ma...6102241334.png

Screenshot taken from AviSynth script above. Looks a bit lower quality, but colors are the same.

http://u.cubeupload.com/ClearSky/3FromVideo.png

Screenshot taken from final x264 encode. Red color is slightly off:

http://u.cubeupload.com/ClearSky/3fu.png

Is this color conversion normal, the way it should be, or is there a way to fix this?

Thanks.

Last edited by orion44; 12th June 2019 at 05:43. Reason: clarification...
orion44 is offline   Reply With Quote
Old 12th June 2019, 05:50   #2  |  Link
Cary Knoop
Cary Knoop
 
Cary Knoop's Avatar
 
Join Date: Feb 2017
Location: Newark CA, USA
Posts: 208
The lower quality is mostly chroma subsampling.
The color difference looks like a Rec.601/Rec709 interpretation issue.
Cary Knoop is offline   Reply With Quote
Old 12th June 2019, 13:21   #3  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Germany
Posts: 672
Try with:

Code:
#Indexing
OpenDMLSource("D:\Project\sf2.avi")

#From BGR24 to 4:2:0 planar
Converttoyv12(interlaced=false)

#Resize
Spline36Resize(960, 720)
Please note that PointResize is a pretty basic resizing kernel, so I would suggest you either Lanczos or Spline.
Since you recorded in RGB, when you are gonna convert it to yv12 you are gonna lose something, while by converting it to yv24 you are gonna preserve chroma. Are you sure you wanna encode in H.264 4:2:0 planar?
As to the color matrix, I don't know whether it has been recorded in BT601 or BT709, but in case it was recorded in BT601 and you wanna convert it to BT709, just use:

Code:
#Indexing
OpenDMLSource("D:\Project\sf2.avi")

#From BGR24 to 4:2:0 planar
Converttoyv12(interlaced=false)

#From BT601 to BT709
ColorMatrix(mode="Rec.601->Rec.709", clamp=true, interlaced=false, threads=0, thrdmthd=0, opt=3)

#Resize
Spline36Resize(960, 720)
By the way, in your case, your content is a videogame, so it doesn't really matter, but in case one day you'll have to encode a real live footage, you may wanna do a color matrix conversion with 16bit precision. In case you wanna do it in 16bit interleaved:
Code:
Matrix(from=601, to=709, rg=1.0, gg=1.0, bg=1.0, a=16, b=235, ao=16, bo=235, bitdepth=16)
__________________
Broadcast Encoder
Avisynth memes: 1 - 2 - 3
Videotek - Audacity XP
FranceBB is offline   Reply With Quote
Old 12th June 2019, 16:36   #4  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,822
Quote:
Converttoyv12(interlaced=false)

#From BT601 to BT709
ColorMatrix(mode="Rec.601->Rec.709", clamp=true, interlaced=false, threads=0, thrdmthd=0, opt=3)
Would it not be one less conversion just to do:

Code:
converttoyv12(interlaced = false, matrix = "rec709")
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is online now   Reply With Quote
Reply

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 22:00.


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