Skip to content

Stefanhodgman/videoCompressor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

videoCompressor

This script provides functionality to compress video files in a specified folder and its subfolders using the ffmpeg library. The user has an option to either overwrite the original videos with their compressed versions or save the compressed videos in a separate subfolder. Here's an in-depth description of the code: Imports: ffmpeg: A popular library for handling multimedia data, used here to obtain video duration and to compress the video. os: This module provides a way of using operating system-dependent functionality like reading or writing to the file system. shutil: This module provides a higher-level interface for file operations. Functions: get_video_duration(video_path) This function retrieves the duration of a video. ffmpeg.probe(video_path) probes the video file to fetch its metadata. The duration of the video is extracted from the metadata and returned. compress_videos(folder_location, convert_in_place) This function compresses all the .mp4 videos in a given folder and its subfolders. If the convert_in_place flag is False, it creates a converted subfolder in the specified folder location to store the compressed videos. It then walks through the folder and its subfolders to find .mp4 files. For each video file, it uses ffmpeg to compress the video with the specified settings. The compression settings specified are: Video codec (c:v): libx264 Preset: veryfast Constant rate factor (crf): 28 Audio bitrate (b:a): 64k Audio codec (c:a): aac Strictness: experimental If convert_in_place is True, it replaces the original video with its compressed version. Otherwise, it saves the compressed video in the converted subfolder. User Input & Execution: The script prompts the user for the folder location containing the videos. The user is also asked if they want to overwrite the original videos with their compressed versions (y) or save the compressed videos in a separate subfolder (n). Based on the user input, the compress_videos function is invoked to perform the video compression.

About

Compresses all video files in selected folder

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages