From c098ab1be0673051939b24741aee42d2a63d11dd Mon Sep 17 00:00:00 2001 From: WyattBlue Date: Wed, 6 Mar 2024 02:30:49 -0500 Subject: [PATCH] Don't need ffmpeg for reading json --- auto_editor/edit.py | 2 +- auto_editor/formats/json.py | 12 ++++++------ auto_editor/subcommands/info.py | 13 ++----------- auto_editor/subcommands/test.py | 2 +- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/auto_editor/edit.py b/auto_editor/edit.py index d654c05f0..0b3dd50f0 100644 --- a/auto_editor/edit.py +++ b/auto_editor/edit.py @@ -177,7 +177,7 @@ def edit_media( elif path_ext == ".json": from auto_editor.formats.json import read_json - tl = read_json(paths[0], ffmpeg, log) + tl = read_json(paths[0], log) sources = [] if tl.src is None else [tl.src] src = tl.src else: diff --git a/auto_editor/formats/json.py b/auto_editor/formats/json.py index fcc31b6fa..9e7e745d3 100644 --- a/auto_editor/formats/json.py +++ b/auto_editor/formats/json.py @@ -6,7 +6,7 @@ from fractions import Fraction from typing import Any -from auto_editor.ffwrapper import FFmpeg, FileInfo, initFileInfo +from auto_editor.ffwrapper import FileInfo, initFileInfo from auto_editor.lang.json import Lexer, Parser, dump from auto_editor.lib.err import MyError from auto_editor.timeline import ( @@ -42,7 +42,7 @@ def check_file(path: str, log: Log) -> None: log.error(f"Could not locate media file: '{path}'") -def read_v3(tl: Any, ffmpeg: FFmpeg, log: Log) -> v3: +def read_v3(tl: Any, log: Log) -> v3: check_attrs( tl, log, @@ -158,7 +158,7 @@ def parse_obj(obj: dict[str, Any], build: pAttrs) -> dict[str, Any]: return v3(src, tb, sr, res, bg, v, a, v1=None) -def read_v1(tl: Any, ffmpeg: FFmpeg, log: Log) -> v3: +def read_v1(tl: Any, log: Log) -> v3: from auto_editor.make_layers import clipify check_attrs(tl, log, "source", "chunks") @@ -194,7 +194,7 @@ def read_v1(tl: Any, ffmpeg: FFmpeg, log: Log) -> v3: ) -def read_json(path: str, ffmpeg: FFmpeg, log: Log) -> v3: +def read_json(path: str, log: Log) -> v3: with open(path, encoding="utf-8", errors="ignore") as f: try: tl = Parser(Lexer(path, f)).expr() @@ -206,9 +206,9 @@ def read_json(path: str, ffmpeg: FFmpeg, log: Log) -> v3: ver = tl["version"] if ver == "3": - return read_v3(tl, ffmpeg, log) + return read_v3(tl, log) if ver == "1": - return read_v1(tl, ffmpeg, log) + return read_v1(tl, log) if type(ver) is not str: log.error("version needs to be a string") log.error(f"Importing version {ver} timelines is not supported.") diff --git a/auto_editor/subcommands/info.py b/auto_editor/subcommands/info.py index 73df259b7..c5bda19f2 100644 --- a/auto_editor/subcommands/info.py +++ b/auto_editor/subcommands/info.py @@ -5,7 +5,7 @@ from dataclasses import dataclass, field from typing import Any, Literal, TypedDict -from auto_editor.ffwrapper import FFmpeg, initFileInfo +from auto_editor.ffwrapper import initFileInfo from auto_editor.lang.json import dump from auto_editor.timeline import v3 from auto_editor.utils.func import aspect_ratio @@ -16,8 +16,6 @@ @dataclass(slots=True) class InfoArgs: json: bool = False - ffmpeg_location: str | None = None - my_ffmpeg: bool = False help: bool = False input: list[str] = field(default_factory=list) @@ -25,12 +23,6 @@ class InfoArgs: def info_options(parser: ArgumentParser) -> ArgumentParser: parser.add_required("input", nargs="*") parser.add_argument("--json", flag=True, help="Export info in JSON format") - parser.add_argument("--ffmpeg-location", help="Point to your custom ffmpeg file") - parser.add_argument( - "--my-ffmpeg", - flag=True, - help="Use the ffmpeg on your PATH instead of the one packaged", - ) return parser @@ -83,7 +75,6 @@ class MediaJson(TypedDict, total=False): def main(sys_args: list[str] = sys.argv[1:]) -> None: args = info_options(ArgumentParser("info")).parse_args(InfoArgs, sys_args) - ffmpeg = FFmpeg(args.ffmpeg_location, args.my_ffmpeg) log = Log(quiet=not args.json) file_info: dict[str, MediaJson] = {} @@ -96,7 +87,7 @@ def main(sys_args: list[str] = sys.argv[1:]) -> None: if ext == ".json": from auto_editor.formats.json import read_json - tl = read_json(file, ffmpeg, log) + tl = read_json(file, log) file_info[file] = {"type": "timeline"} file_info[file]["version"] = "v3" if isinstance(tl, v3) else "v1" diff --git a/auto_editor/subcommands/test.py b/auto_editor/subcommands/test.py index eb1e6df2e..89085ef70 100644 --- a/auto_editor/subcommands/test.py +++ b/auto_editor/subcommands/test.py @@ -13,7 +13,7 @@ import numpy as np -from auto_editor.ffwrapper import FFmpeg, FileInfo, initFileInfo +from auto_editor.ffwrapper import FileInfo, initFileInfo from auto_editor.lang.palet import Lexer, Parser, env, interpret from auto_editor.lib.data_structs import Char from auto_editor.lib.err import MyError