-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
seek theora in progress #32539
seek theora in progress #32539
Conversation
First Ogg Theora Seek Attempt Ogg Tidbits Ogg lacks a seek table. Timestamp exists on the ogg page with the closing packet stream. Ogg_page_packets can discern which page has a timestamp. Keyframes exist in pages with ogg_pages_packets(&og) == 1 Proposal Split the file into BUFFERSIZE segments for binary searching and backtracking. Algorithm Binary Search Ogg Page Timestamps Backtrack to Keyframe Catch up to Seek Section 1: This section is implemented as nested loops. The inner loops finds an unprocessed buffer segment and retrieves the first ogg_page even if it spans across buffer segments. The outer loop compares the ogg_page into an iterative binary search. Since ogg_page_packets can discern the granulepos or time stamp, no ogg_packet is inspected. Section 2: The section is implemented as a buffer sync step to combine all ogg_pages into one ogg_packet. Section 3: Submit the frames into the theora decoder and advance the video forward until the buffer catches up to the seek time. Modified Implemented Seek Added BUFFERSIZE and remove the hard coded 4096 Known Bugs Seek cannot find subsequent ogg_pages in the buffer segment. When a buffer section has two ogg_pages and the keyframe is encoded in the latter ogg_page. Seek will not find it. VideoTheoraStreak is littered with time resets. Currently, seek only works during play mode. Seek 0 does not work Links https://www.theora.org/doc/libtheora-1.0/group__decfuncs.html https://xiph.org/oggz/doc/group__basics.html Issue godotengine#14430
e4fb60c
to
143a898
Compare
ogg_pages. The iframe appears on the latter page Found a bug where the solution is skipping more audio frames
In addition to updating the video player, I also popped packets until I reached the desired seeked time
the state and call play to start the video again. Seek 0 seems to work without explicting solving the issue Modified play to not reset the time New bugs: Some artifacts appear at the beginning of the seek
I accidently dropped an ogg_page. The fix was to move the pageout back to the top
@akien-mga Can somebody help review the pr request? I managed to implement most of my original goals, but I need some idea on how I should change I will squash my commits later because I already referenced the Issue page. Squashing commits will spam the issue page |
Added a few more lines of comments
the video is seeked near the end
vorbis_granule_time(&vd, audio_granulepos + op.packetno - total_packets--); to vorbis_granule_time(&vd, audio_granulepos + total_packets--); In the Ogg Format, packetno is just a serial no. The number becomes somewhat nonsense when the decoder is serializing XX without any frame of reference. In order to calculate the correct time stamp without decoding through all the ogg packets, I grab the granulepos and total completed packets from the ogg page. Since each packet is one sample, total_packets is used to offset the serial number
In the third stage, I used the last page time to update the following decoded page. The time should be accurate for all packets Granulepos is defined as granule of keyframe | offset such that 101231|0 is a keyframe. 101231|1 is the next frame and so on. Since, the last few bits is the offset, I should be able to just add the an offset to obtain the correct granulepos unless endian issues may arise. In vorbis, packets might have varied block size. This code might not be correct.
@akien-mga Should I rebase the onto master? When will godot 4.0 be released? |
Upstream broke OGV Theora. I have to wait until issue #36647 is fixed. |
First Ogg Theora Seek Attempt
Ogg Tidbits
Ogg lacks a seek table.
Timestamp exists on the ogg page with the closing packet stream.
Ogg_page_packets can discern which page has a timestamp.
Keyframes exist in pages with ogg_pages_packets(&og) == 1
Proposal
Split the file into BUFFERSIZE segments for binary searching and backtracking.
Algorithm
Binary Search Ogg Page Timestamps
Backtrack to Keyframe
Catch up to Seek
Section 1:
This section is implemented as nested loops. The inner loops finds an unprocessed buffer segment and retrieves the first ogg_page even if it spans across buffer segments.
The outer loop compares the ogg_page into an iterative binary search. Since ogg_page_packets can discern the granulepos or time stamp, no ogg_packet is inspected.
Section 2:
The section is implemented as a buffer sync step to combine all ogg_pages into one ogg_packet.
Section 3:
Submit the frames into the theora decoder and advance the video forward until the buffer catches up to the seek time.
Modified
Implemented Seek
Added BUFFERSIZE and remove the hard coded 4096
Known Bugs
Seek cannot find subsequent ogg_pages in the buffer segment. When a buffer section has two ogg_pages and the keyframe is encoded in the latter ogg_page. Seek will not find it.VideoTheoraStreak is littered with time resets. Currently, seek only works during play mode.
More audio frames needs to be dropped when videobuf_time > audio_time within the streamSeek 0 does not workSmall artifacts at the beginning of the videoCrashes godot when using a seeking near the end line: 771d4930c9Links
https://www.theora.org/doc/libtheora-1.0/group__decfuncs.html
https://xiph.org/oggz/doc/group__basics.html
Issue #14430
Seek works somewhat. I need to fix these three bugs.
https://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_stereo.ogg
I managed run big_buck_bunny.ogv