Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VapourSynth API Integration #24

Closed
wants to merge 7 commits into from

Conversation

animafps
Copy link
Contributor

@animafps animafps commented Apr 16, 2023

This no doubt will need to be rebased when done but just want to throw out a start while I have time as rustsynth is stable enough to do what its needed for this but if I eventually make breaking changes to the upstream API will update this accordingly.

Want to kinda keep all the modules of the python rewrites kinda equivalent to keep all bases covered for further customization/configuration

Feel free to add commits to this PR/Branch with help but keep this open until its functionally complete or minimum viable product

or can do in diff

Things to do:

  • flag while in development to compare new and old methods
  • VSDepth
  • LSMASH or ffms2 input
  • FrameInter
  • Flowblur?
  • NCNN-RIFE?
  • Progress ARC or MPSC channel (to main thread or a progress bar thread, can only be done from non script interp tho)
  • weighting
  • blur
  • masking
  • timescale
  • colourspace remapping
  • colourdepth changing
  • brightness, contrast and saturation
  • vsscript/vsscriptapi option and evaluation(this has not been tested by me through rustsynth but should function and the api is complete enough to do basic evaluation and output of nodes) {see yalter's vspipe which has a very similar wrapper api for ideas)
  • bundle dlls or .sos (need to figure out linker bullshit)
  • optimization of workflow

If need help with rustsynth api feel free to DM me or use the docs

@couleurm
Copy link
Member

Hey Anima, I appreciate you going ahead and actually bother to propose to implement your wrapper in my project

The two main things that hold me back with Rustsynth are:

  • How is error handling done?
  • Have you found a ways to directly pass maps to plugin calls, maybe via rust macros? I’ve had a hard time making hashmaps without structs

For development I don’t think it would be wise to ditch python completely, there could be two options to help support vpy scripts:

  • —vpy: Completely override the recommended filtering and generate and render a videonode from vpy path
  • —vpy-input: Instead of using a source indexer before the smoothie filtering, let the user have a pre/post « filter » .vpy script and then run it through smoothie’s own filtering

Direct VideoNode access will lead to us being able to manipulate output content easierly than a Y4M streams, see vspreview-rs, it also uses egui 😋.

I’d want to focus on working on render.rs to be able to evaluate vnodes from vpy paths before actually going and rewriting jamba and all of it’s dependencies, do what you like though 👍

@couleurm
Copy link
Member

We can start by making an « —rs-exp » clap bool arg which is checked in render.rs to know wether to use legacy vspipe_render or bleeding edge rustsynth trollery :trollface:

@animafps
Copy link
Contributor Author

animafps commented Apr 17, 2023

How is error handling done?

If a plugin function is called it will return the output OwnedMap then if call .error() will return an Option<Cow<'_, str>> with the error code set by the function/plugin or None if it successfully ran

For general vapoursynth functions the also follow but "normally" will just a return Result<(), something> (see api docs for specific functions) or will panic if its unrecoverable

Have you found a ways to directly pass maps to plugin calls, maybe via rust macros? I’ve had a hard time making hashmaps without structs

confused by this but assume you are meaning calls the keys and properties are not strictly defined before execution/ when writing. Which is pretty hard to deal with because everything is loaded at runtime and parsing would be a struggle

there is https://rustsynth.animafps.xyz/rustsynth/macro.owned_map.html and can use https://rustsynth.animafps.xyz/rustsynth/plugin/struct.PluginFunction.html#structfield.arguments which holds all the arguments for a function

if need any other macro for specifically calling or a trait to make a hashmap to a rustsynth map or proc-macro for a struct i could prob whip something up

@animafps animafps changed the title rustsynth VapourSynth API Apr 17, 2023
@animafps animafps changed the title VapourSynth API VapourSynth API Integration Apr 17, 2023
@animafps
Copy link
Contributor Author

—vpy-input: Instead of using a source indexer before the smoothie filtering, let the user have a pre/post « filter » .vpy script and then run it through smoothie’s own filtering

was thinking about this and

Its only really possible to send a node to vpy script as its designed to be a complete workflow but a pre script would work but still would pretty much make the api usage obsolete and then the whole workflow slow

but could put something together that writes the node uncompressed to a binary file then can pick it up in a script but would be slow writing and reading.

@couleurm
Copy link
Member

but could put something together that writes the node uncompressed to a binary file then can pick it up in a script but would be slow writing and reading.

if videonodes arent that flexible it's not even worth it then ig

@animafps
Copy link
Contributor Author

animafps commented Apr 18, 2023

if videonodes arent that flexible it's not even worth it then ig

huh? they are just script environments are not if you are working with nodes before evaluating a script

still good to give that kind of control to have a pre script but that might be a stretch goal

@animafps
Copy link
Contributor Author

Have you found a ways to directly pass maps to plugin calls, maybe via rust macros? I’ve had a hard time making hashmaps without structs

so now there is kinda a better way and more similar to vpy

https://rustsynth.animafps.xyz/rustsynth_derive/macro.init_plugins.html

@couleurm
Copy link
Member

couleurm commented Oct 7, 2023

i suppose this will stay dormant for a while until someone considers this relevant to implement.. 🤷

@animafps
Copy link
Contributor Author

animafps commented Oct 7, 2023

marking pr as stale and closing as i have no time to develop but the branch will be open if someone wants to work on it and need to improve rustsynth plugin/plugin invoke interface more before i feel comfortable with implementing it myself

@animafps animafps closed this Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants