Skip to content

Commit

Permalink
made compatible with linux and probably macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
NuperSu committed Apr 15, 2023
1 parent ae2ee80 commit 1cd69bd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import subprocess
import os
from multiprocessing import Pool, cpu_count
from pathlib import Path
from time import perf_counter
Expand All @@ -9,6 +10,12 @@
SLICES_DIR_PATH.mkdir(exist_ok=True)
PARTS_DIR_PATH.mkdir(exist_ok=True)

if os.name == 'nt':
ffmpeg = './ffmpeg.exe'
ffprobe = './ffprobe.exe'
else:
ffmpeg = 'ffmpeg'
ffprobe = 'ffprobe'

class Slice:
def __init__(self, slice_id: int):
Expand All @@ -33,7 +40,7 @@ def __repr__(self):
def get_duration(path: Path) -> float:
result = subprocess.run(
[
"./ffprobe.exe",
ffprobe,
"-v",
"error",
"-show_entries",
Expand Down Expand Up @@ -66,7 +73,7 @@ def slice_video(path: Path, start: float, end: float, output: Path):
# .\ffmpeg.exe -loglevel quiet -u -i $path -ss $start -to $end -c copy $output
subprocess.run(
[
"./ffmpeg.exe",
ffmpeg,
"-loglevel",
"quiet",
"-y",
Expand Down Expand Up @@ -105,7 +112,7 @@ def make_webm(video_slice: Slice, fps: int, part: Part):

subprocess.run(
[
"./ffmpeg.exe",
ffmpeg,
"-loglevel",
"quiet",
"-y",
Expand Down

0 comments on commit 1cd69bd

Please sign in to comment.