Skip to content

refactor(video): change default video format to webm#466

Merged
max-lvs merged 1 commit intolinuxdeepin:develop/eagle20260427from
Resurgamz:release/eagle
Apr 27, 2026
Merged

refactor(video): change default video format to webm#466
max-lvs merged 1 commit intolinuxdeepin:develop/eagle20260427from
Resurgamz:release/eagle

Conversation

@Resurgamz
Copy link
Copy Markdown

@Resurgamz Resurgamz commented Apr 27, 2026

Unify video format selection logic across all devices. Change default format from mp4 to webm for better compatibility.

统一所有设备的视频格式选择逻辑,将默认格式从 mp4 改为 webm 以提升兼容性。

Log: 修改默认录制视频格式为 webm
PMS: https://pms.uniontech.com/bug-view-358869.html
Influence: 新用户默认使用 webm 格式录制视频,用户仍可在设置中切换为 mp4。已有用户配置不受影响。

Summary by Sourcery

Enhancements:

  • Standardize video format selection so WebM is the default format with MP4 as an optional alternative in settings.

Unify video format selection logic across all devices. Change default
format from mp4 to webm for better compatibility.

统一所有设备的视频格式选择逻辑,将默认格式从 mp4 改为 webm 以提升兼容性。

Log: 修改默认录制视频格式为 webm
PMS: https://pms.uniontech.com/bug-view-358869.html
Influence: 新用户默认使用 webm 格式录制视频,用户仍可在设置中切换为 mp4。已有用户配置不受影响。
@deepin-ci-robot
Copy link
Copy Markdown

Hi @Resurgamz. Thanks for your PR. 😃

@deepin-ci-robot
Copy link
Copy Markdown

Hi @Resurgamz. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

CLA Assistant Lite bot:
提交邮箱中包含我们的合作伙伴,但您似乎并非合作伙伴的成员或对接人,请联系相关对接人将您添加至组织之中,或由其重新发起 Pull Request。
The commit email domain belongs to one of our partners, but it seems you are not yet a member of the current organization, please contact the contact person to add you to the organization or let them submit the Pull Request.

zhangjiarui seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 27, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors video format selection to make webm the primary default format across devices while simplifying and unifying the selection logic, with settings now interpreting index 0 as webm and 1 as mp4.

Class diagram for updated video format selection

classDiagram
    class videowidget {
        - string m_videoFormat
        + videowidget(parent)
    }

    class Settings {
        - SettingsInstance m_settings
        - QStringList videoFormatList
        + void init()
    }

    class DataManager {
        + static DataManager* instance()
        + int encodeEnv()
        + bool encExists()
    }

    class GlobalUtils {
        + static void loadCameraConf()
        + static bool isLowPerformanceBoard()
    }

    class dc_Settings {
        + static dc_Settings& get()
        + QVariant getOption(key)
        + void setOption(key, value)
    }

    videowidget --> DataManager : uses encodeEnv
    videowidget --> DataManager : uses encExists
    videowidget --> dc_Settings : reads vidformat

    Settings --> DataManager : uses encodeEnv
    Settings --> DataManager : uses encExists
    Settings --> GlobalUtils : uses loadCameraConf
    Settings --> dc_Settings : sets vidformat

    note for videowidget "m_videoFormat default webm; config index 0=webm, 1=mp4"
    note for Settings "videoFormatList[0]=webm, [1]=mp4 when encoder exists"
Loading

File-Level Changes

Change Details Files
Make webm the default recording format and simplify runtime selection logic in the video widget.
  • Remove low-performance-board special case from default format selection
  • Set webm as default when FFmpeg is unavailable or encoder does not exist
  • When FFmpeg encoder is available, interpret settings option value 0 as webm and 1 as mp4, defaulting to webm otherwise
src/src/videowidget.cpp
Standardize available video format ordering so webm is index 0 and mp4 is index 1 in settings initialization.
  • Always populate videoFormatList as [webm, mp4] when encoder is available, regardless of performance board status
  • Keep webm-only option and force vidformat setting to 0 when encoder does not exist
src/src/Settings.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The logic around GlobalUtils::isLowPerformanceBoard() has been removed from both the constructor and settings list, which changes behavior on low-performance boards; please double-check whether these devices are still expected to prefer webm only or if mp4 should now be user-selectable there.
  • The mapping from outsetting.outformat.vidformat option to actual format strings ("webm" / "mp4") is duplicated between Settings::init and videowidget—consider centralizing this mapping (e.g., via a helper or enum) to keep default indices and supported formats consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The logic around `GlobalUtils::isLowPerformanceBoard()` has been removed from both the constructor and settings list, which changes behavior on low-performance boards; please double-check whether these devices are still expected to prefer `webm` only or if `mp4` should now be user-selectable there.
- The mapping from `outsetting.outformat.vidformat` option to actual format strings (`"webm"` / `"mp4"`) is duplicated between `Settings::init` and `videowidget`—consider centralizing this mapping (e.g., via a helper or enum) to keep default indices and supported formats consistent.

## Individual Comments

### Comment 1
<location path="src/src/videowidget.cpp" line_range="225-231" />
<code_context>
     setGridType(Grid_None);

-    if (DataManager::instance()->encodeEnv() != FFmpeg_Env || !DataManager::instance()->encExists() || GlobalUtils::isLowPerformanceBoard()) {
+    // 默认使用 webm 格式
+    if (DataManager::instance()->encodeEnv() != FFmpeg_Env || !DataManager::instance()->encExists()) {
         m_videoFormat = "webm";
-    }
-    if (dc::Settings::get().getOption("outsetting.outformat.vidformat").toInt()) {
-        if (!GlobalUtils::isLowPerformanceBoard())
-            m_videoFormat = "webm";
-        else
+    } else {
+        // 根据配置选择格式:0=webm(默认), 1=mp4
+        int formatIndex = dc::Settings::get().getOption("outsetting.outformat.vidformat").toInt();
+        if (formatIndex == 1) {
             m_videoFormat = "mp4";
+        } else {
</code_context>
<issue_to_address>
**suggestion:** Consider simplifying default format logic to reduce duplication and make future changes safer.

`m_videoFormat = "webm"` is assigned in both branches. Since `webm` is the default, you can set it once before the `if`, then only set `
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/src/videowidget.cpp
Comment on lines +225 to +231
// 默认使用 webm 格式
if (DataManager::instance()->encodeEnv() != FFmpeg_Env || !DataManager::instance()->encExists()) {
m_videoFormat = "webm";
}
if (dc::Settings::get().getOption("outsetting.outformat.vidformat").toInt()) {
if (!GlobalUtils::isLowPerformanceBoard())
m_videoFormat = "webm";
else
} else {
// 根据配置选择格式:0=webm(默认), 1=mp4
int formatIndex = dc::Settings::get().getOption("outsetting.outformat.vidformat").toInt();
if (formatIndex == 1) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Consider simplifying default format logic to reduce duplication and make future changes safer.

m_videoFormat = "webm" is assigned in both branches. Since webm is the default, you can set it once before the if, then only set `

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, max-lvs, Resurgamz

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@max-lvs max-lvs merged commit 5a29a2d into linuxdeepin:develop/eagle20260427 Apr 27, 2026
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants