Log in

View Full Version : How to encode archival quality from RGB source?


pancserzso
14th October 2013, 23:42
I have finished a project, in which I rendered RGB images using a computer program, thus, my source is 100% clean RGB images.

I would like to encode for archiving. I was thinking about either using YV24 or RGB mode in Avisynth.

The Avisynth part is OK, and thanks to the amazing help I received in this thread, I can use all filters in RGB mode: http://forum.doom9.org/showthread.php?p=1647102

The part which I do not know is how to encode it in the best possible quality. I was thinking about either using ProRes 4444 or some uncompressed Quicktime codec. I know x264 even supports RGB mode, but I don't know if it's possible to play it back on a Mac.

Playback on a Mac is important, as I need to give it to someone who only has Macs, so I have to use some format which is widely supported on Macs. This is why I was thinking about using ProRes 4444, but I'm open for alternative suggestions.

Do you know if it is possible to encode YV24 Avisynth file to ProRes 4444 without color conversion? Or should I use an alternative codec?

poisondeathray
15th October 2013, 01:09
If you use VLC or MPlayerOSX Extended, you can play just about anything on a Mac - so the real question is if you need it to play in Quicktime related applications

You can encode YV24 to Prores4444 using ffmbc or ffmpeg - if you do that you shouldn't go back to RGB and then to YV24. You should go straight to YV24 after applying YV12 filters to each channel.

The other options for quicktime compatibility are PNG in MOV, and Quicktime Animation codec (MOV) . The latter isn't very compressed and you will be left with huge filesizes

pancserzso
15th October 2013, 01:16
Thanks! I've researched a bit and found that ProRes 4444 is the best option for me.

Here is my script (RGB -> R, G, B -> YV24 processing)
main = last

main.showred("YV12")
d = 2
a1 = RemoveGrain (4).RemoveGrain (12)
a = a1.TemporalSoften (4, 25, 25, 15, 2)
sup_a = a.MSuper ()
vec = sup_a.MAnalyse (multi=true, delta=d, blksize=8, overlap=4, search=5, searchparam=4, DCT=5)
sup = MSuper (levels=1)
MDegrainN (sup, vec, d, thSAD=800)
r = last

main.showgreen("YV12")
d = 2
a1 = RemoveGrain (4).RemoveGrain (12)
a = a1.TemporalSoften (4, 25, 25, 15, 2)
sup_a = a.MSuper ()
vec = sup_a.MAnalyse (multi=true, delta=d, blksize=8, overlap=4, search=5, searchparam=4, DCT=5)
sup = MSuper (levels=1)
MDegrainN (sup, vec, d, thSAD=800)
g = last

main.showblue("YV12")
d = 2
a1 = RemoveGrain (4).RemoveGrain (12)
a = a1.TemporalSoften (4, 25, 25, 15, 2)
sup_a = a.MSuper ()
vec = sup_a.MAnalyse (multi=true, delta=d, blksize=8, overlap=4, search=5, searchparam=4, DCT=5)
sup = MSuper (levels=1)
MDegrainN (sup, vec, d, thSAD=800)
b = last

mergergb(r,g,b)

ConvertToYV24(matrix="Rec709")

And my encoding command line:
ffmbc -i yv24-test.avs -vcodec prores -y -pix_fmt yuv444p10le yv24-test.mov

Although I think it doesn't matter here, I'd be still interested if I can still do YV24 split and merge, like I can do RGB split and merge, as I've just asked in the RGB thread.

Do you think the command line encoding is OK like this, or I need to specify color primaries, like I do for x264 "--colorprim "bt709" --transfer "bt709" --colormatrix "bt709"?

poisondeathray
15th October 2013, 01:39
commandline looks ok , but no audio ?

Also you can change the quality of prores encoding with -qscale I think it is in ffmbc, it might be differnt in ffmpeg

You don't need to specify those colorprim, tranfer, colormatrix

I posted an example of YV24 split to Y,U,V in the other thread

pancserzso
15th October 2013, 01:47
commandline looks ok , but no audio ?

Also you can change the quality of prores encoding with -qscale I think it is in ffmbc, it might be differnt in ffmpeg

You don't need to specify those colorprim, tranfer, colormatrix

I posted an example of YV24 split to Y,U,V in the other thread

Thanks a lot for both! I'll do the audio in a separate run, and mux them later.

Actually, I realised that the best workflow is to just
1. Process everything in R,G,B channels
2. ImageWrite it out to an RGB24 PNG sequence. The trick here is to use something like avs2avi filtering.avs -o n -c null to generate all the files.
3. Do the separate conversions by ImageSource-ing that sequence

This way I only have to wait once and later on the subsequent conversions (x264, ffmbc, etc.) will run much faster.

Here is my final script, just for reference:

ImageSource("Comp 1_%05d.png", 0, 7199, 24,pixel_type="RGB24")

main = last

main.showred("YV12")
d = 2
a1 = RemoveGrain (4).RemoveGrain (12)
a = a1.TemporalSoften (4, 25, 25, 15, 2)
sup_a = a.MSuper ()
vec = sup_a.MAnalyse (multi=true, delta=d, blksize=8, overlap=4, search=5, searchparam=4, DCT=5)
sup = MSuper (levels=1)
MDegrainN (sup, vec, d, thSAD=800)
r = last

main.showgreen("YV12")
d = 2
a1 = RemoveGrain (4).RemoveGrain (12)
a = a1.TemporalSoften (4, 25, 25, 15, 2)
sup_a = a.MSuper ()
vec = sup_a.MAnalyse (multi=true, delta=d, blksize=8, overlap=4, search=5, searchparam=4, DCT=5)
sup = MSuper (levels=1)
MDegrainN (sup, vec, d, thSAD=800)
g = last

main.showblue("YV12")
d = 2
a1 = RemoveGrain (4).RemoveGrain (12)
a = a1.TemporalSoften (4, 25, 25, 15, 2)
sup_a = a.MSuper ()
vec = sup_a.MAnalyse (multi=true, delta=d, blksize=8, overlap=4, search=5, searchparam=4, DCT=5)
sup = MSuper (levels=1)
MDegrainN (sup, vec, d, thSAD=800)
b = last

mergergb(r,g,b, "RGB24")

ImageWriter(file="e:\docs\filtered_fruits\",type="png")

poisondeathray
15th October 2013, 01:57
So you are exporting a png sequence with imagewriter() as a temporary lossless RGB intermediate ?

Then feeding that png sequence into whatever encoder for the final format ?

The (small) problem with that if you're final format goal is ProRes4444 in YUV is you're going RGB=>YUV=>RGB=>YUV ; but it's avoidable quality loss

If you want speed, something like UT Video Codec for the lossless intermediate stage will be faster encoding and decoding (and thus faster final encoding too) than a PNG sequence

pancserzso
15th October 2013, 02:02
So you are exporting a png sequence with imagewriter() as a temporary lossless RGB intermediate ?

The (small) problem with that if you're final format goal is ProRes4444 in YUV is you're going RGB=>YUV=>RGB=>YUV ; but it's avoidable quality loss

If you want speed, something like UT Video Codec for the lossless intermediate stage will be faster encoding and decoding (and thus faster final encoding too) than a PNG sequence

As detailed here (http://forum.doom9.org/showthread.php?p=1647920#post1647920), this is actually not a RGB => YUV => RGB conversion, but a lossless hack to make YV scripts process RGB source.

So I believe my conversions is RGB =lossless> RGB =lossless> RGB => YV24, which seems really high quality for me.

Yes, UT Video is much faster, but in my experience the intermediate will be much bigger than PNG. This way I can also save the PNG sequence for future use.

Also, I wouldn't feed the image sequence directly to the encoder, but through an avs script like this:

ImageSource("%05d.png", 0, 7199, 24,pixel_type="RGB24")
ConvertToYV24(matrix="Rec709")

poisondeathray
15th October 2013, 03:21
There is a prores4444 RGBA variant on the Mac (not YUV), does anyone know if ffmpeg/ffmbc is capable of it ?