Replies: 1 comment 2 replies
|
Hi, thank you! Yes, iteration of samples is very expensive. It requires decoding the video data. If you want to know the number of samples, you can simply count the number of packets instead, which will be identical (in 99.999% of the cases). For that, you can use https://mediabunny.dev/api/InputTrack#computepacketstats. However, I would recommend that you don't rely on counts at all, but timestamps instead: Call |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, first off, thank you for this amazing library!
I am trying to get the total number of samples without having to run a For loop on the sink.samples , in my use case I record a video and want to add a graphic that animates across the view using the canvas draw methods inside the for loop. I thought about doing something like the graphic x cord = (WidthOfFrame/total samples) * current iteration count .. that would move the element across the full width of the frame using all the available loops.
Right now I am having to run the loop once, then capture that total number of samples and use it in another identical loop to achieve the movement across the duration of the video track. I did try getting the total video duration and then divide those seconds by the total duration of a given sample (eg. 0.0333 sec) but by some reason I dont get the same number of loops as when running the loop, so I think I might be missing something to make those match.
I am under the impression that the iterator is expensive? or if it's not then perhaps I just do the loop twice and call it the day.. but something tells me that is not optimal.
thank you for your help
All reactions