Skip to content
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 #32538

Closed
wants to merge 1 commit into from

Conversation

hungrymonkey
Copy link
Contributor

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 #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

extends Node

func _ready():
	var player = get_node('video_player')
	var stream = preload("res://big_buck_bunny_480p_stereo.ogv")
	player.set_stream(stream)
	player.play()
	player.set_stream_position(68.0)
	yield(get_tree().create_timer(10.0), "timeout")
	player.set_stream_position(0.0)

@hungrymonkey hungrymonkey force-pushed the seek_theora branch 2 times, most recently from fa44d91 to 0b68a94 Compare October 4, 2019 05:27
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
@Calinou
Copy link
Member

Calinou commented Feb 3, 2025

@Zireael07
Copy link
Contributor

I think you meant to link #102360 ?

@Calinou
Copy link
Member

Calinou commented Feb 3, 2025

I think you meant to link #102360 ?

Yes and no, because #32539 was technically superseding this PR in the first place. However, it was closed over time so #102360 is its spiritual successor 🙂

@AThousandShips AThousandShips removed this from the 4.0 milestone Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants