How to disable external filter for specific format

View previous topic View next topic Go down

How to disable external filter for specific format

Post by openforu on Wed Sep 16, 2015 12:35 pm

I have small problem, when codec H.264\AVC in ffdshow is disabled, AVI (avc) files have wrong color space, but MP4 good. When it is enabled AVC have good colors but mp4 wrong.


So I want to disable ffdshow Video Decoder but only for mp4 files. But how?
Theres something to do in MPC external filters settings? Which sub type is for mp4?

openforu

Posts : 7
Join date : 2015-09-16

View user profile

Back to top Go down

Re: How to disable external filter for specific format

Post by Admin on Wed Sep 16, 2015 3:03 pm

It is not possible to select a decoder based on the file extension. It would also not be a good solution.

I recommend LAV Video Decoder. You should also try madVR as video renderer in MPC. That is able to use colorspace information from the video decoder.

Can you copy the MediaInfo details for some of your files here? It is possible that the files contain incorrect metadata for the colorspaces. Once we know what is wrong with those files, there are several ways to correct the colors during playback. For example using Shaders in MPC.

Admin
Admin

Posts : 3239
Join date : 2011-06-17

View user profile http://codecs.forumotion.net

Back to top Go down

Re: How to disable external filter for specific format

Post by openforu on Wed Sep 16, 2015 4:39 pm

I spent few days to figure it out.

Haali Video Renderer + LAV
On BT.601 avi and other formats are correct but mp4 wrong, when i switch to BT.709 its only reverse that, and now only mp4 files is correct.
On VMR-7/9 and EVR same thing happens.



On madVR I have to use ffdshow (with two options enabled on screen below) to get right colors.


When I disable decoder for H.264/AVC in ffdshow codec settings it helps. Now all format show correct colors, and mp4 too.
But now problem is only with AVC1 - avi file, color is wrong. LAV settings change nothing.
Or I just need to disable ffdshow codec for H.264 only and leave AVC, but I can't. Its allow me to disable or enable both

So in madVR I have to choose good colorspace between .avi with AVC1 codec, or .mp4.
Or maybe I can do something in MPC external filters settings, there must be way to block ffdshow for only h.264 or mp4
Delete sub type or something? I want set madVR + LAV without ffdshow for mp4.


My best solution for now is second MPC player with different setting for mp4.
I think shaders may help, but I tried all included in MPC and nothing. Maybe I have to download other.


Theres MediaInfo details:
avi/XVID-> avi/AVC1 ->  mp4/H.264 ->

openforu

Posts : 7
Join date : 2015-09-16

View user profile

Back to top Go down

Re: How to disable external filter for specific format

Post by Admin on Wed Sep 16, 2015 8:02 pm

The reason why the AVI files are displayed wrong is because it does not have any metadata that indicates that the video was encoded using BT.601. This means that the video renderer has to guess it, and because the video has HD resolution it assumes BT.709.

Solution 1

Use madVR.
Add [matrix=601] to the filenames of the AVI files. This forces madVR to use the BT.601. Or add it to a folder name to apply it to all files in the folder.

Solution 2

Add this to a .txt file and then rename to .hlsl
Code:
sampler s0;
float2 c0;

float4 main(float2 tex : TEXCOORD0) : COLOR
{
   float4 si = tex2D(s0, tex);
   float3 s1 = si.rgb;
   s1 = float3(dot(float3(.2126, .7152, .0722), s1), dot(float3(-.1063/.9278, -.3576/.9278, .5), s1), dot(float3(.5, -.3576/.7874, -.0361/.7874), s1));
   return float3(s1.x+1.402*s1.z, dot(s1, float3(1, -.202008/.587, -.419198/.587)), s1.x+1.772*s1.y).rgbb;
}

1) Add this shader to MPC-HC.
2) Create a preset called "Disabled" with no shaders and save it.
3) Create a preset called "BT601" with the above shader (as pre-resize!) and save it.

Now you can select the desired preset through:
MPC-HC menu > Play > Shaders


Last edited by Admin on Wed Sep 16, 2015 11:16 pm; edited 2 times in total

Admin
Admin

Posts : 3239
Join date : 2011-06-17

View user profile http://codecs.forumotion.net

Back to top Go down

Re: How to disable external filter for specific format

Post by openforu on Wed Sep 16, 2015 8:25 pm

Solution 2 is not working. I have created file "Color.hlsl" but MPC show "Failed to set presize shaders." - MPC-HC 1.7.9
Something wrong in this code maybe?
Is there way to put metadata when I render video?

openforu

Posts : 7
Join date : 2015-09-16

View user profile

Back to top Go down

Re: How to disable external filter for specific format

Post by Admin on Wed Sep 16, 2015 8:54 pm

Yes, it was mistake in the code. I have fixed it above.

Only way to fix the video is to re-encode it.

Admin
Admin

Posts : 3239
Join date : 2011-06-17

View user profile http://codecs.forumotion.net

Back to top Go down

Re: How to disable external filter for specific format

Post by openforu on Wed Sep 16, 2015 10:56 pm

Its still "Failed to set pre-size shaders."

openforu

Posts : 7
Join date : 2015-09-16

View user profile

Back to top Go down

Re: How to disable external filter for specific format

Post by Admin on Wed Sep 16, 2015 11:16 pm

Fixed another typo.

Admin
Admin

Posts : 3239
Join date : 2011-06-17

View user profile http://codecs.forumotion.net

Back to top Go down

Re: How to disable external filter for specific format

Post by openforu on Thu Sep 17, 2015 3:49 pm

Now is working  Very Happy.  
So when I exporting video as xvid or something else, theres no options to set matrix on BT.601 in encoders.
Admin wrote:Only way to fix the video is to re-encode it.
How I can do that? What program should I use? Because exported video on YouTube have wrong colors too. I have no idea how to correct that

openforu

Posts : 7
Join date : 2015-09-16

View user profile

Back to top Go down

Re: How to disable external filter for specific format

Post by Admin on Thu Sep 17, 2015 4:40 pm

You can use VirtualDub with x264VFW codec (included in K-Lite Mega).

1) Open file in VirtualDub
2) Video > Compression > x264VFW > Configure
3) Enable "virtualdub hack" option
4) Add --colormatrix smpte170m to extra command line (this signals that it is BT.601)
5) I usually set the preset to "slower".
6) With the ratefactor value you can control the quality/size ratio.

Admin
Admin

Posts : 3239
Join date : 2011-06-17

View user profile http://codecs.forumotion.net

Back to top Go down

Re: How to disable external filter for specific format

Post by Admin on Thu Sep 17, 2015 4:44 pm

You may also need to add:
--colorprim smpte170m --transfer smpte170m
But I am not sure if that is needed. Try without first.

Admin
Admin

Posts : 3239
Join date : 2011-06-17

View user profile http://codecs.forumotion.net

Back to top Go down

Re: How to disable external filter for specific format

Post by openforu on Thu Sep 17, 2015 5:57 pm

But I dont want to export with x264VFW I just need to put BT.601 on my avc files, because AVC1 avi format have best quality on youtube, but only colors are wrong. I think about some script? Avisynth or something? Is that possible?

Thanks for help, Now I know a lot.

openforu

Posts : 7
Join date : 2015-09-16

View user profile

Back to top Go down

Re: How to disable external filter for specific format

Post by Admin on Thu Sep 17, 2015 9:06 pm

AVC1 = H.264, and x264VFW is an encoder for H.264 video.

I have found away to modify the bitstream without full re-encoding. See here:
http://forum.doom9.org/showthread.php?t=152419
Command line should be like this:
ffmpeg -i input.avi -vcodec copy -acodec copy -vbsf h264_changesps=colormatrix=6 output.avi

MediaInfo does not show any colorspace details on the resulting file. But I have checked with madVR and it gets to corrent metadata.

Admin
Admin

Posts : 3239
Join date : 2011-06-17

View user profile http://codecs.forumotion.net

Back to top Go down

Re: How to disable external filter for specific format

Post by openforu on Sun Jan 17, 2016 10:10 pm

Hello again Smile

Admin wrote:
4) Add --colormatrix smpte170m to extra command line (this signals that it is BT.601)

Right but with this command, player know its bt.601 and is changing to 709.
Colorspace still wrong.


This is the right solution:
Export with x264VFW
Extra command line: --colorprim bt709 --transfer bt709 --colormatrix bt709 --fps XX

Now player changing it to bt.601  cheers
Colorspace is good in video players and on youtube. Thanks for solving that.

openforu

Posts : 7
Join date : 2015-09-16

View user profile

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum