View Full Version : Color problem: FRIMencoder via Avisynth
colinhunt
22nd December 2013, 00:44
I can't figure out why I'm getting very odd colors out of a 3D encode test. Can anyone tell me what I'm doing wrong here?
This image illustrates the issue clearly:
http://i40.tinypic.com/2lup8j4.jpg
The source is a HDTV broadcast which I demuxed to .AAC and .MPV. Video is MPEG-2, 1440x1080 at 29.97fps. It's also Half-SBS 3D, so the frame contains two viewpoints squeezed horizontally. MediaInfo claims the file is interlaced with Top Field First, but MeGUI's Analyzer says it's interlaced with Bottom Field First.
I indexed the file with DGIndex first. Here's the Avisynth script, input.avs, which acts as source for FRIMencoder:
LoadPlugin("C:\Program Files (x86)\MeGUI\tools\dgindex\DGDecode.dll")
DGDecode_mpeg2source("video.d2v")
Load_Stdcall_Plugin("C:\Program Files (x86)\MeGUI\tools\yadif\yadif.dll")
Yadif(order=0)
ConvertFPS(23.976)
Spline16resize(3840,1080)
(Note: I also ran tests with ConvertToYV12() as the last line in the script, but it has no effect on the output colors.)
Here's the FRIMencode command line (thanks to Sharc):
FRIMEncode -avi -sbs 2 -i input.avs -viewoutput -o::mvc base.avc dependent.mvc -w 1920 -h 1080 -l 6 -cpbsize 3750 -vbr 16000 32000 -u 4 -profile high -level 4.1 -gop 24 4 0 O -PicTimingSEI off -EndOfSequence off
HWK
22nd December 2013, 00:54
Can you post media info report of original file.
HWK
22nd December 2013, 00:57
(Note: I also ran tests with ConvertToYV12() as the last line in the script, but it has no effect on the output colors.)
Here's the FRIMencode command line (thanks to Sharc):
FRIMEncode -avi -sbs 2 -i input.avs -viewoutput -o::mvc base.avc dependent.mvc -w 1920 -h 1080 -l 6 -cpbsize 3750 -vbr 16000 32000 -u 4 -profile high -level 4.1 -gop 24 4 0 O -PicTimingSEI off -EndOfSequence off
If you add ConvertToYV12() to script, you must tell encoder as well. Try adding -nv12 to frimenocde file
colinhunt
22nd December 2013, 01:33
Can you post media info report of original file.
General
ID : 24736 (0x60A0)
Format : MPEG-TS
File size : 6.85 GiB
Duration : 51mn 14s
Overall bit rate mode : Variable
Overall bit rate : 19.1 Mbps
Maximum Overall bit rate : 24.0 Mbps
Video
ID : 4109 (0x100D)
Menu ID : 800 (0x320)
Format : MPEG Video
Format version : Version 2
Format profile : Main@High
Format settings, BVOP : Yes
Format settings, Matrix : Custom
Format settings, GOP : Variable
Codec ID : 2
Duration : 51mn 14s
Bit rate mode : Variable
Bit rate : 18.0 Mbps
Maximum bit rate : 20.0 Mbps
Width : 1 440 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Interlaced
Scan order : Top Field First
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.386
Time code of first frame : 09:28:06:04
Time code source : Group of pictures header
Stream size : 6.44 GiB (94%)
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
Audio
ID : 4173 (0x104D)
Menu ID : 800 (0x320)
Format : AAC
Format/Info : Advanced Audio Codec
Format version : Version 2
Format profile : LC
Muxing mode : ADTS
Codec ID : 15
Duration : 51mn 14s
Bit rate mode : Variable
Bit rate : 192 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Delay relative to video : -303ms
Stream size : 70.4 MiB (1%)
It's actually in two parts; the above is from part 1. I combined the files in tsmuxer before demuxing video and audio.
colinhunt
22nd December 2013, 01:35
If you add ConvertToYV12() to script, you must tell encoder as well. Try adding -nv12 to frimenocde file
ConvertToYV12 is unnecessary, AFAIK, as the source file is YUV420. FRIMencoder accepts input without ConvertToYV12, in other words. Also, colors are fine in MeGUI's preview of input.avs without ConvertToYV12.
HWK
22nd December 2013, 01:41
I am wondering could it be avisynth. I remember reading few days ago version 2.5.8 had problem with it.
colinhunt
22nd December 2013, 01:42
I am wondering could it be avisynth. I remember reading few days ago version 2.5.8 had problem with it.
Wouldn't it affect MeGui preview of input.avs?
HWK
22nd December 2013, 02:00
No, it specifically effected frimencode. You can search in that thread and see if it still does.
colinhunt
22nd December 2013, 02:13
No, it specifically effected frimencode. You can search in that thread and see if it still does.
Ah yeah, now I remember reading something about that too. I'll install 2.6.0 Alpha 5 and check if that makes a difference.
... nope. Still blue skin.
HWK
22nd December 2013, 02:41
Can you convert it to I420 color space. Couple days ago I decoded with frimdecode and then pipe to encoder and even though it said YUV, but in other program I had to select I420 to make color appear correct.
Sharc
22nd December 2013, 08:51
@Colin:
1) Colour shift:
Try adding to your script: ConvertToYV12(interlaced=true)
2) your other post "...tsMuxeR can't create ISO ...":
In the 'General' Tab of tsMuxeR tick "Use async I/O" and "Blu-ray Audio PES".
(Physic will fix this in the upcoming release).
colinhunt
22nd December 2013, 12:58
1) Colour shift:
Try adding to your script: ConvertToYV12(interlaced=true)
I suppose you mean it should be added before Yadif deinterlaces video?
Tried it, got blue girls again.
colinhunt
22nd December 2013, 13:28
Can you convert it to I420 color space.
Tried it just now, didn't help :/
colinhunt
22nd December 2013, 19:22
Uninstalled Avisynth, installed Avisynth+. No change: everyone looks like they're from Avatar.
Used FFvideosource for the .mpv instead of DGDecode_Mpegsource for .d2v: it's Na'vi all over again.
Sharc
22nd December 2013, 20:07
I can't reproduce the Color shift here.
Main difference to your case:
- my source format is mpeg-4 (yours is mpeg-2)
- my source is progressive, no deinterlacing (yours is interlaced and you deinterlace with yadif)
Can you upload a short sample of your source?
colinhunt
22nd December 2013, 20:13
Can you upload a short sample of your source?
Found a non-encoding cutting tool... just a moment.
Sharc
22nd December 2013, 20:31
I'd assume that Vdub should be ok for mpeg-2.
Or try
- DGSplit
- DGIndexNV (in case you have it)
colinhunt
22nd December 2013, 20:36
OK, try this:
https://portal.bitcasa.com/send/90364efc993fbc4e86616421248171a806f0ef5e09a8c0a78dab22702a3d7fec/1e95fd32fbcf5ea102ee00652bd2961819f10ee37e14b440c17010375de81a27
And here's a very easy way to tell if the encode has messed-up colors or not: if the tent-like structure is blue, colors are correct. If the tent is red, the colors are incorrect.
Sharc
22nd December 2013, 21:27
No problem here with colors.
Script "colinhunt.avs":
DirectShowSource("C:\..........\edit.mpv")
FieldDeinterlace(blend=false)
spline16resize(3840,1080)
Command:
"C:\..........\FRIMEncode.exe" mvc -avi -sbs 2 -i colinhunt.avs -viewoutput -o::mvc Base_.avc Dependent_.mvc -w 1920 -h 1080 -l 6 -cpbsize 3750 -vbr 6000 15000 -u 4 -profile high -level 4.1 -gop 24 4 0 O -PicTimingSEI off -EndOfSequence off
colinhunt
22nd December 2013, 21:30
No problem here with colors.
OK. So, any theories on what's messing up the colors here? Mind you, I haven't tried DirectShowSource yet; I'll give it a shot.
colinhunt
22nd December 2013, 21:38
Interesting. I got "ERROR: Cannot get YUV420 frame from input avi-file edit_input.avs" errors at first from DirectShowSource("edit.mpv"). I then compared the Command you posted above to the one I'm running and noticed that there was an "mvc" missing from between FRIMEncode.exe and "-avi". I added that to my Command, and the "Cannot get YUV420" error disappeared.
Howeverrrr... output has incorrect colors still.
Sharc
22nd December 2013, 22:17
Hmmm..... here it works with or without the "mvc" before the -avi. Actually I think it shouldn't even be there according to the FRIM documentation. I don't know how it sneaked in (copy / paste from a former syntax?). Anyway, it stopped the error message in your case. Strange.
I have no clue why you still get this color shift. :confused:
colinhunt
22nd December 2013, 22:50
I have no clue why you still get this color shift. :confused:
There must be something terribly wrong with my primary encoding rig. That's the only explanation I can think of. I'll run the same encode on another PC to see what happens.
...welp, can't run a single encode on another PC. Keep getting the "Cannot get YUV420 frame from input" error. Tried DirectShowSource, FFvideosource and DGDecode_mpeg2source. Bloody odd, this.
colinhunt
23rd December 2013, 00:50
I'm totally confused here. Same source files, same scripts, same versions of FRIMEncoder etc., but on this PC I get nothing but "Cannot get YUV420" errors. On the other rig I get blue people.
Really, what the heck?
colinhunt
23rd December 2013, 01:04
Third PC, and it's getting even more ridiculous:
FRIMEncode -avi -sbs 2 -i edit_input.avs -viewoutput -o::mvc base.avc dependent.mvc
-w 1920 -h 1080 -l 6 -cpbsize 3750 -vbr 30000 35000 -u 4 -profile high -level 4.1 -gop 24 4 0 O
-PicTimingSEI off -EndOfSequence off
FRIM Encoder version 1.18 (build: Nov 26 2013)
- based on Intel(R) Media SDK
WARNING: partial acceleration
Media SDK impl HARDWARE (C:\...\libmfxhw32.dll)
Media SDK version 1.7
Memory type System
Input format YUV420
Output video AVC
Source picture:
Resolution 448x64
Crop X,Y,W,H 0,0,438,56
Destination picture:
Resolution 448x64
Crop X,Y,W,H 0,0,438,56
Frame rate 24.000
Bitrate control VBR
avg,maximum 30000,35000
GOP structure:
GOP length 24
I-/P-frame distance 4
IDR-frame interval 0
GOP type Opened
Num of slices 6
Target usage 4 (balanced)
Processing started
Frame number: 0
Processing finished in 0.00 seconds
FRIMEncode -sw -avi -sbs 2 -i edit_input.avs -viewoutput -o::mvc base.avc dependent.mvc
-w 1920 -h 1080 -l 6 -cpbsize 3750 -vbr 30000 35000 -u 4 -profile high -level 4.1 -gop 24 4 0 O
-PicTimingSEI off -EndOfSequence off
FRIM Encoder version 1.18 (build: Nov 26 2013)
- based on Intel(R) Media SDK
Media SDK impl SOFTWARE (C:\...\libmfxsw32.dll)
Media SDK version 1.7
Memory type System
Input format YUV420
Output video AVC
Source picture:
Resolution 448x64
Crop X,Y,W,H 0,0,438,56
Destination picture:
Resolution 448x64
Crop X,Y,W,H 0,0,438,56
Frame rate 24.000
Bitrate control VBR
avg,maximum 30000,35000
GOP structure:
GOP length 24
I-/P-frame distance 4
IDR-frame interval 0
GOP type Opened
Num of slices 6
Target usage 4 (balanced)
Processing started
Frame number: 0
Processing finished in 0.00 seconds
Input.avs:
LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DGDecode.dll")
DGDecode_mpeg2source("edit.d2v")
ConvertToYV12(interlaced=true)
ConvertFPS(23.976)
Spline16resize(3840,1080)
To recap:
PC #1: Blue people.
PC #2: "Cannot get YUV420" errors only.
PC #3: Sets fps to 24.00, resolution to 448x64, crops 438x56 and processes 0 frames.
Sharc
23rd December 2013, 01:06
Check your ffdshow settings (http://forum.doom9.org/showpost.php?p=1655521&postcount=341)
You must have ffdshow fully installed, i.e. including the VFW (Video for Windows) Option.
Added:
I would drop the Intel HW acceleration Option for now. It complicates things even more.
colinhunt
23rd December 2013, 01:18
Check your ffdshow settings (http://forum.doom9.org/showpost.php?p=1655521&postcount=341)
You must have ffdshow fully installed, i.e. including the VFW (Video for Windows) Option.
This might be it; thanks!
Added:
I would drop the Intel HW acceleration Option for now. It complicates things even more.
On one PC FRIMEncoder defaults to -hw while on another it defaults to -sw. I had to add "-sw" to the Command to force FRIM into software mode on this PC, for example.
colinhunt
23rd December 2013, 01:41
Ohh-kay, things are looking up! I did a full re-install of FFDShow on two PCs and ran the tests. The original encoding rig (a dual-Xeon E5520) is still outputting incorrect colors, but the newer rig (i7-3930K) outputs correct colors!
Thanks for sticking with it, Sharc :)
raffriff42
23rd December 2013, 01:50
Ha, too late I guessMergeRGB(ShowBlue, ShowGreen, ShowRed)
colinhunt
23rd December 2013, 01:51
Ha, too late I guessMergeRGB(ShowBlue, ShowGreen, ShowRed)
Not necessarily; I still need to find out why one PC outputs incorrect colors. How do I use MergeRGB and what does it do?
raffriff42
23rd December 2013, 02:00
You add this line to your existing Avisynth Script. You will need to convert to RGB first, and probably back to YUV afterwards.
LoadPlugin("C:\Program Files (x86)\MeGUI\tools\dgindex\DGDecode.dll")
DGDecode_mpeg2source("video.d2v")
Load_Stdcall_Plugin("C:\Program Files (x86)\MeGUI\tools\yadif\yadif.dll")
Yadif(order=0)
ConvertFPS(23.976)
Spline16resize(3840,1080)
ConvertToRGB24
MergeRGB(ShowBlue, ShowGreen, ShowRed)
ConvertToYUY2 /* maybe */
EDIT what it does is swap color planes. Same as Irfanview's Image menu, Swap Colors, RGB->BGR
colinhunt
23rd December 2013, 02:03
You add this line to your existing Avisynth Script. You will need to convert to RGB first, and probably back to YUV afterwards.
ConvertToYV12 instead of YUY2, probably... but OK, I'll give it a shot. Thanks!
update: Bloody Norah, it worked! I haven't the foggiest why the dual-Xeon needs this ConvertToRGB24 -> MergeRGB -> ConvertToYV12 processing, while the newer rig outputs correct color without it - but it works, and that's the main thing. Thank you!
Sharc
23rd December 2013, 10:37
@Colinhunt:
So you are ready for x-mas then .... :D
Out of interest:
How did it go with frame rate conversion and Audio sync?
For 3D Blu-ray compliance you have the options
- 1920x1080p 23.976fps
- 1280x720p 59.94fps
Your source seems to be 29.97fps, encoded (or flagged) interlaced but the video is progressive. So perhaps the simplest conversion for a smooth playback would be bobbing to 59.94 (yadif(mode=1)) and resizing to 1280x720.
colinhunt
23rd December 2013, 13:53
@Colinhunt:
So you are ready for x-mas then .... :D
More or less :)
How did it go with frame rate conversion and Audio sync?
For 3D Blu-ray compliance you have the options
- 1920x1080p 23.976fps
- 1280x720p 59.94fps
Your source seems to be 29.97fps, encoded (or flagged) interlaced but the video is progressive. So perhaps the simplest conversion for a smooth playback would be bobbing to 59.94 (yadif(mode=1)) and resizing to 1280x720.
I'm not there yet. My newer encoding rig is still crunching MVC. My intention is to check the exact length of the output, then use some audio software to stretch, if needed, demuxed audio to match the mvc's length. I'm encoding to 1080p/23.976 by simply using ConvertFPS. I'll go for a more sophisticated FRC later, if necessary.
colinhunt
23rd December 2013, 18:07
check the exact length of the output, then use some audio software to stretch, if needed, demuxed audio to match the mvc's length. I'm encoding to 1080p/23.976 by simply using ConvertFPS.
Yeah, that didn't work out too well. Yech.
colinhunt
23rd December 2013, 18:23
Your source seems to be 29.97fps, encoded (or flagged) interlaced but the video is progressive. So perhaps the simplest conversion for a smooth playback would be bobbing to 59.94 (yadif(mode=1)) and resizing to 1280x720.
Tried it, but my Avisynth skillz let me down again. There's something wrong with this:
Load_Stdcall_Plugin("C:\Program Files (x86)\MeGUI\tools\yadif\yadif.dll")
FFvideoSource("video.mpv", colorspace="YV12")
Yadif(mode=1)
Spline16resize(2560,720)
Sharc
23rd December 2013, 19:37
What works well here and produces 2 views 1280x720p 59.94fps
Script colinhunt2.avs:
LoadCplugin("C:\Program Files Video\AviSynth 2.5\plugins\yadif.dll")
directShowSource("c:\Temp\Scratch\Colinhunt\edit.mpv")
Yadif(mode=1)
Spline16resize(2560,720)
FRIM-cmd:
"C:\Program Files Video\Frim\FRIMEncode.exe" -avi -sbs 2 -i colinhunt2.avs -viewoutput -o::mvc colinhunt_Base_.avc colinhunt_Dependent_.mvc -w 1280 -h 720 -l 6 -cpbsize 3750 -vbr 6000 15000 -u 4 -profile high -level 4.1 -gop 24 4 0 O -PicTimingSEI off -EndOfSequence off
colinhunt
23rd December 2013, 20:09
What works well here and produces 2 views 1280x720p 59.94fps
I'll give it a shot - thanks!
... Well, the computer says "no".
FRIMEncoder says the source has a resolution of 464x320, and processes 0 frames at a framerate of 24.000 fps.
Opened the .avs on MPC-HC and got this:
DirectShowSource: Could not open as video or audio.
Video returned: "DirectShowSource: unable to determine the duration of the video."
Audio returned: "DirectShowSource: RenderFile, the filter graph manager won't talk to me."
Also, when I first tried to run the command, FRIMEncoder threw a s***fit and complained there's no "nvcuvid.dll" installed on my system.
Sharc
23rd December 2013, 21:22
Perhaps better to wait for jdobb's new release?
The 3-D stuff seems to give him a hard time as well.... ;)
colinhunt
23rd December 2013, 21:59
Perhaps better to wait for jdobb's new release?
The 3-D stuff seems to give him a hard time as well.... ;)
There's nothing terribly difficult about Avisynth scripts, really. I keep running into problems because no two PCs of mine behave the same way. If Avisynth, its filters and FRIMEncoder worked consistently the same way in every environment, I'd have no problems at all... but for some reason they don't.
FFvideosource works fine here, DirectShowSource does not.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.