|
<< Click to Display Table of Contents >> Navigation: Nodes > Tasks > Render Engines > ffmpeg (calling a external CLI example) |
To execute the ffmpeg CLI.
This node provides a Python example about how to integrate external CLI programs with Mistika Workflows, by using the ffmpeg CLI as an example.
This node implements basic aspects for CLI integrations including multithreading support, parameter substitution, parsing node connectors into text parameters, adding parameter placeholders, and other common needs for interacting with CLI programs.
The ffmpeg program (the famous open source application) is provided just as a CLI example. An easy way to integrate other CLI programs can be to copy the Python code property of this node and just replace the executable path and other neccesary changes to suite your needs.
Input: Input files. They are made available to your command line via the [input] token.
Output: The new media files created by the ffmpeg call ( as long as the URL properties are correctly set to define the ffmpeg output paths)
Options:
DstExtension: The extension of the new media files to be produced by the command line. It needs to be declared because the new media will be created by an external application, so the node needs to know it in order to prepare the [output] token properly.
Threads: If more than one input media (UP) is available in the input connector then Mistika Workflows will execute one command line for each one in parallel, up to the maximum selected Threads. This is specially useful when the external application can not use all the available system resources (CPU cores...) with just one instance.
Note that this feature does not split jobs in a per-frame granularity. It can be used to process several movies or several enumerated sequences at the same time, but it can not be used to split an enumerated sequence into packets of frames (for doing such a thing please read the point about Executing workflows on external renderfarms
Parallel instances are only lunched when receiving a batch of media files from the input nodes (for example Watcher or Folder node containing a bunch of files on the same execution), but not for files received one by one on different executions of the input nodes.
cmdLineParams: The parameters to be passed to the ffmpeg binary in the command line. You can type parameters directly as needed, or you can reference parameter tokens between brackets [], such as [param1], [param2], [input] ....
The following tokens are pre-defined, you can use them in your command line:
[input]: Input media (UP) received by this node via the input connector
[input-firstFile]: typically used for enumerated sequences, it includes the name of the first file of an enumerated sequence or Universal Path.
[output]: This token is only valid if the output media to be created by the command line (in this example the ffmpeg command) can be obtained from the URL property above.
The whole path for the output folder will also be created if it does not exist yet, as other Workflows nodes can do.
param1 ... param8: Parameter placeholders. They produce tokens that can then be inserted between brackets ( [param1], [param2]...) in the cmdLineParams property
Examples:
Let's suppose that a media file /My Folder/My Media1.avi arrives to the input connector, and you set the node properties in the most simple (but not recommended) way:
cmdLineParams: -i [input] -codec:v mpeg4 -codec:a aac "/tmp/test1/My Media1.mp4"
That will execute this command line:
"Path To SGO Apps/Mistika Workflows/bin/ffmpeg" -i "/My Folder/My Media1.avi" "-codec:v mpeg4" "-codec:a aac" "/tmp/OutFolder/My Media1.mp4"
So in principle it will do the expected job (to transcode from avi to mp4), but it will not provide a proper integration with Mistika Workflows. The next example will produce an identical command line with a much better integration:
URL:
Name: From Input
Dest. Folder: /tmp/OutFolder
DstExtension: mp4
param1: -codec:v mpeg4
param2:-codec:a aac
cmdLineParams: -i [input] [param1] [param2] [output]
It will create a coherent [output] token (in this example "/tmp/OutFolder/My Media1.mp4" ) , and the output naming will still be coherent when changing the input media in posterior executions. The path for the new media will be automatically created, and then sent to posterior nodes via the output connector, as you would expect with any other node in Mistika Workflows:
Avoiding program dialogs: In practice, the real command line executed will have an extra parameter "-y", which means to auto-answer yes to all questions (being the most typical to confirm if you want to overwrite destination file...). For that purpose the -y parameter is hard coded in the python code.
This is supported by the ffmpeg CLI but please be aware that other CLI applications could not support it, and that you will need to ensure no questions are asked at execution time (otherwise the workflow will never finish.
You can detect this type of unexpected questions by executing Mistika Workflows in a console, in that way you should be able to see the standard output of external calls)
Property Label |
Property ID |
URL |
url |
Dst Extension |
dstExtension |
Threads |
threads |
Cmd Line Params |
cmdLineParams |
Param 1 |
param1 |
Param 2 |
param2 |
Param 3 |
param3 |
Param 4 |
param4 |
Param 5 |
param5 |
Param 6 |
param6 |
Param 7 |
param7 |
Param 8 |
param8 |