Skip to content

Commit 4e94e92

Browse files
committed
Fix exporting json to .mp4 files
1 parent 0c556a3 commit 4e94e92

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

auto_editor/edit.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030

3131
def set_output(
32-
out: str | None, _export: str | None, path: Path | None, log: Log
33-
) -> tuple[str, dict[str, Any]]:
32+
out: str | None, export: str | None, path: Path | None, log: Log
33+
) -> tuple[str, str]:
3434
if out is None or out == "-":
3535
if path is None:
3636
log.error("`--output` must be set.") # When a timeline file is the input.
@@ -42,33 +42,31 @@ def set_output(
4242
# Use `mp4` as the default, because it is most compatible.
4343
ext = ".mp4" if path is None else path.suffix
4444

45-
export: dict[str, Any]
46-
if _export is None:
45+
if export is None:
4746
match ext:
4847
case ".xml":
49-
export = {"export": "premiere"}
48+
export = "premiere"
5049
case ".fcpxml":
51-
export = {"export": "final-cut-pro"}
50+
export = "final-cut-pro"
5251
case ".mlt":
53-
export = {"export": "shotcut"}
52+
export = "shotcut"
5453
case ".json" | ".v1":
55-
export = {"export": "v1"}
54+
export = "v1"
5655
case ".v3":
57-
export = {"export": "v3"}
56+
export = "v3"
5857
case _:
59-
export = {"export": "default"}
60-
else:
61-
export = parse_export(_export, log)
58+
export = "default"
6259

63-
match export["export"]:
60+
match export:
6461
case "premiere" | "resolve-fcp7":
6562
ext = ".xml"
6663
case "final-cut-pro" | "resolve":
6764
ext = ".fcpxml"
6865
case "shotcut":
6966
ext = ".mlt"
7067
case "v1":
71-
ext = ".v1"
68+
if ext != ".json":
69+
ext = ".v1"
7270
case "v3":
7371
ext = ".v3"
7472

@@ -186,9 +184,13 @@ def edit_media(paths: list[str], args: Args, log: Log) -> None:
186184
src = sources[0]
187185
use_path = src.path
188186

189-
output, export_ops = set_output(args.output, args.export, use_path, log)
190-
assert "export" in export_ops
191-
export = export_ops["export"]
187+
if args.export is None:
188+
output, export = set_output(args.output, args.export, use_path, log)
189+
export_ops: dict[str, Any] = {"export": export}
190+
else:
191+
export_ops = parse_export(args.export, log)
192+
export = export_ops["export"]
193+
output, _ = set_output(args.output, export, use_path, log)
192194

193195
if output == "-":
194196
# When printing to stdout, silence all logs.

0 commit comments

Comments
 (0)