Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th April 2014, 08:05   #1  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,779
From 16bit TIFFs to Y4M for x265?

I would like to create a Y4M file from a sequence of 16-bit-per-component (48 bit RGB) raw TIFF images for encoding in x265 with enabled HIGH_BIT_DEPTH flag.

Is this possible at all via AviSynth 2.6 and one of the AVS piping tools? Would ImageSource be able to read them as either TIFF or other 48 bit images? I rather doubt, it would have to be read as stacked LSB/MSB clip probably. ImmaSource won't handle that either. May one better try to make a specific converter without AviSynth being involved?

Samples can be found in e.g. http://media.xiph.org/tearsofsteel/t...steel-4k-tiff/ or for other Blender movies.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 17th April 2014, 01:26   #2  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
I'd work in vapoursynth, using VS-lsmashsource's LWLibavSource to load the TIFFs with format YUV420P16, then use fmtconv to sample it down to YUV420P10. You can use ffmpeg to write it out to y4m.

Note that x265 does not yet support reading from high-bit y4m, although that was discussed a month or two ago on the mailing list. You'll have to use raw YUV, or pipe the y4m through ffmpeg, either way specifying all of the video metadata manually. (And in that case, you might as well keep the raw TIFFs around unless it's just easier to work with a single file.)
foxyshadis is offline   Reply With Quote
Old 23rd July 2015, 12:23   #3  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,779
Coming back to this topic, now that x265 would support even Main12 profile ... which would be the recommended way now to use e.g. a subset of 16 bit-per-component TIFFs in 4K resolution from "Tears of Steel" I downloaded (frames 11270 to 12709 "graded_edit_%05d.tif", matching 60 seconds of scenes with different degrees of action)? I never used VapourSynth yet, a brief guide regarding possible quirks would be very welcome.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 23rd July 2015, 12:55   #4  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Should be something like the following:
Code:
import vapoursynth as vs
core = vs.get_core()
ret = core.imwri.Read('graded_edit_%05d.tiff')
ret = core.fmtc.bitdepth(clip=ret, bits=12)
ret.set_output()
Then pipe as y4m:
vspipe --y4m script.vpy - | x265 - --y4m -o output.265

But somehow I don't have the ImageMagick plugin. I wonder if it's missing in the R27 installer?
http://forum.doom9.org/showthread.ph...96#post1731196
sneaker_ger is offline   Reply With Quote
Old 23rd July 2015, 13:02   #5  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,779
Just about to download; r27 is a lot smaller than r26. I'll compare the content...
__

Quote:
Originally Posted by Myrsloik View Post
It's not included and never will be due to its insane size.
... but here seems to be a download link to DropBox.
__

OK, after installing imwri and fmtconv plugins, and studying the documentation a bit to get around several different error messages, I made my script up to the point that x265 accepts the incoming video stream and starts encoding...

tos_60s.vpy
Code:
import vapoursynth as vs
core = vs.get_core()
ret = core.imwri.Read('graded_edit_%05d.tif', firstnum=11270)
ret = core.std.AssumeFPS(clip=ret, fpsnum=24)
ret = core.fmtc.matrix (clip=ret, mat="709", col_fam=vs.YUV, bits=16)
ret = core.fmtc.resample (clip=ret, css="420")
ret = core.fmtc.bitdepth(clip=ret, bits=12)
ret.set_output()
tos_60s.vpy.bat
Code:
E:\Programme\VapourSynth\core64\vspipe --y4m tos_60s.vpy - | E:\Programme\x265\x265 - -D 12 --y4m -o tos_60s.vpy.hevc
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid

Last edited by LigH; 23rd July 2015 at 13:50.
LigH is offline   Reply With Quote
Old 23rd July 2015, 13:38   #6  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Well, unless you can compile ImageMagick and get it running yourself there don't seem to be many options left.
ffms2: fails on those tifs?
vsimagesource: deprecated
lsmash: needs start filename at 1 (or 0?), not 11270. (you could rename with a different program first). Crashes for me once I load for than 1 file, though.

As suggested by foxyshadis using lsmash:
Code:
import vapoursynth as vs
core = vs.get_core()
ret = core.lsmas.LWLibavSource('graded_edit_%05d.tif', format="YUV444P16")
ret = core.fmtc.matrix(clip=ret, mats="601", matd="709") #in case lsmash assumes BT.601 and you want BT.709
ret = core.fmtc.resample(clip=ret, css="420") #if you want 4:2:0 sampling
ret = core.fmtc.bitdepth(clip=ret, bits=12)
ret.set_output()
Lsmash does not seem to be able to output RGB48 for some reason so the YUV444P16 conversion can't be avoided although I don't trust it and it may be assuming BT.601.
sneaker_ger is offline   Reply With Quote
Old 23rd July 2015, 13:52   #7  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Quote:
Originally Posted by LigH View Post
OK, after installing imwri and fmtconv plugins, and studying the documentation a bit to get around several different error messages, I made my script up to the point that x265 accepts the incoming video stream and starts encoding
Yeah, I just saw that test6 is still compatible. Your script looks good. (Only "bits=16" is unnecessary.)
sneaker_ger is offline   Reply With Quote
Old 23rd July 2015, 13:52   #8  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,779
If I am not completely wrong, this is how to downscale to 720p in YUV444p16 and output as YUV420p12 eventually:

Code:
import vapoursynth as vs
core = vs.get_core()
ret = core.imwri.Read('graded_edit_%05d.tif', firstnum=11270)
ret = core.std.AssumeFPS(clip=ret, fpsnum=24)
ret = core.fmtc.matrix (clip=ret, mat="709", col_fam=vs.YUV, bits=16)
ret = core.resize.Spline(clip=ret, width=1280, height=536)
ret = core.std.AddBorders(clip=ret, top=92, bottom=92)
ret = core.fmtc.resample (clip=ret, css="420")
ret = core.fmtc.bitdepth(clip=ret, bits=12)
ret.set_output()
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 23rd July 2015, 14:10   #9  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Yes, but fmtc.resample can also do resizing:
Code:
import vapoursynth as vs
core = vs.get_core()
ret = core.imwri.Read('graded_edit_%05d.tif', firstnum=11270)
ret = core.std.AssumeFPS(clip=ret, fpsnum=24)
ret = core.fmtc.matrix (clip=ret, mat="709", col_fam=vs.YUV)
ret = core.fmtc.resample (clip=ret, w=1280, h=536, css="420")
ret = core.fmtc.bitdepth(clip=ret, bits=12)
ret = core.std.AddBorders(clip=ret, top=92, bottom=92)
ret.set_output()
I would always do adding borders last. Quality might be improved by leaving full range->limited range to fmtc.bitdepth step and do 32 bit float in-between but I assume the difference will be negligible.
sneaker_ger is offline   Reply With Quote
Old 23rd July 2015, 15:26   #10  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,779
Despite all pessimism I heard about HEVC decoders not yet supporting Main12 ... no, I believe it was rather x265 not yet producing correct bitstreams. With x265 v1.7+367, it looks actually pretty well in MPC-HC 1.7.9 (just the colors appear a bit ... "vivid"):

tos_60s_720p_main12.vpy.hevc.mp4 (11 MB)
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid

Last edited by LigH; 23rd July 2015 at 15:28.
LigH is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:56.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.