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. |
![]() |
#21 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
so ... in VapourSynth we cheat and read properties from the first frame for simplicity. In Avisynth, any usage of frame properties must be in ScriptClip?
When you need to pass ColorRange to create a LUT table, or other complex filters, it's kind of a dead-end. Creating a LUT on every frame killed performance. For something simple like calling Tweak with the right coring parameter. |
![]() |
![]() |
![]() |
#22 | Link | |
Registered User
Join Date: Jul 2018
Posts: 351
|
Quote:
Code:
BlankClip() propset("_reba", 4) temp_dir = RT_GetSystemEnv("temp") + "\" + "temp.txt" ScriptClip(function [temp_dir] () { RT_TxtWriteFile(String(propGetInt("_reba")), temp_dir) last }) RT_AverageLuma(n=0, w=1, h=1) var = Value(RT_ReadTxtFromFile(temp_dir, 1, 0)) Subtitle(String(var)) ScriptClip(function [temp_dir] () { CallCmd(close="cmd /c del " + temp_dir, hide=true) }) Last edited by StvG; 15th October 2021 at 07:26. |
|
![]() |
![]() |
![]() |
#23 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,683
|
Nuttin' stopping you from something like this [the cheating stuff]
Code:
AviSource(...) current_frame = 0 x=Averageluma # or whatever frame property thingy ...
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
#24 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,683
|
This works
Code:
BlankClip() propset("_reba", 4) # ... # cheatin' stuff current_frame=0 # pretend frameserving in runtime filter var = propGetInt("_reba") Subtitle(String(var)) # EDIT: And then drop-though to frame serve to Player, Vdub etc
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 15th October 2021 at 10:08. |
![]() |
![]() |
![]() |
#25 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
I had written the VapourSynth code to respect per-frame color-range and matrix -- in the theoretical case that it could ever be useful.
But I came to the conclusion that in such rare case, you'd be better off running a filter that auto-splits the file into segments to process them individually, because nearly no filter would support respecting it per-frame anyway. And for theoretical or imaginary benefits, you pay a performance cost, and cannot use LUT or any hard-to-initialize filter based on frame property values. Is there any Input (video source) or Output (encoder/player) that supports variable matrix and range? |
![]() |
![]() |
![]() |
#26 | Link |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,576
|
Today I had a very bad behavior with frame properties.
A source encoded by a broadcast hardware recording port passed some dynamically changing metadata; in other words, they have been constant up to a certain point and then they changed 'cause the input stream into the port changed and the saved metadata in the file changed accordingly. When I indexed it with ffms3 and worked with the file inside Avisynth with several filters like dfttest etc it went through up to a certain point, then the encoding just stopped. It didn't crash, the RAM was still allocated, but the encoding just stopped, without any sign of moving/proceeding. I repeated the test over and over again, it was always stopping at the very same point. This happened with FFMpeg opening the Avisynth Script and encoding. I tried to re-encode the source in HuffYUV lossless with FFMpeg and then Index with ffms3 and encode, same behavior, stopped mid encode. I tried to re-encode the source in H.264 lossless with FFMpeg and then Index with ffms3 and encode, same behavior, stopped mid encode. I tried to re-encode the source in FFV1 lossless with FFMpeg and then Index with ffms3 and encode, same behavior, stopped mid encode. Then, I realized it could have been because of the dynamically changing metadata, so I re-encoded with FFMpeg in FFV1 lossless but stripping out the metadata like so: Code:
-c:v ffv1 -slicecrc 1 -c:a pcm_s24le -ac %i_a_channels% -pix_fmt yuv422p10le -map_metadata -1 -s %i_width%:%i_height% -ar 48000 So the question is: is there a way to make ffms3 ignore and strip out the metadata / frame properties entirely to prevent this kind of thing from happening and behave like the old good ffms2 + Avisynth 3.7.0? Last edited by FranceBB; 18th October 2021 at 15:24. |
![]() |
![]() |
![]() |
#27 | Link |
Broadcast Encoder
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,576
|
Nice one, StainlessS!
I'm reading about http://avisynth.nl/index.php/Internal_functions#propSet Looks like it works! So now the user is accountable to get and set the right frame properties for every encode every time. What a bummer DX Jokes aside, it works, this is an HDR PQ: Code:
FFVideoSource("\\mibctvan000\Ingest\MEDIA\temp\trim.m2ts") ![]() and this is after the conversion to HLG: Code:
FFVideoSource("\\mibctvan000\Ingest\MEDIA\temp\trim.m2ts") ConvertYUVtoLinearRGB(Color=0,OOTF=false) ConvertLinearRGBtoYUV(Color=0,HDRMode=1,HLGLw=1200,HLGColor=2,OOTF=false) propset("_Transfer", 18) propDelete("ContentLightLevelAverage") propDelete("MasteringDisplayMaxLuminance") propDelete("MasteringDisplayMinLuminance") propDelete("MasteringDisplayPrimariesX") propDelete("MasteringDisplayPrimariesY") propDelete("MasteringDisplayWhitePointX") propDelete("MasteringDisplayWhitePointY") propDelete("ContentLightLevelMax") ![]() So what is cool about this is that we CAN not only make use of the properties like automatizing tonemapping by reading the MaxCLL value and set it as a variable, but we can also pass the right info to whatever we're frameserving to so that it's gonna make use of those info. The "bummer" is that the user MUST set those correctly every time and has to do that manually... or... just cheat and turn Avisynth 3.7.1 into Avisynth 3.7.0 with: Code:
propClearAll() Last edited by FranceBB; 20th October 2021 at 18:08. |
![]() |
![]() |
![]() |
#28 | Link |
Useful n00b
Join Date: Jul 2014
Posts: 1,667
|
I'm trying to implement the AVS+ frame properties for DGDecodeNV but getting confused. I took avisynth.h and the avs folder from pinterf's GIT. I have in GetFrame():
PVideoFrame frame = env->NewVideoFrame(vi); Then I try to get props: AVSMap* props = m_decoder.has_at_least_v8 ? env->getFramePropsRW(frame) : nullptr; But there is an error because getFramePropsRW() wants an AVSFrameRef*. But I never heard of an AVSFrameRef. Can someone please straighten me out on how to do this? Thank you. |
![]() |
![]() |
![]() |
#29 | Link | |
Registered User
Join Date: Jan 2014
Posts: 2,239
|
Quote:
|
|
![]() |
![]() |
![]() |
#30 | Link |
Useful n00b
Join Date: Jul 2014
Posts: 1,667
|
Thank you, pinterf. I'll try that in the morning and report back.
There's one other matter I can work around but thought to mention. If I have a filter that supports VS and AVS, then I have to include both header files. But then they both define ptUnset etc. in enums, causing a compiler error. |
![]() |
![]() |
![]() |
#32 | Link | |
Useful n00b
Join Date: Jul 2014
Posts: 1,667
|
Quote:
|
|
![]() |
![]() |
![]() |
#34 | Link | |
Acid fr0g
Join Date: May 2002
Location: Italy
Posts: 2,359
|
Quote:
AFAIK, for now, it's easier to encode as if it is a CFR and then apply a timestamps file to MKV.
__________________
@turment on Telegram |
|
![]() |
![]() |
![]() |
#36 | Link | |
...?
Join Date: Nov 2005
Location: Florida
Posts: 1,377
|
Quote:
The logic for that would likely have to shift location significantly, probably out of avisynth_create_stream_video and into avisynth_read_packet_video, or constitute a hybrid where the current approach works in concert with whatever frame properties are set as overrides. It's largely the same reason that I didn't add the MasteringDisplay and whatnot properties - as those don't have to be static, making sure they're set right is trickier (also, AFAIK, FFmpeg doesn't set those as properties, but as side metadata, requiring a much larger amount of changes to even get the AviSynth demuxer to work with that concept to start with). Can it be done? Yeah, probably. It's currently above my head, though (and I rarely ever have to deal with VFR as it is, so ensuring it does what it's supposed to do would be up to the community). If someone wants to figure it out and contribute, by all means, have at it. |
|
![]() |
![]() |
![]() |
#37 | Link | ||||
...?
Join Date: Nov 2005
Location: Florida
Posts: 1,377
|
FFmpeg now supports reading two more frame properties - _SARNum and _SARDen, which are then combined into what FFmpeg reads as the full SAR value.
And because of how...tricky...that one would be when dealing with extraordinarily common resizing tasks, there is now a brand-new mechanism: Code:
>ffmpeg -hide_banner -h demuxer=avisynth Demuxer avisynth [AviSynth script]: Common extensions: avs. AviSynth demuxer AVOptions: -avisynth_flags <flags> .D......... set flags related to reading frame properties from script (AviSynth+ v3.7.1 or higher) (default field_order+range+primaries+transfer+matrix+chroma_location) field_order .D......... read field order range .D......... read color range primaries .D......... read color primaries transfer .D......... read color transfer characteristics matrix .D......... read matrix coefficients chroma_location .D......... read chroma location sar .D......... read sample aspect ratio >ffmpeg -hide_banner -loglevel 40 -i test_hdr.avs Quote:
>ffmpeg -hide_banner -loglevel 40 -avisynth_flags +sar-field_order-chroma_location -i test_hdr.avs Quote:
Quote:
Quote:
|
||||
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|