GithubHelp home page GithubHelp logo

video.machine's People

Contributors

guillevent avatar

Watchers

 avatar

video.machine's Issues

--brightness

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])

Critical bug in new filename strings

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

change default

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.")

conv:maintain other tracks

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.")

conv:make class

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()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.