Effort free video editing!
Add hasBaseVideo and hasBaseAudio for the empty-track checks
WyattBlue3841cc93f619
diff --git a/src/exports/drops.nim b/src/exports/drops.nimindex ab6e0b7f..899a5c5b 100644--- a/src/exports/drops.nim+++ b/src/exports/drops.nim@@ -116,7 +116,7 @@ func shortensSpans(base: seq[Clip], markers: seq[Marker]): bool {.raises: [].} =breakfunc fcpxmlShortensSpans(tl: v3): bool {.raises: [].} =- if tl.v.len > 0 and tl.v[0].len > 0: tl.v[0].shortensSpans(tl.markers)+ if tl.hasBaseVideo: tl.v[0].shortensSpans(tl.markers)elif tl.a.len > 0: tl.a[0].shortensSpans(tl.markers)else: false@@ -127,7 +127,7 @@ proc exportDrops*(tl: v3, kind: ExportKind): seq[string] {.raises: [].} =if not kind.isEditorExport:returnlet sup = support(kind)- let videoBase = tl.v.len > 0 and tl.v[0].len > 0+ let videoBase = tl.hasBaseVideovar s = DropScan(videoBase: videoBase)for clip in (if videoBase: tl.v[0] elif tl.a.len > 0: tl.a[0] else: @[]):diff --git a/src/exports/fcp11.nim b/src/exports/fcp11.nimindex 40667391..63ad1ce1 100644--- a/src/exports/fcp11.nim+++ b/src/exports/fcp11.nim@@ -318,10 +318,10 @@ proc fcp11WriteXml*(groupName: string, version: uint8, output: string,var clips: seq[Clip]var transitions: seq[Transition]- if tl.v.len > 0 and tl.v[0].len > 0:+ if tl.hasBaseVideo:clips = tl.v[0]if tl.vt.len > 0: transitions = tl.vt[0]- elif tl.a.len > 0 and tl.a[0].len > 0:+ elif tl.hasBaseAudio:clips = tl.a[0]if tl.at.len > 0: transitions = tl.at[0]diff --git a/src/exports/fcp7.nim b/src/exports/fcp7.nimindex 7a131086..bf339604 100644--- a/src/exports/fcp7.nim+++ b/src/exports/fcp7.nim@@ -417,7 +417,7 @@ proc premiereWriteAudio(audio: XmlNode, files: var FileDefs, tl: v3,aformat.add ascharaudio.add aformat- let hasVideo = tl.v.len > 0 and tl.v[0].len > 0+ let hasVideo = tl.hasBaseVideovar transitionPlans = newSeq[seq[TransitionLink]](tl.a.len)for i, layer in tl.a:let transitions = (if i < tl.at.len: tl.at[i] else: @[])@@ -579,7 +579,7 @@ proc fcp7WriteXml*(name, output: string, resolve: bool, tl: v3) =files.ids[mi] = &"file-{idCounter}"ptrToMi[ptrSrc] = mi- let hasVideo = tl.v.len > 0 and tl.v[0].len > 0+ let hasVideo = tl.hasBaseVideo# clipitem ids run V1, V2, ... then audio. Audio ids start past every video clip# across all tracks, not just v[0]'s, so <link> refs stay unambiguous.diff --git a/src/exports/json.nim b/src/exports/json.nimindex a16730da..b1067750 100644--- a/src/exports/json.nim+++ b/src/exports/json.nim@@ -127,9 +127,9 @@ proc exportJsonTl*(tlV3: v3, `export`: ExportKind, output: string) =error "No chunks available for export"var source: string = ""- if tlV3.v.len > 0 and tlV3.v[0].len > 0:+ if tlV3.hasBaseVideo:source = tlV3.v[0][0].src[]- elif tlV3.a.len > 0 and tlV3.a[0].len > 0:+ elif tlV3.hasBaseAudio:source = tlV3.a[0][0].src[]let clips2 = tlV3.clips2diff --git a/src/render/format.nim b/src/render/format.nimindex 7eca266f..20fa621c 100644--- a/src/render/format.nim+++ b/src/render/format.nim@@ -143,7 +143,7 @@ proc makeMedia*(args: mainArgs, inputVideo: VideoSettings, audio: AudioSettings,let includeVideo = not args.vn and rules.defaultVid notin [ID_NONE, ID_PNG]let includeAudio = not args.an and rules.defaultAud != ID_NONElet includeSubtitle = not args.sn and rules.defaultSub != ID_NONE- let renderVideo = includeVideo and renderTl.v.len > 0 and renderTl.v[0].len > 0+ let renderVideo = includeVideo and renderTl.hasBaseVideoif renderVideo:template limitTo(limit: SizeLimit, what, source: string) =let (width, height) = scaledVideoResolution(renderTl.res, video.scale)diff --git a/src/render/preview.nim b/src/render/preview.nimindex 21a25c1f..5fe34f67 100644--- a/src/render/preview.nim+++ b/src/render/preview.nim@@ -46,7 +46,7 @@ proc openPreview*(args: sink mainArgs, startSeconds, scale: float64,r.tb = tbr.sampleRate = r.renderTl.sr.intlet start = clamp(int64(round(startSeconds * tb.float64)), 0, max(r.renderTl.len - 1, 0))- if r.renderTl.v.len > 0 and r.renderTl.v[0].len > 0:+ if r.renderTl.hasBaseVideo:# Frames come unturned; the export carries the template's display matrix.if r.renderTl.templateFile != nil:let vids = r.cache.getContainer(r.renderTl.templateFile).videodiff --git a/src/timeline.nim b/src/timeline.nimindex d06d95f0..9b4a54ca 100644--- a/src/timeline.nim+++ b/src/timeline.nim@@ -192,8 +192,16 @@ proc rescale*(self: var v3, tb: AVRational) {.raises: [ActionParseError].} =span(w.start, w.dur)self.tb = tb+func hasBaseVideo*(tl: v3): bool {.inline.} =+ ## Whether the bottom video track has a clip; tracks can be empty.+ tl.v.len > 0 and tl.v[0].len > 0++func hasBaseAudio*(tl: v3): bool {.inline.} =+ ## Whether the first audio track has a clip; tracks can be empty.+ tl.a.len > 0 and tl.a[0].len > 0+func timelineIsEmpty(self: v3): bool =- (self.v.len == 0 or self.v[0].len == 0) and (self.a.len == 0 or self.a[0].len == 0)+ not self.hasBaseVideo and not self.hasBaseAudiofunc isLinear*(self: v3): bool {.raises: [].} =return self.clips2.len > 0 or self.timelineIsEmpty