YUV RGB Video Levels

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

YUV RGB Video Levels

Chris-2
I have a strange question.

I have a YUV video file which must pass EBU r103. The RGB components must be above 0 and less than 255.

How would I use ffmpeg to correct the levels of the R, G and B components of YUV video?

According to the docs, lutrgb works only on RGB video, not YUV.

I'm not sure this can be accomplished by bringing down the Y level using lutyuv or by reducing saturation.

Thank you.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: YUV RGB Video Levels

Carl Eugen Hoyos-2
2018-10-22 23:54 GMT+02:00, Chris <[hidden email]>:
> I have a strange question.
>
> I have a YUV video file which must pass EBU r103. The RGB
> components must be above 0 and less than 255.

(I probably misunderstand but I would have assumed that it is
technically impossible to output values that are not within
these boundaries.)

> How would I use ffmpeg to correct the levels of the R, G and
> B components of YUV video?

What did you do (command line and complete, uncut console
output) to get output that you or EBu r103 did not like?

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: YUV RGB Video Levels

Phil Rhodes-3
>> I have a YUV video file which must pass EBU r103. The RGB
>> components must be above 0 and less than 255.

> (I probably misunderstand but I would have assumed that it is
> technically impossible to output values that are not within
> these boundaries.)
Depending on the primaries, it is possible to have YUV values which imply illegal RGB values, which may be what's being discussed here.
P  
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: YUV RGB Video Levels

Chris-2
In reply to this post by Chris-2
Depending on the primaries, it is possible to have YUV values which imply illegal RGB values, which may be what's being discussed here.

That's what I'm trying to fix with ffmpeg :)


-----Original Message-----
From: Phil Rhodes <[hidden email]>
To: FFmpeg user questions <[hidden email]>
Sent: Wed, Oct 24, 2018 3:41 am
Subject: Re: [FFmpeg-user] YUV RGB Video Levels


>> I have a YUV video file which must pass EBU r103. The RGB
>> components must be above 0 and less than 255.

> (I probably misunderstand but I would have assumed that it is
> technically impossible to output values that are not within
> these boundaries.)
Depending on the primaries, it is possible to have YUV values which imply illegal RGB values, which may be what's being discussed here.
P   

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: YUV RGB Video Levels

Paul B Mahol
On 10/24/18, Chris <[hidden email]> wrote:
> Depending on the primaries, it is possible to have YUV values which imply
> illegal RGB values, which may be what's being discussed here.
>
> That's what I'm trying to fix with ffmpeg :)
>
>

You probably want to use limiter video filter:

for 8bit videos:

limiter=min=16:max=235:planes=1,limiter=min=16:max=240:planes=6
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: YUV RGB Video Levels

Chris-2
Thanks, I'll give it a try. Does this apply to RGB as opposed to YUV? How do you arrive at planes=6, assuming 3 bit planes?


-----Original Message-----
From: Paul B Mahol <[hidden email]>
To: FFmpeg user questions <[hidden email]>
Sent: Wed, Oct 24, 2018 1:09 pm
Subject: Re: [FFmpeg-user] YUV RGB Video Levels

You probably want to use limiter video filter:

for 8bit videos:

limiter=min=16:max=235:planes=1,limiter=min=16:max=240:planes=6

_______________________________________________
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: YUV RGB Video Levels

Gyan Doshi
On Thu, Oct 25, 2018 at 4:48 AM Chris <[hidden email]>
wrote:

> Thanks, I'll give it a try. Does this apply to RGB as opposed to YUV? How
> do you arrive at planes=6, assuming 3 bit planes?
>

`6` is the decimal for 0110 where those middle bits represent the chroma
planes; the right represents luma, and the MSB represents alpha i.e. AVUY

I'm not sure this will do job, though.If there's any legal YUV triplet
which maps to out-of-bounds RGB this filter won't sanitize it.

The crude way is to roundtrip via RGB using scale.


Gyan
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: YUV RGB Video Levels

Chris-2
In reply to this post by Chris-2
Here is the command line I've been using. Note that I am "cheating" by using lutrgb on a yuv file.

ffmpeg -y -i "D:\Videos\SonyAX53\C0060.MP4"  -crf 0 -s 1280X720   -c:v huffyuv  -pix_fmt yuv420p  -s 1280x720  -r 59.94  -vf  unsharp=luma_msize_x=7:luma_msize_y=7:luma_amount=-0.70,eq=brightness=0.00:saturation=1.00:gamma=0.81,lutyuv=y='clip(val*1.20,16,240)',lutrgb=r='clip(val,16,205)',lutrgb=g='clip(val,16,246)',lutrgb=b='clip(val,16,246)' -c:a copy  processed.mkv

Here is EBU r103. Ideally the y, r, g and b levels would range from 5 to 246 (8-bit video). In any event they MUST range from 1 - 254 as the values 0 and 255 are reserved for sync.

https://tech.ebu.ch/docs/r/r103.pdf

I have begun to try converting the y, u and v samples to rgb using pix_fmt rgb24 and have had some success but am having trouble making the rgb values meet the exact clip values I specify.

lutrgb=r='clip(val,16,180)',lutrgb=g='clip(val,16,180)',lutrgb=b='clip(val,16,180)'

I have set the clip values to 180 for testing.

The source video is from a camcorder.


-----Original Message-----
From: Carl Eugen Hoyos <[hidden email]>
To: FFmpeg user questions <[hidden email]>
Sent: Wed, Oct 24, 2018 3:20 am
Subject: Re: [FFmpeg-user] YUV RGB Video Levels

2018-10-22 23:54 GMT+02:00, Chris <[hidden email]>:
> I have a strange question.
>
> I have a YUV video file which must pass EBU r103. The RGB
> components must be above 0 and less than 255.

(I probably misunderstand but I would have assumed that it is
technically impossible to output values that are not within
these boundaries.)


> How would I use ffmpeg to correct the levels of the R, G and
> B components of YUV video?


What did you do (command line and complete, uncut console
output) to get output that you or EBu r103 did not like?

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".


-----Original Message-----
From: Carl Eugen Hoyos <[hidden email]>
To: FFmpeg user questions <[hidden email]>
Sent: Wed, Oct 24, 2018 3:20 am
Subject: Re: [FFmpeg-user] YUV RGB Video Levels


2018-10-22 23:54 GMT+02:00, Chris <[hidden email]>:
> I have a strange question.
>
> I have a YUV video file which must pass EBU r103. The RGB
> components must be above 0 and less than 255.

(I probably misunderstand but I would have assumed that it is
technically impossible to output values that are not within
these boundaries.)


> How would I use ffmpeg to correct the levels of the R, G and
> B components of YUV video?


What did you do (command line and complete, uncut console
output) to get output that you or EBu r103 did not like?

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: YUV RGB Video Levels

Chris-2
In reply to this post by Paul B Mahol
I'm having some success with this. r103 compliance is easier to achieve in the RGB domain than in the YUV domain.


-----Original Message-----
From: Paul B Mahol <[hidden email]>
To: FFmpeg user questions <[hidden email]>
Sent: Wed, Oct 24, 2018 1:09 pm
Subject: Re: [FFmpeg-user] YUV RGB Video Levels


On 10/24/18, Chris <[hidden email]> wrote:
> Depending on the primaries, it is possible to have YUV values which imply
> illegal RGB values, which may be what's being discussed here.
>
> That's what I'm trying to fix with ffmpeg :)
>
>

You probably want to use limiter video filter:

for 8bit videos:

limiter=min=16:max=235:planes=1,limiter=min=16:max=240:planes=6
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".