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

Inaccurate seek #427

Open
yakir12 opened this issue Jan 2, 2025 · 1 comment
Open

Inaccurate seek #427

yakir12 opened this issue Jan 2, 2025 · 1 comment

Comments

@yakir12
Copy link
Contributor

yakir12 commented Jan 2, 2025

I have a video where seek yields highly inaccurate results. Maybe this can be explained by some "quality" of the video, but if so, it might be worth mentioning in seek's docstring what the accuracy of seek depends on.

MWE (note that the link here is valid only for the next 7 days, expiring approximately on 2025-01-09 23:00:00 CET):

using VideoIO

url = "https://vision-group-temporary.s3.eu-central-1.amazonaws.com/00002_K02.MTS"
file = download(url) # sorry, 740 MB, takes a moment
vid = openvideo(file)
t = 2 # arbitrary time stamp, feel free to choose another
seek(vid, t)
read(vid)
tt = gettime(vid) # 2.46 >> 2
close(vid)

# the following proves there are many frames closer to the desired target time point:
vid = openvideo(file)
ts = Float64[gettime(vid)]
while ts[end] < tt # collect up to the claimed time stamp
    read(vid)
    push!(ts, gettime(vid))
end
close(vid)

filter((t), ts) # 24 frames between the desired and claimed time points

I'm on VideoIO v1.1.1 and Julia Version 1.11.2.

@yakir12
Copy link
Contributor Author

yakir12 commented Jan 3, 2025

Here, I calculate the intended time stamp and the actual one for every second in the first minute of the video:

t0 = 1:60
t1 = map(t0) do t
    openvideo(file) do vid
        seek(vid, t)
        gettime(vid)
    end
end

These are the differences:

julia> lineplot(t0 .- t1)
        ┌────────────────────────────────────────┐ 
      0 │⢸⠀⠀⠀⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⠀│ 
        │⢸⠀⠀⠀⠀⠀⠀⢰⢹⠀⠀⠀⠀⠀⠀⢰⢹⠀⠀⠀⠀⠀⠀⢰⢹⠀⠀⠀⠀⠀⠀⢰⢹⠀⠀⠀⠀⠀⠀⢰│ 
        │⢸⠀⠀⠀⠀⠀⠀⡇⢸⠀⠀⠀⠀⠀⠀⡇⢸⠀⠀⠀⠀⠀⠀⡇⢸⠀⠀⠀⠀⠀⠀⡇⢸⠀⠀⠀⠀⠀⠀⡇│ 
        │⢸⠀⠀⠀⠀⠀⢸⠀⢸⠀⠀⠀⠀⠀⢸⠀⢸⠀⠀⠀⠀⠀⢸⠀⢸⠀⠀⠀⠀⠀⢸⠀⢸⠀⠀⠀⠀⠀⢸⠀│ 
        │⢸⠀⠀⠀⠀⢀⡇⠀⢸⠀⠀⠀⠀⢀⡇⠀⢸⠀⠀⠀⠀⠀⡇⠀⢸⠀⠀⠀⠀⠀⡇⠀⢸⠀⠀⠀⠀⠀⡇⠀│ 
        │⢸⠀⠀⠀⠀⡜⠀⠀⢸⠀⠀⠀⠀⡜⠀⠀⢸⠀⠀⠀⠀⡸⠀⠀⢸⠀⠀⠀⠀⡸⠀⠀⢸⠀⠀⠀⠀⡸⠀⠀│ 
        │⠸⡀⠀⠀⢠⠃⠀⠀⠸⡀⠀⠀⢠⠃⠀⠀⠸⡀⠀⠀⢠⠃⠀⠀⠸⡀⠀⠀⢠⠃⠀⠀⠸⡀⠀⠀⢠⠃⠀⠀│ 
        │⠀⡇⠀⠀⡜⠀⠀⠀⠀⡇⠀⠀⡜⠀⠀⠀⠀⡇⠀⠀⡜⠀⠀⠀⠀⡇⠀⠀⡜⠀⠀⠀⠀⡇⠀⠀⡜⠀⠀⠀│ 
        │⠀⡇⠀⢠⠃⠀⠀⠀⠀⡇⠀⢠⠃⠀⠀⠀⠀⡇⠀⢠⠃⠀⠀⠀⠀⡇⠀⢠⠃⠀⠀⠀⠀⡇⠀⢠⠃⠀⠀⠀│ 
        │⠀⡇⠀⡎⠀⠀⠀⠀⠀⡇⠀⡎⠀⠀⠀⠀⠀⡇⠀⡎⠀⠀⠀⠀⠀⡇⠀⡎⠀⠀⠀⠀⠀⡇⠀⡎⠀⠀⠀⠀│ 
        │⠀⡇⢰⠁⠀⠀⠀⠀⠀⡇⢰⠁⠀⠀⠀⠀⠀⡇⢰⠁⠀⠀⠀⠀⠀⡇⢰⠁⠀⠀⠀⠀⠀⡇⢰⠁⠀⠀⠀⠀│ 
        │⠀⡇⡇⠀⠀⠀⠀⠀⠀⡇⡎⠀⠀⠀⠀⠀⠀⡇⡇⠀⠀⠀⠀⠀⠀⡇⡇⠀⠀⠀⠀⠀⠀⡇⡇⠀⠀⠀⠀⠀│ 
        │⠀⡿⠀⠀⠀⠀⠀⠀⠀⡿⠁⠀⠀⠀⠀⠀⠀⡿⠀⠀⠀⠀⠀⠀⠀⡿⠀⠀⠀⠀⠀⠀⠀⡿⠀⠀⠀⠀⠀⠀│ 
        │⠀⠁⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀│ 
   -0.5 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ 
        └────────────────────────────────────────┘ 
        ⠀0⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀60⠀ 

Perhaps this has to do with the fact that the start-time of this video is not zero:

julia> openvideo(file) do vid
           read(vid)
               gettime(vid)
               end
1.02

But the difference between the seek'ed time stamp and the actual one is not constant (as can be seen in the line-plot above), so I'm not sure what the relationship between a non-zero start-time and this seek-inaccuracy is, if any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant