-
-
Notifications
You must be signed in to change notification settings - Fork 11
Fix: Correct hardware filter chaining for QSV/VAAPI to prevent video corruption #25
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "author": "Josh.5", | ||
| "author": "DeRoelO", | ||
| "compatibility": [ | ||
| 2 | ||
| ], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| """ | ||
| plugins.qsv.py | ||
|
|
||
| Written by: Josh.5 <jsunnex@gmail.com> | ||
| Written by: DeRoelO (Based on Josh.5) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure you are the author of this file 🤔. I thought I was? |
||
| Date: 08 Jun 2022, (8:14 AM) | ||
|
|
||
| Copyright: | ||
|
|
@@ -254,9 +254,8 @@ def generate_filtergraphs(self, current_filter_args, smart_filters, encoder_name | |
| end_filter_args.append(",".join(end_chain)) | ||
| else: | ||
| # Pure HW path - frames stay in QSV memory | ||
| chain = [f"format={target_fmt}|qsv", | ||
| "hwupload=extra_hw_frames=64", | ||
| "format=qsv", f"vpp_qsv=format={target_fmt}"] | ||
| # We skip hwupload as it would attempt to upload hardware frames as software frames, causing corruption. | ||
| chain = ["format=qsv", f"vpp_qsv=format={target_fmt}"] | ||
| end_filter_args.append(",".join(chain)) | ||
|
|
||
| # Add the smart filters to the end | ||
|
|
@@ -318,7 +317,7 @@ def stream_args(self, stream_info, stream_id, encoder_name, filter_state=None): | |
| # Use default LA_ICQ mode | ||
| encoder_args += [ | ||
| '-global_quality', str(defaults.get('qsv_constant_quality_scale')), | ||
| '-look_ahead_depth', '100', '-extbrc', '1', | ||
| '-look_ahead_depth', '40', '-extbrc', '1', | ||
| ] | ||
| if encoder_name in ["h264_qsv"]: | ||
| encoder_args += ['-look_ahead', '1'] | ||
|
|
@@ -352,7 +351,7 @@ def stream_args(self, stream_info, stream_id, encoder_name, filter_state=None): | |
| # They enable lookahead via "-look_ahead_depth <N>" and "-extbrc 1" instead. | ||
| if encoder_name in ["h264_qsv"]: | ||
| encoder_args += ['-look_ahead', '1'] | ||
| encoder_args += ['-look_ahead_depth', '100', '-extbrc', '1'] | ||
| encoder_args += ['-look_ahead_depth', '40', '-extbrc', '1'] | ||
| else: | ||
| # Configure the QSV encoder with a bitrate-based mode | ||
| # Set the max and average bitrate (used by all bitrate-based modes) | ||
|
|
@@ -361,7 +360,7 @@ def stream_args(self, stream_info, stream_id, encoder_name, filter_state=None): | |
| # Add lookahead | ||
| if encoder_name in ["h264_qsv"]: | ||
| encoder_args += ['-look_ahead', '1'] | ||
| encoder_args += ['-look_ahead_depth', '100', '-extbrc', '1'] | ||
| encoder_args += ['-look_ahead_depth', '40', '-extbrc', '1'] | ||
| elif self.settings.get_setting('qsv_encoder_ratecontrol_method') == 'CBR': | ||
| # Add 'maxrate' with the same value to make CBR mode | ||
| encoder_args += ['-maxrate', f"{self.settings.get_setting('qsv_average_bitrate')}M"] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| """ | ||
| plugins.vaapi.py | ||
|
|
||
| Written by: Josh.5 <jsunnex@gmail.com> | ||
| Written by: DeRoelO (Based on Josh.5) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are not the author of this file. |
||
| Date: 08 Jun 2022, (8:15 AM) | ||
|
|
||
| Copyright: | ||
|
|
@@ -219,7 +219,8 @@ def generate_filtergraphs(self, current_filter_args, smart_filters, encoder_name | |
| end_filter_args.append(",".join(end_chain)) | ||
| else: | ||
| # Pure HW path - frames stay in VAAPI memory | ||
| chain = [f"format={target_fmt}|vaapi", "hwupload"] | ||
| # We skip hwupload as it would attempt to upload hardware frames as software frames. | ||
| chain = ["format=vaapi"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change drops the target pixel-format handling from the pure hardware path. I don't think it is correct to drop the |
||
| end_filter_args.append(",".join(chain)) | ||
|
|
||
| # Add the smart filters to the end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| """ | ||
| plugins.plugin.py | ||
|
|
||
| Written by: Josh.5 <jsunnex@gmail.com> | ||
| Written by: DeRoelO (Based on Josh.5) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are not the author of this file. |
||
| Date: 4 June 2022, (6:08 PM) | ||
|
|
||
| Copyright: | ||
|
|
||
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.
You are not taking ownership as the maintainer of the official plugin. You are still more than welcome to fork and maintain your own version and change the author this
info.jsonfile there, but I would recommend keeping the original author cited in it also.