Skip to content

Commit 2180416

Browse files
committed
Add to info json output
1 parent 4e03e18 commit 2180416

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

auto_editor/formats/json.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ def read_v1(tl: Any, log: Log) -> v3:
178178
if type(chunks) is not list:
179179
log.error("chunks key must be an array")
180180

181-
do_bonk_chunk = False
182181
for i, chunk in enumerate(chunks):
183182
if type(chunk) is not list or len(chunk) != 3:
184183
log.error(f"Invalid chunk at chunk {i}")

auto_editor/make_layers.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ def run_interpreter_for_edit_option(
110110
return result
111111

112112

113+
def make_sane_timebase(fps: Fraction) -> Fraction:
114+
tb = round(fps, 2)
115+
ntsc = Fraction(30_000, 1001)
116+
film_ntsc = Fraction(24_000, 1001)
117+
if tb == round(ntsc, 2):
118+
return ntsc
119+
if tb == round(film_ntsc, 2):
120+
return film_ntsc
121+
return tb
122+
123+
113124
def make_timeline(
114125
sources: list[FileInfo],
115126
ffmpeg: FFmpeg,
@@ -125,16 +136,10 @@ def make_timeline(
125136
if inp is None:
126137
tb, res = Fraction(30), (1920, 1080)
127138
else:
128-
tb = round(inp.get_fps() if args.frame_rate is None else args.frame_rate, 2)
129-
ntsc = Fraction(30_000, 1001)
130-
film_ntsc = Fraction(24_000, 1001)
131-
if tb == round(ntsc, 2):
132-
tb = ntsc
133-
elif tb == round(film_ntsc, 2):
134-
tb = film_ntsc
135-
139+
tb = make_sane_timebase(
140+
inp.get_fps() if args.frame_rate is None else args.frame_rate
141+
)
136142
res = inp.get_res() if args.resolution is None else args.resolution
137-
138143
try:
139144
start_margin = time(args.margin[0], tb)
140145
end_margin = time(args.margin[1], tb)

auto_editor/subcommands/info.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from auto_editor.utils.func import aspect_ratio
1212
from auto_editor.utils.log import Log
1313
from auto_editor.vanparse import ArgumentParser
14+
from auto_editor.make_layers import make_sane_timebase
1415

1516

1617
@dataclass(slots=True)
@@ -108,6 +109,7 @@ def main(sys_args: list[str] = sys.argv[1:]) -> None:
108109

109110
file_info[file] = {
110111
"type": "media",
112+
"recommendedTimebase": "30/1",
111113
"video": [],
112114
"audio": [],
113115
"subtitle": [],
@@ -117,6 +119,10 @@ def main(sys_args: list[str] = sys.argv[1:]) -> None:
117119
},
118120
}
119121

122+
if src.videos:
123+
recTb = make_sane_timebase(src.videos[0].fps)
124+
file_info[file]["recommendedTimebase"] = f"{recTb.numerator}/{recTb.denominator}"
125+
120126
for track, v in enumerate(src.videos):
121127
w, h = v.width, v.height
122128

0 commit comments

Comments
 (0)