Skip to content

Effort free video editing!

Reject unusable ease durations and report unreadable timelines

WyattBluee4fbb200e6d0
diff --git a/src/action.nim b/src/action.nim
index c05ff4b7..69cdd62a 100644
--- a/src/action.nim
+++ b/src/action.nim
@@ -446,8 +446,13 @@ proc parseDuration(spec: string): (float32, DurUnit) {.raises: [ActionParseError
let n =
try: parseFloat(num)
except ValueError: raise newException(ActionParseError, &"Invalid duration: {spec}")
- if tu == tuFrames: (n.float32, duFrames)
- else: (float32(n * tu.seconds), duSec)
+ result =
+ if tu == tuFrames: (n.float32, duFrames)
+ else: (float32(n * tu.seconds), duSec)
+ # `not (a and b)` so NaN fails too; inf would write a timeline that can't
+ # be read back.
+ if not (result[0] >= 0 and result[0] < Inf):
+ raise newException(ActionParseError, &"Duration can't be negative or infinite: {spec}")
proc parseKfTime(spec: string): KfTime {.raises: [ActionParseError].} =
## "50%" -> percent of the section; otherwise a duration, as parseDuration.
diff --git a/src/conductor.nim b/src/conductor.nim
index 1cb99a2f..96033065 100644
--- a/src/conductor.nim
+++ b/src/conductor.nim
@@ -516,7 +516,8 @@ proc buildTimeline*(args: var mainArgs, audio: AudioSettings,
let inputExt = agSplitFile(input).ext
if inputExt in [".v1", ".v2", ".v3", ".json"]:
- tlV3 = readJson(readFile(input), interner)
+ let text = (try: readFile(input) except IOError: error "Cannot read: " & input)
+ tlV3 = readJson(text, interner)
tlV3.applyArgs(args, audio)
elif inputExt == ".xml":
tlV3 = fcp7ReadXml(input, interner)