Skip to content

Commit cf4bf47

Browse files
committed
UNTESTED correct frame timestamps
1 parent dc996be commit cf4bf47

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

internal/pkg/stitch/stitch.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,7 @@ func createH264(seq sequence, dest_dir string) (*TrainClip, error) {
233233
src.SetCaps(videoInfo.ToCaps())
234234
src.SetProperty("format", gst.FormatTime)
235235

236-
// Initialize a frame counter
237-
var i int
238-
//palette := video.FormatRGB8P.Palette()
236+
frame_no := 0
239237

240238
// Since our appsrc element operates in pull mode (it asks us to provide data),
241239
// we add a handler for the need-data callback and provide new data from there.
@@ -247,23 +245,23 @@ func createH264(seq sequence, dest_dir string) (*TrainClip, error) {
247245
NeedDataFunc: func(self *app.Source, _ uint) {
248246

249247
// If we've reached the end of the palette, end the stream.
250-
if i == len(seq.frames) {
248+
if frame_no == len(seq.frames) {
251249
log.Debug().Msg("all frames pushed to gstreamer appsrc")
252250
src.EndStream()
253251
return
254252
}
255253

256-
log.Trace().Int("frame", i).Msg("Producing frame")
254+
log.Trace().Int("frame", frame_no).Msg("Producing frame")
257255

258256
// Create a buffer that can hold exactly one video RGBA frame.
259257
buffer := gst.NewBufferWithSize(videoInfo.Size())
260258

261259
// For each frame we produce, we set the timestamp when it should be displayed
262260
// The autovideosink will use this information to display the frame at the right time.
263-
buffer.SetPresentationTimestamp(gst.ClockTime(time.Duration(i) * 33 * time.Millisecond)) // FIXME
261+
buffer.SetPresentationTimestamp(gst.ClockTime(seq.startTS.Sub(seq.ts[frame_no])))
264262

265263
// Produce an image frame for this iteration.
266-
pixels := seq.frames[i].(*image.RGBA).Pix
264+
pixels := seq.frames[frame_no].(*image.RGBA).Pix
267265
//pixels := produceImageFrame(palette[i])
268266

269267
// At this point, buffer is only a reference to an existing memory region somewhere.
@@ -283,7 +281,7 @@ func createH264(seq sequence, dest_dir string) (*TrainClip, error) {
283281

284282
log.Trace().Msg("buffer pushed")
285283

286-
i++
284+
frame_no++
287285
},
288286
})
289287

0 commit comments

Comments
 (0)