-
Notifications
You must be signed in to change notification settings - Fork 425
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
Add durationPerFrame to Frameset #507
Conversation
Thank you. Could you put that info into to the class JDoc so the class is easier to use? |
@TobiGr Okay, I'll add it. Actually, I'd prefer an open/public default implementation - something like public int[] getFrameBoundsAt(long timestamp) where the I just checked the other services and PeerTube doesn't support frames and media.ccc.de uses the same logic as YouTube (grid) (but here you've got to load an additional Url: https://static.media.ccc.de/media/events/rc3/150-8e6fd90f-f358-518f-95dc-19dbec1dcaea.thumbnails.vtt What do you think? |
Sounds good. |
65caff4
to
3d9fbc8
Compare
I've added the default implementation. It should work correctly (even if the "testing" has basically been with the eyes :') ) |
extractor/src/main/java/org/schabi/newpipe/extractor/stream/Frameset.java
Outdated
Show resolved
Hide resolved
3d9fbc8
to
b727c3e
Compare
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.
Can be merged after this small change
extractor/src/main/java/org/schabi/newpipe/extractor/stream/Frameset.java
Outdated
Show resolved
Hide resolved
b727c3e
to
11dcfe6
Compare
This PR adds
durationPerFrame
field to the existingFrameset
class. This property is necessary to calculate the correct frame depending on the timestamp. Before there was no way to crop the correct frame bounds from the storyboard ("framesPerPageX
xframesPerPageY
"-matrix).Short example with this change to calculate the correct frame coordinates (pseudo code):
-- Goal: get frame bounds for 3:25:500 (= 180.500 milliseconds)´
-- Given: storyboard-Urls in 5x5-matrix, duration per frame = 5.000, frame height = 160 and frame width = 90
=>
180.500 / 5.000
= 36.1 => 37. Frame=>
(37 - 1 * 25)
= 12 => 12. frame in 2. storyboard=>
(12 - 2 * 5)
= 2 => 3. row, 2. column => row index = 2, column index = 1=> Bounds / rectangle of the frame at the position:
left top (x, y) = (0 + 1 * 160 = 160, 0 + 2 * 90 = 180)
=>
(left, top, right, bottom) = (160, 180, 320, 270)