# FFmpeg **Repository Path**: HarmonyOS-tpc/FFmpeg ## Basic Information - **Project Name**: FFmpeg - **Description**: No description available - **Primary Language**: Unknown - **License**: LGPL-2.1 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2021-09-17 - **Last Updated**: 2024-12-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README FFmpeg ================== ## Introduction FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata. ### Libraries include * `libavcodec` provides implementation of a wider range of codecs. * `libavformat` implements streaming protocols, container formats and basic I/O access. * `libavutil` includes hashers, decompressors and miscellaneous utility functions. * `libavfilter` provides a mean to alter decoded Audio and Video through chain of filters. * `libavdevice` provides an abstraction to access capture and playback devices. * `libswresample` implements audio mixing and resampling routines. * `libswscale` implements color conversion and scaling routines. ### Tools * [ffmpeg](https://ffmpeg.org/ffmpeg.html) is a command line toolbox to manipulate, convert and stream multimedia content. FFmpeg binary is built using native ndk tools. It supports many features by default, to further customize and to add additional external codecs refer [here](https://github.com/Javernaut/ffmpeg-android-maker) Once the ffmpeg binary is ready, copy the linux Binary to Resource asset folder. ## Usage Instructions STEP1: Load the ffmpeg library ``` private boolean loadFFmpegBinary() { try { ffmpeg.loadBinary(new LoadBinaryResponseHandler() { @Override public void onFailure() { LogUtil.error(TAG, "loadFFmpegBinary failed"); } @Override public void onSuccess() { binLoaded = true; LogUtil.info(TAG, "loadFFmpegBinary Success"); } }); } catch (FFmpegNotSupportedException e) { LogUtil.error(TAG, e.getMessage()); } } ``` STEP2: Execute the ffmpeg command ``` private void execFFmpegBinary(final String[] command) { try { ffmpeg.execute(command, new ExecuteBinaryResponseHandler() { @Override public void onFailure(String s) { LogUtil.error(TAG, "execFFmpegBinary failed"); } @Override public void onSuccess(String s) { LogUtil.info(TAG, "execFFmpegBinary success"); } }); } catch (FFmpegCommandAlreadyRunningException e) { // do nothing for now LogUtil.error(TAG, e.getMessage()); } } } ``` ## Installation Instructions ``` Method 1. Add the dependencies in entry/build.gradle to generate ffmpeg library har as below: dependencies { implementation project(':ffmpegharmony') } Method 2. Add ffmpeg library har file to entry/libs and add below line to include har file as dependency in entry/build.gradle file. dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) } Method 3. For using FFmpeg from a remote repository in separate application, add the below dependency in entry/build.gradle file. dependencies { implementation 'io.openharmony.tpc.thirdlib:FFmpeg:1.0.1' } ``` Note, new openharmony version comes with selinux, i.e. security enhaced linux, which discourage applications to include and run any linux executable. as ffmpeg binary is linux executable, so ffmpeg commands may fail. Hence before we run ffmpeg command, make sure you run the hdc command "hdc shell setenforce 0", which disables security feature. ## License FFmpeg codebase is mainly LGPL-licensed with optional components licensed under GPL. Please refer to the LICENSE file for detailed information. ffmpeg required features are based on or derives from projects below: - LGPL - [FFmpeg](https://github.com/FFmpeg/FFmpeg) - MIT - [ffmpeg-android-maker](https://github.com/Javernaut/ffmpeg-android-maker) - LGPLv3 - [ffmpeg-android-java](https://github.com/WritingMinds/ffmpeg-android-java) FFmpeg is also based on other different projects under various licenses, which I have no idea whether they are compatible to each other or to your product. [IANAL](https://en.wikipedia.org/wiki/IANAL), you should always ask your lawyer for these stuffs before use it in your product.