I would like to ask how to use variables in ffmpy (Python wrapper for FFmpeg).
To be exactly: I want to use variables to crop video. The FFmpeg command is:
ffmpeg in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4
https://ffmpeg.org/ffmpeg-filters.html#crop
To use it in Python/ffmpy, I wrote these codes:
from ffmpy import FFmpeg
import ffmpy
# define the variables
out_w = 100
out_h = 120
x = 50
y = 80
inputFile = "F:\\in.avi"
outputFile = "F:\\out.avi"
ff = FFmpeg(inputs = {inputFile: None}, outputs= {outputFile: " -y -filter:v `crop=100:120:50:80'"})
#This line works fine.
#Now rewrite the above line using variables...
ff = FFmpeg(inputs = {inputFile: None}, outputs={outputFile: " -y -filter:v `crop=out_w:out_h:x:y'"} )
#...It line does not work. I guess it is wrong to use variables in the statement.
#...This is my question. How to write this line using variables?
ff.cmd
ff.run()
Thanks for your help!