-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve frame accuracy when pausing and seeking.
When pausing, sometimes the consumer thread would output a newer frame before the video thread was done. Then, the video thread would output an older frame. Also, when seeking, the consumer would reload a bunch of the same frame into the buffer.
- Loading branch information
Showing
3 changed files
with
46 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ab3ce28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit broke GPU processing. It it rather heavy-handed. Changing a bunch of consumer properties when pausing and playing? Is that what a MLT app needs to do properly handle play/pause? Ugly.
ab3ce28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, when I said it "broke GPU processing" I mean it crashes with GPU processing enabled. The following changes fixes it and still provides clean, dead-stop behavior most of the time:
The removal of the consumer->stop()s might also be necessary for decklink output. I still have to check that. Also, if you are doing Encode > Stream (broken at the moment), then pause and seek are supported, and we do not want to interrupt the stream during that by calling stop.
ab3ce28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Dan,
Thanks for the review. With your patch, I had some trouble resuming when GPU is enabled. I had better luck with this modified change:
With both your patch and the one above, I see that seeking is still frame accurate. But when pausing the last frame is output twice. I see this by adding a debug line at the begingin of GLWidget::on_frame_show():
When pausing, I frequently see this result:
I suppose that is tolerable for now.
Regarding "heavy handed":
I would have thought the same thing until I did some profiling. With the previous code, when the user pauses, the consumer pulls 25 duplicate frames into the consumer buffer. Then, when you seek, those 25 frames are purged and 25 more duplicate frames are loaded. That's 25 image malloc/memcpy operations for video and 25 more for audio - and then another 50 free operations - for no reason. But by chaning the consumer properties that all gets reduced to one unnecessary frame loaded in the buffer.
I'll commit my patch above if you're OK with that.
ab3ce28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, your version of the patch works for me too. Go ahead.
ab3ce28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
377eb4f