-
Notifications
You must be signed in to change notification settings - Fork 72
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 fps and duration to GetCodecInfo #376
Conversation
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.
Nice! I tested it and it worked fine for every video I tried! 🎉
Added two comments just for me to understand the changes.
ffmpeg/extras.c
Outdated
@@ -176,6 +176,10 @@ int lpms_get_codec_info(char *fname, pcodec_info out) | |||
} | |||
out->width = ic->streams[vstream]->codecpar->width; | |||
out->height = ic->streams[vstream]->codecpar->height; | |||
|
|||
AVRational frame_rate = av_guess_frame_rate(ic,ic->streams[vstream],NULL); | |||
out->fps = (frame_rate.num && frame_rate.den ? av_q2d(frame_rate) : 0); |
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.
What does this line do? Why isn't it just this?
out->fps = frame_rate.num;
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.
frame rates are in AVRational
types that are similar to Rats in Go with a numerator and denominator. I think this is overly conservative after researching a bit more and changing to avg_frame_rate
in the AVStream
ffmpeg/extras.c
Outdated
@@ -176,6 +176,10 @@ int lpms_get_codec_info(char *fname, pcodec_info out) | |||
} | |||
out->width = ic->streams[vstream]->codecpar->width; | |||
out->height = ic->streams[vstream]->codecpar->height; | |||
|
|||
AVRational frame_rate = av_guess_frame_rate(ic,ic->streams[vstream],NULL); |
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.
Just to make sure, did you check the performance of this call? Won't it slow down the input file analysis?
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.
I have updated to use avg_frame_rate
in the AVStream
from the avformat_find_stream_info
call already being done. Duration is in the AVFormatContext
as well so don't need to calculate. Want to note that the nb_frames
was not populated on webm files I think this is a container spec driven difference compared to mp4 files.
Performance stats indicate it performs more or less the same as not getting the FPS and Duration data. Was tested on my O node so not entirely unused test environment. Most test files from https://test-videos.co.uk test function was:
|
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.
Looks good. @ad-astra-video ping me when the PR is ready to merge, then I'll merge it.
@ad-astra-video Is this PR ready to merge? |
I think the lpms part has no changes needed. go-livepeer does not consider getting the fps from the new fields yet though. Do you want to wait to merge until that gets added to go-livepeer? |
Yeah, maybe let's wait and merge it all together |
537ac4a
to
579d8ab
Compare
Rebased this to current master. Testing this with AI workflows. |
Is this PR still needed now that #407 is merged? |
Add FPS and Duration data to GetCodecInfo.