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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-video-merger

v0.1.6-2

Published

test

Downloads

14

Readme

react-native-video-merger

** NOTE: The current version only supports the iOS platform, Android platform is not currently supported. **

A package for React Native video merge scenario. You can use this package to achieve the following functions:

  1. Merge multiple videos together (the input file support both H.264 and HEVC video), encode in H.264, MP4 file.
  2. Resize one or mutiple video file, and supports setting the fill color of the blank area.

Installation

# use npm
npm install react-native-video-merger

# use yarn
yarn add react-native-video-merger

Install iOS dependencies

pod repo update --verbose
cd ios && pod install --repo-update

# If the dependencies cannot be found, please execute this command manually
rm ~/Library/Caches/CocoaPods/search_index.json
pod search SotVideoSDK

Usage

Visit demo project: https://github.com/Bijiabo/react-native-video-merger-example

import {
  mergeVideos,
  MergeVideoParams,
  cleanCacheDir,
} from 'react-native-video-merger';
import type { VideoMergeEvent } from 'react-native-video-merger';

// merge multiple videos
async function mergetVideoTest() {
  const paramsForMergeVideo: MergeVideoParams = {
    urls: ['/User.../a.mp4', '/User.../b.mp4'], // use react-native-fs get fill path
    outputSize: { width: 1080, height: 1080 }, // optional
    backgroundColor: 'rgba(229, 192, 123, 1.00)', // optional
  };
  try {
    const res: VideoMergeEvent = await mergeVideos(
      paramsForMergeVideo,
      onProgress
    );
    // TODO: update UI
  } catch (_error) {
    const error = _error as unknown as VideoMergeEvent;
    // TODO: update UI
  }
}

// clear cache dir
await cleanCacheDir();

Error Code

| Error Code | Error Description | | ---------- | :----------------------------------------------------------- | | 101 | Video is exporting now, please start a new export task later | | 102 | Video urls config is empty. |

Native Module API Design

Basic

All API export promise function to JavaScript, you can read document here:

Module Name

The native module name is VideoMerger.

API for merget video

Basic permoise function

Native module export an API to JavaScript like this:

// JavaScript/TypeScript code
const res: VideoMergeEvent = await VideoMerger.mergeVideos(params);

The parameter type definition can refer to ./src/type.ts:

export interface MergeVideoParams {
  urls: Array<string>;
  outputSize?: {
    width: number;
    height: number;
  };
  backgroundColor?: string;
}

The outputSize and backgroundColor are optional properties.

The promise result type definition can refer to ./src/type.ts, It should be noted here that there are differences between the two platforms for the reject(...) function, may need add a filter logic in src/index.tsx.

export interface VideoMergeEvent {
  errorCode: number;
  errorDescription: string;
  outputFilePath: string;
  progress: number;
}

Notification progress to JavaScript/TypeScript

For native modue (it's easy than UI component), we can directly use event sender function to send to JavaScript layer, document is here: Native Modules / Android / Sending Events to JavaScript.

The event name is RNVideoSDK:dataFromNative, and the event data type is also VideoMergeEvent.

Consider some performance limitations of React Native UI (especially the old architecture), the iOS version native module limit sending progress every 200ms.

API for clear cachr dir

Every time the video merge interface is called, a video file is created in the local sandbox cache directory, we provide a convenience function here to clear all cached video files.

Just need to provide such an interface:

await VideoMerger.cleanCacheDir({});

Version History

v1.0.5-0

  • Fix iOS platform black image between videos for special video case (wrong video package format).

License

MIT


Made with create-react-native-library