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

Fix Input-Output Frame Mismatch in FFmpeg-VAAPI VPP Deinterlace #691

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ffmpeg/vppbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def gen_output_opts(self):
opts = "-filter_complex" if self.vpp_op in fcomplex else "-vf"
opts += f" '{','.join(vpfilter)}'"
opts += " -pix_fmt {mformat}" if self.vpp_op not in ["csc", "tonemap", "overlay"] else ""
opts += " -f rawvideo -fps_mode passthrough -an -vframes {frames} -y {osdecoded}"
opts += " -f rawvideo -fps_mode cfr -an -vframes {frames} -y {osdecoded}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what "cfr" does and why it fixes this? Also, this will change the command line for all VPP tests... have you verified they don't regress?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cfr (Constant Frame Rate) forces FFmpeg to maintain a fixed output frame rate, even if the input timestamps are irregular or the frame rate is variable. This ensures that the output frames are evenly spaced in time, and if there are any gaps in the input frames or missing frames due to timestamp issues, FFmpeg will either drop or duplicate frames to keep the frame rate consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our tests, when using fps_mode passthrough, FFmpeg outputs frames directly based on the timestamp of the input stream, which can cause some frames to be lost due to discontinuous timestamps or insufficient reference frames. When using CFR mode, FFmpeg avoids frame drops by normalizing timestamps to ensure that each output frame has a fixed time interval. Therefore, this modification can ensure the stability and integrity of the output frame.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding your concern about the impact on FFmpeg VPP tests, I understand that changing to cfr affects all tests. I have conducted thorough testing across different cases. While the issue of output frame mismatches has been resolved, I noticed that in some cases, there are issues with bitrate_gap and ssim. This indicates that certain test cases are indeed affected by the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will explore further to see if there’s a better solution to resolve the output frame mismatch issue.


return opts

Expand Down