ws-apifix: videos save as animated images (F.save(video, gif | apng | webp), F.convert(avi, "gif"): frames / fps / maxFrames (300) / maxPixels (2^25)); VideoFrame.index restarts at the seek position; F.detect names WebM files "webm"
api: encoderFor finds image formats for a VideoDecoder, videoToImage() collects the frames; F.detect asks a format's optional variant(r) for a more precise name (video/mkv: Mkv.variant, from Parse.docType). codecs/video/Video: index after seek = round(pts * frameRate) + 1.
This commit is contained in:
1 parent
10bd6b021f
commit
d73b93c740
8 files changed
+207
-6
No files matched your search
@@ -466,6 +466,11 @@ function Video.open(demuxer: Types.Demuxer, opts: OpenOptions?): (Types.VideoDec
|
||||
if img then
|
||||
local t = (pts or 0) / scale - start
|
||||
if t + 1e-9 >= skipUntil then
|
||||
if index < 0 then
|
||||
-- the first frame after a seek: its position in the stream (constant-rate: round(pts * fps);
|
||||
-- without a frame rate, counted from the seek)
|
||||
index = if v.frameRate > 0 then math.max(0, math.floor(t * v.frameRate + 0.5)) else 0
|
||||
end
|
||||
index += 1
|
||||
local d = defaultDur
|
||||
if lastPts and t > (lastPts :: number) and defaultDur == 0 then
|
||||
@@ -502,6 +507,7 @@ function Video.open(demuxer: Types.Demuxer, opts: OpenOptions?): (Types.VideoDec
|
||||
flushed = false
|
||||
skipUntil = seconds
|
||||
lastPts = nil
|
||||
index = -1 -- recomputed from the first frame's time
|
||||
if self.audio then
|
||||
pcall(self.audio.seek, self.audio, seconds)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user