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

How to get the FrameRate of a video file? #105

Open
scally81 opened this issue May 6, 2023 · 5 comments
Open

How to get the FrameRate of a video file? #105

scally81 opened this issue May 6, 2023 · 5 comments

Comments

@scally81
Copy link

scally81 commented May 6, 2023

I have looked all over the internet but there is no information anywhere. It is logical that the FrameRate parameter should be received along with NativeVideoWidth(Heigth), but it is not in any of the base classes.
How to get the number of frames per second of an open video?

@glenn-slayden
Copy link
Collaborator

caveat: I'm no expert.

The likely reason for this might be that essentially every modern video format in use nowadays uses adaptive compression, with the sophistication of deploying higher frame rates only when they are actually most needed according to the varying complexity of the content signal, to maximize overall quality.

This issue usually comes up when someone wants to know a "total count of how many frames" are in a given MP4. As far as I know, long gone are the days where that answer can be determined by multiplying a putative "FrameRate" by the length of the video in seconds. Note that this is not to say that a given video doesn't have a fixed number of frames that can be determined, usually only by enumerating and counting them in sequence. That total should remain a permanently conclusive value--but possibly only given the specific MP4 decoder configuration you just measured it on..

So my understanding is that both questions are somewhat meaningless nowadays?

You would have to be more specific about what your ultimate goal for having this number is, in order to better choose from amongst the various available approximation methods or workarounds that might be avilable.

@scally81
Copy link
Author

scally81 commented May 7, 2023

All this is needed to track the position of the current frame, for a clear transition to the desired frame and end after the desired frame. Roughly speaking, easy video editing on the fly.
All other components have this parameter. Only in this component does not. Even DirectShow itself has GetFrameRate. In this component, it is even described in the MediaType.h file, but I don't know how to attach it to the graph to use.
FrameRate always works in the solutions I need. But he, like AspectRatio and other goodies, is missing here.
Well, even if FrameRate, like AspectRatio, can change during playback, then in any case it can somehow be received in some event, for example, make an event to change each frame "FrameProgress".
Simple video editing always goes to the next, previous frame, or 10-20 frames back and forth, frames, not milliseconds.

@skaterlui
Copy link

Look at this PR #69 how to implement missing DirectShow functions. I added the framestep function which was initially not available on wpf-mediakit. Over there you can also find a commit with the framerate property you are looking for.

@scally81
Copy link
Author

Unfortunately, I couldn't find any examples of using non-implemented DirectShow methods. Where can I get more different examples? The site to which everyone refers https://wpfmediakit.codeplex.com/ has not been available for a long time.

@skaterlui
Copy link

skaterlui commented May 10, 2023

As mentioned, you can find the sample code here inside the active pullrequest #69 the commit link to review the code 76158bd
https://wpfmediakit.codeplex.com/ was the previous home of wpf-mediakit and got abandoned to be continued here. Codeplex was shut down from Microsoft long ago.

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

3 participants