mirror of
https://github.com/opencv/opencv.git
synced 2025-07-31 18:07:08 +08:00
Fix frame rate rounding in ffmpeg wrapper (#9023)
This commit is contained in:
parent
1059735bfb
commit
255b20f6de
@ -1541,7 +1541,7 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
|
|||||||
identically 1. */
|
identically 1. */
|
||||||
frame_rate=(int)(fps+0.5);
|
frame_rate=(int)(fps+0.5);
|
||||||
frame_rate_base=1;
|
frame_rate_base=1;
|
||||||
while (fabs((double)frame_rate/frame_rate_base) - fps > 0.001){
|
while (fabs(((double)frame_rate/frame_rate_base) - fps) > 0.001){
|
||||||
frame_rate_base*=10;
|
frame_rate_base*=10;
|
||||||
frame_rate=(int)(fps*frame_rate_base + 0.5);
|
frame_rate=(int)(fps*frame_rate_base + 0.5);
|
||||||
}
|
}
|
||||||
@ -2374,7 +2374,7 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC
|
|||||||
|
|
||||||
int frame_rate = static_cast<int>(fps+0.5);
|
int frame_rate = static_cast<int>(fps+0.5);
|
||||||
int frame_rate_base = 1;
|
int frame_rate_base = 1;
|
||||||
while (fabs(static_cast<double>(frame_rate)/frame_rate_base) - fps > 0.001)
|
while (fabs((static_cast<double>(frame_rate)/frame_rate_base) - fps) > 0.001)
|
||||||
{
|
{
|
||||||
frame_rate_base *= 10;
|
frame_rate_base *= 10;
|
||||||
frame_rate = static_cast<int>(fps*frame_rate_base + 0.5);
|
frame_rate = static_cast<int>(fps*frame_rate_base + 0.5);
|
||||||
|
Loading…
Reference in New Issue
Block a user