JuliaIO / VideoIO.jl

Reading and writing of video files in Julia via ffmpeg
https://juliaio.github.io/VideoIO.jl/stable
Other
125 stars 53 forks source link

feat(info.jl): added get_fps #392

Closed AbelHo closed 1 year ago

AbelHo commented 1 year ago

function to retrieve video fps

codecov[bot] commented 1 year ago

Codecov Report

Base: 79.40% // Head: 78.78% // Decreases project coverage by -0.62% :warning:

Coverage data is based on head (c174b08) compared to base (98739b9). Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #392 +/- ## ========================================== - Coverage 79.40% 78.78% -0.62% ========================================== Files 10 10 Lines 1277 1287 +10 ========================================== Hits 1014 1014 - Misses 263 273 +10 ``` | [Impacted Files](https://codecov.io/gh/JuliaIO/VideoIO.jl/pull/392?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaIO) | Coverage Δ | | |---|---|---| | [src/info.jl](https://codecov.io/gh/JuliaIO/VideoIO.jl/pull/392?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaIO#diff-c3JjL2luZm8uamw=) | `75.00% <0.00%> (-25.00%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaIO). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaIO)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

IanButterworth commented 1 year ago

VideoIO.framerate(f) exists, but I notice it is only mentioned in passing in the manual.

Does that meet your needs? If so can you PR to add that to the manual.

Thanks!

AbelHo commented 1 year ago

Thanks for your quick response! VideoIO.framerate(f) gives 1//0 for the videos I have. I hope I am not doing something wrong?

IanButterworth commented 1 year ago

I think it requires that at least one frame has been read. Can you test that?

Perhaps that's fixable

AbelHo commented 1 year ago

The following is what I did:

vid = VideoIO.openvideo("somefile.mp4")
img = read(vid);
VideoIO.framerate(vid)

3 out of 5 video still gives: 1//0

2 out of 5 video successfully give the frame rate after reading one frame

IanButterworth commented 1 year ago

Can you try https://github.com/JuliaIO/VideoIO.jl/pull/393

AbelHo commented 1 year ago

Results from the current master branch before:

julia> VideoIO.framerate.(VideoIO.openvideo.(fnames))
5-element Vector{Rational{Int32}}:
 1//0
 1//0
 1//0
 1//0
 1//0

julia> map(fnames) do x
               vid=VideoIO.openvideo(x); read(vid); VideoIO.framerate(vid)
       end
5-element Vector{Rational{Int32}}:
    1//0
   50//1
 3840//1
    1//0
    1//0

julia> get_fps.(fnames)
5-element Vector{Rational{Int64}}:
 30//1
 25//1
 30//1
 25//1
 25//1
AbelHo commented 1 year ago

Can you try #393

Thank you. tested, added results for both before and after changes, here and in #393 respectively

IanButterworth commented 1 year ago

@AbelHo thanks for the help here. I'm going to close this and try to finish all the framerate fixes over in #393

I'd appreciate your review there as I can't see why tests are failing currently