Hi,
I started using FFAStrans just a couple of days ago to do some transcoding, and I am already thinking that I could do a lot more with it than I initially imagined.
However, I stumbled into something that is proving more difficult to solve than I thought.
For each video that I process, I need to export the full length video and a trimmed version.
The trimmed version is cut based on frame ranges that are stored in a JSON file. The frame range always differs from file to file, but the values are stored into the above JSON file.
I thought that I could use a "command executor" to run a python script that reads the necessary frame range and sets the value of start and end frame user variables that I set at the beginning of the workflow.
However, is it possible to set a user variable value from a Python script running via a Command Executor, at all?
After the command executor I run a custom AviSynth script to do the trimming, but I am wondering whether I should already trim in the command executor. I would rather just use the command executor to set the user variable value to the desired start and end frame, if possible, but is that possible?
Thanks for any pointer!
Trimming based on arbitrary frame ranges from JSON file
Re: Trimming based on arbitrary frame ranges from JSON file
Hi amdx,
welcome to the Forum and thank you for using FFAStrans!
setting one variable from some cmd executed python script is pretty simple, you just use the "read std-stream" into variable in the cmd executor and in python just make sure you only print() the stuff you want to be contained in the variable. For all other stuff that your python script wants to "print", you can just use STDERR for example
or alternatively just use some logging module.
Another way would be to e.g. let ffastrans calculate the path to the output file that your python script should fill with the contents of your variable, hand it over to python script as parameter and read the file when the script is done. This is how plugin processors work.
In addition, there is a lot to say about trimming in general AND there has been some very recent changes in ffastrans in that direction, e.g. the encoding processors should now natively support ffconcat lists. The ffconcat stuff basically only works well with i-frame codecs, if you have such then i would recommend you to work into that direction (e.g. generate a ffconcat list from python and feed it back to ffastrans encoding)
welcome to the Forum and thank you for using FFAStrans!
setting one variable from some cmd executed python script is pretty simple, you just use the "read std-stream" into variable in the cmd executor and in python just make sure you only print() the stuff you want to be contained in the variable. For all other stuff that your python script wants to "print", you can just use STDERR for example
Code: Select all
sys.stderr.write("some log msg\n")
Another way would be to e.g. let ffastrans calculate the path to the output file that your python script should fill with the contents of your variable, hand it over to python script as parameter and read the file when the script is done. This is how plugin processors work.
In addition, there is a lot to say about trimming in general AND there has been some very recent changes in ffastrans in that direction, e.g. the encoding processors should now natively support ffconcat lists. The ffconcat stuff basically only works well with i-frame codecs, if you have such then i would recommend you to work into that direction (e.g. generate a ffconcat list from python and feed it back to ffastrans encoding)
emcodem, wrapping since 2009 you got the rhyme?
Re: Trimming based on arbitrary frame ranges from JSON file
Thank you very much!
sys.stderr.write worked. I think it was actually documented well enough, if only my eyes were open.
Is there a reason why enabling "show console" from the the command executor does not open the CMD prompt (Win10)?
Or am I expecting something that is not supposed to happen?
Also, thanks for the concat suggestion. I am actually a noob, so I would need to read more on this before being able to appreciate the potential of this solution.
Thank you!
sys.stderr.write worked. I think it was actually documented well enough, if only my eyes were open.
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Is there a reason why enabling "show console" from the the command executor does not open the CMD prompt (Win10)?
Or am I expecting something that is not supposed to happen?
Also, thanks for the concat suggestion. I am actually a noob, so I would need to read more on this before being able to appreciate the potential of this solution.
Thank you!
Re: Trimming based on arbitrary frame ranges from JSON file
Ah sorry i have overseen this!
Congrats on getting it working
I really should come up with a plugin processor example for python...
The reason why "show console" in cmd executor might not show a console is most likely explained as simple as "the process you start is not a console window". (or ffastrans is installed and runs as service)
Example:
This will not open any console, because you only start python.exe process and neither python.exe nor "myscript.py" starts any console.
This would show a console because you actually start a console process and hand over python and all the rest as parameter to this console process.
Regarding concat, there will be more tutorials in the upcoming versions![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Congrats on getting it working
![Smile :)](./images/smilies/icon_e_smile.gif)
The reason why "show console" in cmd executor might not show a console is most likely explained as simple as "the process you start is not a console window". (or ffastrans is installed and runs as service)
Example:
Code: Select all
python myscript.py "parameter1" "parameter2"
Code: Select all
cmd /C "python myscript.py "parameter1" "parameter2""
Regarding concat, there will be more tutorials in the upcoming versions
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
emcodem, wrapping since 2009 you got the rhyme?