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

Conversation

Hangjie22Coder
Copy link
Contributor

@Hangjie22Coder Hangjie22Coder commented Sep 23, 2024

No description provided.

@Hangjie22Coder Hangjie22Coder changed the title Fix Mismatch Between Input and Output Frames in FFmpeg-VAAPI VPP Dein… Fix Input-Output Frame Mismatch in FFmpeg-VAAPI VPP Deinterlace Sep 23, 2024
@Hangjie22Coder Hangjie22Coder marked this pull request as ready for review September 27, 2024 07:35
@FocusLuo FocusLuo requested review from uartie, Bin-CI and feiwan1 October 8, 2024 06:20
@@ -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.

@Hangjie22Coder Hangjie22Coder requested a review from uartie October 22, 2024 07:23
@Hangjie22Coder Hangjie22Coder marked this pull request as draft December 2, 2024 09:32
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

Successfully merging this pull request may close these issues.

2 participants