FFmpeg icon indicating copy to clipboard operation
FFmpeg copied to clipboard

Support film grain

Open 6ws opened this issue 1 year ago • 17 comments

VVenC is now capable of producing bitstreams with FGC SEI messaging.

6ws avatar Jul 27 '24 00:07 6ws

@6ws, could you provide a command line or clips for this? @QSXW, could you help implement SEI functions? We can start with this and implement all SEIs similarly to HEVC.

nuomi2021 avatar Jul 27 '24 02:07 nuomi2021

When compiled from the master branch, it can be enabled via vvencapp by --fga, or when linked against FFmpeg, by -vvenc-params "FGA=1".

station2_1080p25_VVC_FGA.mp4

6ws avatar Jul 27 '24 05:07 6ws

@6ws, could you provide a command line or clips for this? @QSXW, could you help implement SEI functions? We can start with this and implement all SEIs similarly to HEVC.

Sure. I will help support this.

QSXW avatar Jul 27 '24 17:07 QSXW

When compiled from the master branch, it can be enabled via vvencapp by --fga, or when linked against FFmpeg, by -vvenc-params "FGA=1".

station2_1080p25_VVC_FGA.mp4

Hi. I cannot open the link. Can you help a check?

QSXW avatar Jul 27 '24 18:07 QSXW

Try right clicking the link and "Save as". If that doesn't work, I uploaded the raw VVC stream instead.

station2_1080p25_VVC_FGA.266

6ws avatar Jul 27 '24 21:07 6ws

Hi @6ws. I've added the ability to decode film grain characteristic SEI NAL for VVC. The final thing is to verify if it works like HEVC. Do you also have a sample of the HEVC clip with film grain SEI?

QSXW avatar Jul 30 '24 19:07 QSXW

Maybe @nuomi2021 has conformance clips? HEVC with FGC is new and I am unaware of a way to generate streams outside the reference encoder.

6ws avatar Jul 31 '24 01:07 6ws

not sure too. maybe you can refer to av1, I guess AV1 has this feature too

nuomi2021 avatar Aug 01 '24 12:08 nuomi2021

Hi, @nuomi2021. Where is the best location to apply the film grain filter, which should be used on the frame decoded? The hevc and h264 apply it when the frame end, but looks like we don't have a frame end.

QSXW avatar Aug 02 '24 20:08 QSXW

in submit_frame before ff_vvc_frame_submit. is a good place. I guess hw codec will add some code there just like hevc.

nuomi2021 avatar Aug 03 '24 12:08 nuomi2021

in submit_frame before ff_vvc_frame_submit. is a good place. I guess hw codec will add some code there just like hevc.

Maybe not? It needs the frame that has been decoded. I tried and it doesn't work.

QSXW avatar Aug 05 '24 15:08 QSXW

Hi @6ws. I've added the support for film grain !257 here. Would you have a try and help review the changes?

QSXW avatar Aug 06 '24 18:08 QSXW

@QSXW I am getting build errors. Can you rebase against upstream FFmpeg? Thanks.

6ws avatar Aug 08 '24 00:08 6ws

@6ws . Sure. Done!

QSXW avatar Aug 08 '24 18:08 QSXW

[vvc @ 000001fb955b06c0] Unsupported film grain parameters. Ignoring film grain. The film grain is still applied despite the warning. Unfortunately, the hashing of the decoded data does not match.

6ws avatar Aug 09 '24 03:08 6ws

Hi @6ws. I've added the breakpoint and tried to decode station2_1080p25_VVC_FGA.mp4 and the film grain by decoder doesn't seem to be applied. Can you check again?

Unfortunately, the hashing of the decoded data does not match. Do you use the md5 to generate the hash? Is the hash generated after the film grain stage or before?

QSXW avatar Aug 10 '24 13:08 QSXW

The film grain is still applied despite the warning. Unfortunately, the hashing of the decoded data does not match.

Film grain, much like a filter, is usually not defined in the spec. As a result, different implementations may produce varying outputs.

nuomi2021 avatar Aug 11 '24 14:08 nuomi2021

sorry for the long waiting @6ws

nuomi2021 avatar May 31 '25 12:05 nuomi2021