which is the best programing language with a library to write ffmpeg readable commands?
ffmpeg in python script - Stack Overflow
python - FFmpeg VS PyFFmpeg performance wise? - Stack Overflow
ffmpeg vs ffmpeg-python in requirements.txt
Videos
» pip install ffmpeg-python
I'm starting with fmpeg, currently I use it with python, I write the commands as if using the cli, and I create a subprocess to get the result.
But I'm already at a point where I write very long commands and it becomes difficult to read, maintain and reuse.
What is the best programming language with some library that allows me to write them in a way that is easier to read and maintain?
The idea would be to use that language only to write the ffmpeg scripts, either via api, stdout, and continue with python to read the result since I use a lot more things there than ffmpeg.
Thanks
From a brief look at FFMPY, you could do this using ffmpy.FFmpeg, as that allows any and all FFMPEG command line options, including -f. -- Click the link for documentation.
You could do the FFMPEG command with os.system. You'll need to import OS anyway to iterate through the files.
You would need to iterate through all the files in a directory though. This would be the more challenging bit, it's quite easy with a for loop though.
for filename in os.listdir(path):
if (filename.endswith(".mp4")): #or .avi, .mpeg, whatever.
os.system("ffmpeg -i {0} -f image2 -vf fps=fps=1 output%d.png".format(filename))
else:
continue
The above code iterates through the directory at path, and uses command prompt to execute your given FFMPEG command, using the filename (if it's a video file) in place of mymovie.avi
Dont have reputation to comment, hence adding another response.
Another version of ocelot's answer with the more readable f-string syntax of python -
for filename in os.listdir(path):
if (filename.endswith(".mp4")): #or .avi, .mpeg, whatever.
os.system(f'ffmpeg -i {filename} -f image2 -vf fps=fps=1 output%d.png')
else:
continue