npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hxa-rn/react-native-video-processing

v1.7.1

Published

Native Video processing/editing for React-Native

Readme

@hxa-rn/react-native-video-processing

本项目基于 react-native-video-processing 开发,并适配 React Native for OpenHarmony。

如果在使用过程中有任何问题,可以在 GitCode 提交 Issue,我们会及时跟进。

项目介绍

面向 HarmonyOS 的视频播放与处理库,提供视频播放、可视化时间轴裁剪,以及基于 FFmpeg 的裁剪、压缩、倒放、回旋、画面裁切与多视频合并能力。

  • VideoPlayer:视频播放组件,支持播放/暂停、循环、进度回调、区间播放、音量、缩放模式、旋转与指定播放器尺寸。
  • Trimmer:可视化时间轴组件,展示缩略图序列与选区,支持双端拖动、播放跟踪柄与主题样式。
  • ProcessingManager:trim、compress、reverse、boomerang、crop、merge、getVideoInfo、getPreviewForSecond、getTrimmerPreviewImages、pickVideo。

集成指南

安装

在 React Native 工程根目录执行:

npm install @hxa-rn/react-native-video-processing

本库运行期依赖 @react-native-ohos/react-native-ffmpeg-kit(6.0.4-beta.3),并适配 react-native >= 0.72。

Autolinking

安装依赖后由宿主工程自动接入,无需手动注册。

导入

import {
  ProcessingManager,
  Trimmer,
  VideoPlayer,
  VideoPlayerConstants,
} from '@hxa-rn/react-native-video-processing';

使用说明

基础用法

import React, {useState} from 'react';
import {Button, Text, View} from 'react-native';
import {
  ProcessingManager,
  VideoPlayer,
  VideoPlayerConstants,
} from '@hxa-rn/react-native-video-processing';

export function Demo() {
  const [source, setSource] = useState('');
  const [play, setPlay] = useState(false);
  const [progress, setProgress] = useState(0);

  const pick = async () => {
    setSource(await ProcessingManager.pickVideo());
  };

  return (
    <View>
      <Button title="选择视频" onPress={pick} />
      {source ? (
        <VideoPlayer
          source={source}
          play={play}
          volume={1}
          resizeMode={VideoPlayerConstants.resizeMode.CONTAIN}
          progressEventDelay={250}
          onVideoProgress={event => setProgress(event.nativeEvent.currentTime)}
          style={{width: '100%', height: 220}}
        />
      ) : null}
      <Text>进度 {progress.toFixed(2)} 秒</Text>
      <Button title={play ? '暂停' : '播放'} onPress={() => setPlay(value => !value)} />
    </View>
  );
}

VideoPlayer 的 source 支持字符串路径或 {uri} 对象;onVideoProgress 为原生事件,当前时间从 event.nativeEvent.currentTime 读取。Trimmer 的 onChange / onTrackerMove 与原库一致,回调参数为裸对象 {startTime, endTime} / {currentTime}。

接口文档

以下 API 依据 src/index.tsx 与 src/specs/v1 类型定义整理。

VideoPlayer

| 属性 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | source | string \| {uri: string} | 未声明 | 视频源,字符串路径或 {uri} 对象 | | play | boolean | false | 是否播放 | | replay | boolean | false | 播放到结尾后是否从头循环 | | currentTime | number | 0 | 跳转位置(秒) | | startTime | number | 0 | 播放区间起点(秒) | | endTime | number | 0 | 播放区间终点(秒),0 表示到视频末尾 | | volume | number | 1 | 音量,取值 0–1 | | resizeMode | string | 'none' | 缩放模式,取 VideoPlayerConstants.resizeMode | | progressEventDelay | number | 1000 | 进度回调最小间隔(毫秒) | | rotate | boolean | false | 是否将画面旋转 90° | | playerWidth | number | 0 | 播放器宽度,0 表示占满容器 | | playerHeight | number | 0 | 播放器高度,0 表示占满容器 | | onVideoProgress | (event) => void | 未声明 | 进度回调,读取 event.nativeEvent.currentTime / event.nativeEvent.duration |

VideoPlayerConstants.resizeMode:CONTAIN、COVER、STRETCH、NONE。

VideoPlayerConstants.quality:QUALITY_LOW、QUALITY_MEDIUM、QUALITY_HIGHEST、QUALITY_640x480、QUALITY_960x540、QUALITY_1280x720、QUALITY_1920x1080、QUALITY_3840x2160、QUALITY_PASS_THROUGH。

Trimmer

| 属性 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | source | string \| {uri: string} | 未声明 | 视频源 | | previewCount | number | 8 | 自动生成的缩略图数量 | | previewMaximumSize | {width: number; height: number} | {width: 160, height: 90} | 缩略图最大尺寸 | | showTrackerHandle | boolean | false | 是否显示播放跟踪柄 | | themeColor | string | 'gray' | 选区边框与手柄颜色 | | trackerColor | string | 'black' | 跟踪柄轨道颜色 | | trackerHandleColor | string | 'gray' | 跟踪柄滑块颜色 | | minLength | number | 0 | 选区最小长度(秒) | | maxLength | number | 0 | 选区最大长度(秒),0 表示不限制 | | currentTime | number | 0 | 跟踪柄位置(秒) | | thumbWidth | number | 20 | 选区手柄宽度 | | borderWidth | number | 2 | 选区边框与轨道厚度 | | onChange | ({startTime, endTime}) => void | 未声明 | 选区变化回调,参数为裸对象 | | onTrackerMove | ({currentTime}) => void | 未声明 | 拖动跟踪柄回调,参数为裸对象 |

ProcessingManager

| 方法 | 说明 | | --- | --- | | getVideoInfo(source) | 读取视频信息,返回 {duration, size: {width, height}, orientation} | | getPreviewForSecond(source, second?, maximumSize?, format?) | 获取指定时刻预览帧;format 取 'base64'(默认)或 'JPEG' | | getTrimmerPreviewImages(source, startTime, endTime, step, maximumSize?, format?) | 按步长批量取帧,返回图片 URI 或 Base64 数组 | | pickVideo() | 从系统相册选择视频,返回复制到应用沙箱 cache 的 file:// 路径(鸿蒙新增) | | trim(source, options) | 时间范围裁剪;options 为 {startTime?, endTime?, quality?} | | compress(source, options) | 压缩;options 为 {bitrateMultiplier?, width?, height?, minimumBitrate?, crf?, removeAudio?} | | reverse(source, options) | 倒放;options 为 {quality?},输出无音轨 | | boomerang(source, options) | 正放 + 倒放拼接;options 为 {quality?, cameraType?: 'front' \| 'back'} | | crop(source, options) | 画面裁切;options 为 {cropOffsetX, cropOffsetY, cropWidth, cropHeight, startTime?, endTime?, quality?} | | merge(readableFiles, command) | 按 filter_complex 合并多个视频,至少两个文件 |

类型

| 类型 | 定义 | | --- | --- | | VideoSource | string \| {uri: string} | | PreviewSize | {width: number; height: number} | | PreviewFormat | 'base64' \| 'JPEG' | | TrimOptions | {startTime?: number; endTime?: number; quality?: string} | | EffectOptions | {quality?: string; cameraType?: 'front' \| 'back'} | | CompressOptions | {bitrateMultiplier?: number; height?: number; width?: number; minimumBitrate?: number; crf?: number; removeAudio?: boolean} | | CropOptions | {cropOffsetX: number; cropOffsetY: number; cropWidth: number; cropHeight: number; startTime?: number; endTime?: number; quality?: string} |

快速验证(运行 Example)

前置条件

| 依赖 | 版本要求 | | :-- | --- | | Node.js | >= 18 | | React Native for OpenHarmony | 0.72.139 | | HarmonyOS SDK | 6.0.2(22) |

运行步骤

  1. 获取开发分支源码:
git clone -b br_rnoh0.72_dev https://gitcode.com/hxa-rn/react-native-video-processing.git
  1. 进入仓库根目录:
cd react-native-video-processing
  1. 安装仓库根目录依赖:
npm install
  1. 生成供示例工程安装的本地安装包:
npm pack
  1. 进入 example 目录:
cd example
  1. 安装示例工程依赖:
npm install
  1. 生成 React Native JavaScript Bundle:
npm run dev
  1. 使用 DevEco Studio 打开 example/harmony,同步依赖并完成签名配置后构建运行。

约束与限制

兼容性

| 依赖 | 要求 | | --- | --- | | React Native for OpenHarmony | 0.72.139 | | HarmonyOS SDK | 6.0.2(22) | | Example 工程 compatibleSdkVersion | 6.0.2(22) | | Example 工程 targetSdkVersion | 26.0.0 | | Node.js | >= 18 |

使用限制

  • resizeMode: NONE 采用 Android 原库语义:按原始像素尺寸、左上对齐,超出播放器区域的部分裁切;iOS 原库为比例适配。
  • VideoPlayer.backgroundColor / background_Color 为 iOS 专有属性,鸿蒙与 Android 对齐不导出,播放器底色固定为黑色。
  • getVideoInfo 返回 {duration, size, orientation},不提供 iOS 的帧率与码率字段。
  • trimmer 的 onChange / onTrackerMove 回调参数为裸对象,与原库一致。
  • merge 的 filter_complex 必须是合法指令;语法非法的滤镜图可能触发底层 FFmpeg 崩溃(上游限制),请在调用前自行校验。
  • trim 的 passthrough 档按关键帧切分;关键帧稀疏的长视频上,短区间可能得到不含视频关键帧的片段。需要可靠短区间片段时请指定 quality 以重编码。
  • 本库产物声明 compatibleSdkVersion 为 22;使用方工程低于该版本时构建会报 00306004。
  • resizeMode: CONTAIN 依赖 API 20 起提供的 VideoScaleType.SCALED_ASPECT。

系统权限

本库不依赖额外的 HarmonyOS 系统权限。

开源 License

本项目采用 MIT,与上游项目保持一致。

问题反馈渠道

如在使用过程中遇到问题,请在 GitCode 提交 Issue,我们会及时跟进。

  • 提交问题时建议附上项目版本、RN 版本、OpenHarmony SDK/API 版本、DevEco Studio 版本、设备信息、复现步骤及相关日志。
  • 涉及签名、账号、密钥或用户数据时,请勿在 Issue 中上传敏感信息;可按组织安全流程提交脱敏日志。