#π Question about optimizing video encoding and other stuff.
8 messages Β· Page 1 of 1 (latest)
@lime wyvern
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
@echo off
:loop
set "SOURCE=%1"
set "BASE=%~n1"
set "TARGET=%BASE% upgraded.mp4"
set "QUALITY=%BASE% quality.mp4"
ffmpeg -i "%SOURCE%" -c:v hevc_nvenc -qp 17 -vf scale=1920x1080:flags=lanczos "%TARGET%"
ffmpeg -i "%SOURCE%" -i "%TARGET%" -c:v hevc_nvenc -qp 17 -filter_complex "[0]pad=iw:1080:0:(1080-ih)/2,hstack" "%QUALITY%"
shift
if not "%~1"=="" goto loop
og batch file
import pathlib
import os
import datetime
import subprocess
# Get the path to the current directory
current_directory = pathlib.Path.cwd()
files = list(current_directory.rglob("*.mp4"))
files.sort(key=lambda x: os.path.getmtime(x))
# List all files in the current directory
for file in files:
if file.is_file():
name = file.name
if file.suffix == ".mp4":
stat = file.stat()
ok = datetime.datetime.fromtimestamp(stat.st_mtime).strftime("%c")
source_file = str(file.name)
base_file = f"{file.stem} upgraded.mp4"
quality_file = f"{file.stem} quality.mp4"
subprocess.check_call(
[
"ffmpeg",
"-i",
source_file,
"-c:v",
"hevc_nvenc",
"-qp",
"17",
"-vf",
"scale=1920x1080:flags=lanczos",
base_file,
]
)
subprocess.check_call(
[
"ffmpeg",
"-i",
source_file,
"-i",
base_file,
"-c:v",
"hevc_nvenc",
"-qp",
"17",
"-filter_complex",
"[0]pad=iw:1080:0:(1080-ih)/2,hstack",
quality_file,
]
)
print("done")
import pathlib
@lime wyvern
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.