NatronGitHub / Natron

Open-source video compositing software. Node-graph based. Similar in functionalities to Adobe After Effects and Nuke by The Foundry.
http://NatronGitHub.github.io
GNU General Public License v2.0
4.73k stars 344 forks source link

(Feature): outputFormat Width & Height must be made available as parameters #769

Open Praveen-Rai opened 2 years ago

Praveen-Rai commented 2 years ago

Make sure to follow our issue report guidelines

Provide a description of your feature request

Project Height and Width must be made available as individual parameters on the Project Settings page. Currently, they are just hidden away, and all we have is Combo-Box for Format Selection, and its corresponding "outputFormat" param. The param is of type "ChoiceParam", that does not support returning the currently selected options string value.

This will be very helpful for the users to :

Is this a realistically implementable feature?

Can you contribute in creating this feature?

Additional details

No response

tebicap commented 2 years ago

I want to make a progress-bar and it would be very useful to access width value of the output Format in order to adapt it to the screen.

devernay commented 2 years ago

what about that: https://natron.readthedocs.io/en/rb-2.4/devel/PythonReference/NatronEngine/Effect.html#NatronEngine.NatronEngine.Effect.getOutputFormat

devernay commented 2 years ago

As for the ChoiceParam, it does support returning the currently selected options string value:

tebicap commented 2 years ago

what about that: https://natron.readthedocs.io/en/rb-2.4/devel/PythonReference/NatronEngine/Effect.html#NatronEngine.NatronEngine.Effect.getOutputFormat

I'm on 2.4.1 , I got an error in the script editor and expressions editor playing with this: NatronEngine.ChoiceParam.getOption(frame).

Screenshot_20220217_234233

Am I doing something wrong? I'm really interested on getting the default width of the project.

devernay commented 2 years ago

it's get(frame), not getOption(frame). "frame" stands for a frame number. in this case, the parameter cannot be animated, so just use get() (see the doc and read the NEXT line)

getOption(index) takes the index returned by get()

I'm sorry, but maybe you should learn a bit of python before you try your hands at python scripting?

Praveen-Rai commented 2 years ago

As for the ChoiceParam, it does support returning the currently selected options string value:

Thanks for the pointers. Somehow I skipped the function, while scanning the docs. I tried it now, interestingly it return is different from the UI.

idx = app.getProjectParam("outputFormat").get()
ret = app.getProjectParam("outputFormat").getOption(idx)

#ret = "HD", while on the UI it is "HD 1920x1080" 

To me it appears, that the list that appears on UI concats formatName & frameDimensions, while internal list only holds formatName, which is what is returned by ChoiceParam.getOption(). To me it seems a bad design and needs a separate discussion of its own. In case, if this behavior was required, we must have another function that returns the exact values that appear on the display.

what about that: https://natron.readthedocs.io/en/rb-2.4/devel/PythonReference/NatronEngine/Effect.html#NatronEngine.NatronEngine.Effect.getOutputFormat

I am not very sure on this, and need a little more time to try it out. But my first impression is that I shouldn't be needing to go to Effects class to get the project properties. To my understanding, Project Settings are central to every effect and node. While effects might derive the settings from project, but users must not need to go to Effects to get project settings.

I am still looking at the Rectangle example, do not have any other effect / node into the project. Just want to align the rectangle, also to make it adaptable.

tebicap commented 2 years ago

I'm just starting with python but yes I have done a course. I got confused because frame provides the current frame in the expression editor. I apologize. thnks

devernay commented 2 years ago

You mean the Rectangle OFX plugin? Then you can use https://github.com/NatronGitHub/openfx/blob/master/Support/include/ofxsImageEffect.h#L1168 on your source clip

Praveen-Rai commented 2 years ago

You mean the Rectangle OFX plugin? Then you can use https://github.com/NatronGitHub/openfx/blob/master/Support/include/ofxsImageEffect.h#L1168 on your source clip

It's not really about any specific plugin. What we are expecting here is params that define project height and width.

Here's a look at how the change would look like on the UI.

ProjectSettings_New

Notice the added TextFields for Project Width & Height. Now these parameters can be used in Expressions , through-out the project & its nodes. This will immensely help in positioning elements.

# Pseudo-Code for the proposed project params

width = app.getProjectParam("Width")
height = app.getProjectParam("Height")

Further, I feel the entire Project Format Settings can be re-structured to something as below :

ProjectSettings_ReworkedFormat

In this case I have moved Frame-Rate to the project format . Which is what commonly used in video editors i.e. a format is a set of Height, Width, & Frame-Rate parameters. In the combo-box we can have an entry named "User Defined" or "Custom". Which signifies that the current project settings aren't selected from a pre-defined format. The "New Format" button, will copy the values from these text-fields to define a new format.

devernay commented 2 years ago

What is called "project format" is just the default format for generators and writers in the project. See the documentation/tooltip for this parameter: "The project format is used as the default workspace size for viewers, the default format for generators, and the default output format for writers. In most cases this should match your plate resolution."

This is probably not what you need.

Any code you write should use the actual format of a given node (including writers).

The format can be modified by any effect (see Reformat, Crop, and all Readers which default to the format in the file), and can be set explicitly by any Writer.

Which is what commonly used in video editors

Natron is not a video editor, that may be where the confusion comes from. It is a compositor, and thus handles many different sources of potentially different formats.

That being said, we welcome all contributions as pull requests, which are then reviewed and discussed.

devernay commented 2 years ago

Also note that the project format is normally set at the beginning of a project (see doc here: https://natron.readthedocs.io/en/rb-2.5/guide/compositing-projects-setup.html ) It is in general not advisable to change the project format after creating the graph, since it may have unexpected effects. It can be done, but should be done with care. For example, changing the FPS will only affect the viewer reading speed and the default FPS of video writers. In a video editor, one may expect this setting to "retime" the videos, but this is not the case in a compositor.

Praveen-Rai commented 2 years ago

Natron is not a video editor, that may be where the confusion comes from. It is a compositor, and thus handles many different sources of potentially different formats.

Thanks for the clarification. I get the point now, and will spend more time in understanding the concepts.

A few points I could quickly gather :

Regarding the contribution, I will be more than happy to contribute to code. But I couldn't at the moment since i am lacking understanding of QT and Natron Design. But will definitely try to update the docs. At the moment this issue is my 2 cents contribution to this project :-)