guillevent / video.machine Goto Github PK
View Code? Open in Web Editor NEWa tool to convert videos and edit them to share them with friends
a tool to convert videos and edit them to share them with friends
def make_brigther(IN, OUT): # https://video.stackexchange.com/questions/20962/ffmpeg-color-correction-gamma-brightness-and-saturation
subprocess.check_output(['ffmpeg','-i', IN, '-vf',"eq=gamma=1.5:saturation=1.0",'-c:a','copy',OUT])
https://developer.apple.com/documentation/videotoolbox
# Use VideoToolbox for hardware acceleration on macOS and iOS
if options['codec'] == "h264":
cmd.extend(["-c:v", "h264_videotoolbox", "-global_quality", str(your_quality_value)])
else:
cmd.extend(["-c:v", "hevc_videotoolbox", "-global_quality", str(your_quality_value)])
if you don't change the resolution 1080 but change the quality it will remove all files, the old and new. so critical
% python3 vidconv.py /Volumes/Fotos/GoPro/GOPRO-XMAS-23-24.12.22/XMAS-DELL --resolution 1080 --quality 3 --remove
[...]
INFO:root:- Input file: /Volumes/Fotos/GoPro/GOPRO-XMAS-23-24.12.22/XMAS-DELL/GX030018.MP4
INFO:root:GX030018.MP4
FILENAMES
/Volumes/Fotos/GoPro/GOPRO-XMAS-23-24.12.22/XMAS-DELL/GX030018.MP4
/Volumes/Fotos/GoPro/GOPRO-XMAS-23-24.12.22/XMAS-DELL/GX030018.mp4
parser.add_argument("--quality",type=int, default=13, choices=range(0, 52), help="Quality (integer-) value for encoding. Lower is better, but will produce bigger files. Range: [0-51]. Default is 13.")
Line 567 in 13cbe43
VIdeoToolbox from Apple could be used to accelerate bitrate and resolution conversion if redundantly giving the codec parameter as well.
This can be solved here:
Line 247 in 2ebd575
maintain gpx and subtitle data of the video.
investigate audio track and allow conversions:
parser.add_argument("--audio_codec", choices=["aac", "mp3", "opus"], default="aac", help="Audio codec to use.")
parser.add_argument("--channels", choices=["1", "2"], default="2", help="Number of audio channels.")
parser.add_argument("--audio_only", action="store_true", help="Extract audio track without converting video.")
Line 158 in 13cbe43
Line 167 in c0a61a5
import os
import argparse
import subprocess
import sys
import json
import logging
class VideoConverter:
VALID_VIDEO_EXTENSIONS = ['mp4', 'mkv', 'avi', 'mov']
BITRATES = {
'low': {'360': '700k', '480': '1200k', '720': '2500k', '1080': '5000k', '2160': '20000k'},
'mid': {'360': '1000k', '480': '1500k', '720': '4000k', '1080': '8000k', '2160': '35000k'},
'high': {'360': '1500k', '480': '1800k', '720': '6000k', '1080': '12000k', '2160': '50000k'}
}
def __init__(self, input_path, options):
self.input_path = input_path
self.options = options
logging.basicConfig(level=logging.INFO)
def get_video_info(self, input_file):
#... (same as before)
def should_process_video(self, input_file):
#... (same as before)
def prepare_strings_outfiles(self, in_file):
#... (same as before, but use self.options)
def run_ffmpeg_conversion(self, input_file, output_file):
#... (same as before, but use self.options)
def run_file(self, in_file):
#... (same as before, but use self.options)
def check_command_availability(self, command):
#... (same as before)
@classmethod
def cli(cls):
parser = argparse.ArgumentParser(description="Video Conversion Tool")
#... parser arguments as before
args = parser.parse_args()
options = {
'resolution': args.resolution,
'bitrate': args.bitrate,
#... other options
}
converter = cls(args.input_path, options)
if args.cut and len(args.cut) > 1 and args.length:
raise ValueError("Error: When providing a list for --cut, you cannot also provide --length. Length is to be used with a start-timestamp in --cut without end-stimestamp.")
converter.check_command_availability("ffmpeg")
converter.check_command_availability("ffprobe")
if os.path.isfile(converter.input_path):
converter.run_file(converter.input_path)
elif os.path.isdir(converter.input_path):
# If the remove option is set, ask for confirmation
if args.remove:
confirm = input(f"You are about to remove all files in the directory '{converter.input_path}' and its subdirectories. Are you sure? (then type yes or y): ")
if confirm.lower() not in ['yes','y']:
sys.exit("Operation aborted.")
for dirpath, dirnames, filenames in os.walk(converter.input_path):
for file in filenames:
full_path = os.path.join(dirpath, file)
converter.run_file(full_path)
else:
print("Invalid path. Please provide a valid video file or directory.")
if __name__ == "__main__":
VideoConverter.cli()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.