Created
February 1, 2026 05:52
-
-
Save dennyabrain/b5e88e2a22bf7740f50859c09942c3c3 to your computer and use it in GitHub Desktop.
Batch Processsing using FFMPEG in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import subprocess | |
| from pathlib import Path | |
| import os | |
| SOURCE_DIR = Path("../thumbnails") | |
| TARGET_DIR = Path("../thumbnails_avif") | |
| def main(): | |
| print("Beginning!") | |
| print(f"Source Directory Exists : {SOURCE_DIR.exists()}") | |
| print(f"Target Directory Exists : {TARGET_DIR.exists()}") | |
| for file in os.listdir(SOURCE_DIR): | |
| print(f"processing : {file}") | |
| file_id = file.split(".")[0] | |
| cmd = f"ffmpeg -i {SOURCE_DIR/file} -c:v libaom-av1 -still-picture 1 {TARGET_DIR/file}" | |
| subprocess.run(cmd, check=True, capture_output=True, text=True, shell=True) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment