Skip to content

encavcodec: set MF AVScenario to ARCHIVE by default #6371

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

Merged
merged 1 commit into from
Jan 19, 2025

Conversation

dashsantosh-mcw
Copy link
Contributor

For general transcode use cases, AVScenario ICODEC property to be set to ARCHIVE for the MediaFoundation encoders.
This PR sets the default AVScenario to ARCHIVE, if its not already set by the user.

Tested on:

  • Windows 10+ (via MinGW)
  • macOS 10.13+
  • Ubuntu Linux

@bradleysepos
Copy link
Contributor

I wonder whether we should expose additional CLI parameters / UI controls for this.

@santdas36
Copy link

santdas36 commented Oct 25, 2024

I believe this is already configurable via the enc-opts

-x scenario=<default | display_remoting | video_conference | archive | live_streaming | camera_record display_remoting_with_feature_map>

https://github.com/FFmpeg/FFmpeg/blob/08b1bffa49715a9615acc025dfbea252d8409e1f/libavcodec/mfenc.c#L1289

@sr55
Copy link
Contributor

sr55 commented Oct 25, 2024

Note the block further up in this file:

            job->vcodec == HB_VCODEC_FFMPEG_MF_H265 ||
            job->vcodec == HB_VCODEC_FFMPEG_MF_AV1) {
            av_dict_set(&av_opts, "rate_control", "u_vbr", 0); // options are cbr, pc_vbr, u_vbr, ld_vbr, g_vbr, gld_vbr

            // On Qualcomm encoders, the VBR modes can easily drop frames if
            // the rate control feels like it needs it (in certain
            // configurations), unless scenario is set to camera_record.
            av_dict_set(&av_opts, "scenario", "camera_record", 0);
        }

https://github.com/HandBrake/HandBrake/blob/a9f1ad7749ac4624fa2c515472377b13d16f6cd0/libhb/encavcodec.c#L457C58-L457C59

Is this no longer the case? If so, we should remove that block of code at the same time.

@dashsantosh-mcw
Copy link
Contributor Author

@sr55 I've noticed this comment. I'm checking on this. I'll get back as soon as I have confirmed this.

@dashsantosh-mcw
Copy link
Contributor Author

@sr55 The encoder has a free hand in dropping a frame when it runs on vbr mode. With the recent upgrades in the HW and drivers, the encoder shall not drop frames unnecessarily, but still it is recommended to set AVScenario to camera-record when running on vbr mode.

I did try to comment out L457 and run a couple of encodes with different bitrate values and didn't observe any frame drops.

@dashsantosh-mcw
Copy link
Contributor Author

@sr55 Any update on this?

@sr55 sr55 added this to the 1.10.0 milestone Jan 19, 2025
@sr55 sr55 merged commit 1302f0b into HandBrake:master Jan 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants