Changes

Jump to navigation Jump to search
m
no edit summary
Line 33: Line 33:     
==Usage==
 
==Usage==
FFmpeg needs to be run from the command line, but you can create batch scripts to automate the process for multiple files. You can also set up FFmpeg for Python: https://www.bannerbear.com/blog/how-to-use-ffmpeg-in-python-with-examples/
+
FFmpeg needs to be run from the command line, but you can create batch scripts to automate the process for multiple files. There is also a plugin for Python (https://pypi.org/project/ffmpeg-python/), but it is fairly limited so we recommend using subprocess instead (see example below).
    
The following are examples of conversions that we commonly use.
 
The following are examples of conversions that we commonly use.
Line 82: Line 82:  
===Batching===
 
===Batching===
 
The following is a batch script (text file with .bat file extension) that converts all .mp4 files in the specified folder to .avi:
 
The following is a batch script (text file with .bat file extension) that converts all .mp4 files in the specified folder to .avi:
<pre>@echo off
+
<syntaxhighlight lang="batch" overflow:auto;">@echo off
 
setlocal enabledelayedexpansion
 
setlocal enabledelayedexpansion
   Line 97: Line 97:     
pause
 
pause
</pre>
+
</syntaxhighlight >
 +
 
 +
===Python===
 +
<syntaxhighlight lang="python" overflow:auto;">import subprocess
 +
 
 +
inputFile = "input.mov"
 +
outputFile = "output.mp4"
 +
 
 +
subprocess.run(f'ffmpeg -i "{inputFile}" -vcodec h264 -b:v 8M "{outputFile}"')
 +
</syntaxhighlight >
    
==See Also==  
 
==See Also==  
 
* [[Video Codecs]]
 
* [[Video Codecs]]

Navigation menu