All Projects → AnJoiner → Ffmpegcommand

AnJoiner / Ffmpegcommand

Licence: apache-2.0
FFmpegCommand适用于Android的FFmpeg命令库,实现了对音视频相关的处理,能够快速的处理音视频,大概功能包括:音视频剪切,音视频转码,音视频解码原始数据,音视频编码,视频转图片或gif,视频添加水印,多画面拼接,音频混音,视频亮度和对比度,音频淡入和淡出效果等

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Ffmpegcommand

Ffmediatoolkit
FFMediaToolkit is a cross-platform video decoder/encoder library for .NET that uses FFmpeg native libraries. It supports video frames extraction, reading stream metadata and creating videos from bitmaps in any format supported by FFmpeg.
Stars: ✭ 156 (-60.41%)
Mutual labels:  ffmpeg, decoder, encoder, mp4
Bbwebimage
A high performance Swift library for downloading, caching and editing web images asynchronously.
Stars: ✭ 128 (-67.51%)
Mutual labels:  gif, decoder, encoder
Axiom
An FFmpeg GUI for Windows
Stars: ✭ 560 (+42.13%)
Mutual labels:  ffmpeg, encoder, mp4
Gifify
😻 Convert any video file to an optimized animated GIF.
Stars: ✭ 5,792 (+1370.05%)
Mutual labels:  ffmpeg, gif, mp4
AnimatedGif
📼 A high performance .NET library for reading and creating animated GIFs
Stars: ✭ 106 (-73.1%)
Mutual labels:  encoder, decoder, gif
Sickbeard mp4 automator
Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library
Stars: ✭ 1,142 (+189.85%)
Mutual labels:  ffmpeg, media, mp4
Jave2
The JAVE (Java Audio Video Encoder) library is Java wrapper on the ffmpeg project
Stars: ✭ 570 (+44.67%)
Mutual labels:  ffmpeg, decoder, encoder
live-stream-media-source-extensions
Live stream h264 encoded mp4 video on media source extensions using ffmpeg, node.js, socket.io, and express. Works in chrome, firefox, safari, and android. Not iOS compatible. Work has moved to mse-live-player repo =>
Stars: ✭ 24 (-93.91%)
Mutual labels:  ffmpeg, mp4, media
Screen Recorder Ffmpeg Cpp
*Multimedia project* A screen recording application to capture your desktop and store in a video format. Click here to watch the demo
Stars: ✭ 98 (-75.13%)
Mutual labels:  ffmpeg, encoder, encoder-decoder
Gifserver
A server for transcoding gif to video on the fly
Stars: ✭ 100 (-74.62%)
Mutual labels:  ffmpeg, gif, mp4
Image deionising auto encoder
Noise removal from images using Convolutional autoencoder
Stars: ✭ 34 (-91.37%)
Mutual labels:  encoder, decoder, encoder-decoder
canvas-capture
Record the canvas as an image, mp4 video, or gif from the browser
Stars: ✭ 35 (-91.12%)
Mutual labels:  ffmpeg, mp4, gif
Real-Time-Video-Streaming
a real time streaming video application using RTSP
Stars: ✭ 15 (-96.19%)
Mutual labels:  ffmpeg, decoder
mp4
🎥 Basic MP4 reader in Go! CLI + Golang Package for ISO/IEC 14496-12 - ISO Base Media File Format
Stars: ✭ 75 (-80.96%)
Mutual labels:  mp4, media
poc-mp4-websocket
Streaming MP4 over Websocket using BMFF
Stars: ✭ 25 (-93.65%)
Mutual labels:  ffmpeg, mp4
p5.rec
🍿 p5.rec lets you record your p5.js sketches and convert them to mp4 in your browser ▶️
Stars: ✭ 70 (-82.23%)
Mutual labels:  ffmpeg, mp4
morse-pro
Library for manipulating Morse code text and sound. Understands prosigns and Farnsworth speed. Can create WAV files and analyse input from the microphone or audio files.
Stars: ✭ 85 (-78.43%)
Mutual labels:  encoder, decoder
schifra
C++ Reed Solomon Error Correcting Library https://www.schifra.com
Stars: ✭ 28 (-92.89%)
Mutual labels:  encoder, decoder
IkigaJSON
A high performance JSON library in Swift
Stars: ✭ 316 (-19.8%)
Mutual labels:  encoder, decoder
Flask Session Cookie Manager
🍪 Flask Session Cookie Decoder/Encoder
Stars: ✭ 257 (-34.77%)
Mutual labels:  decoder, encoder

FFmpegCommand

To users of FFmpegCommand:

First of all, thank you all for your support of this library. Thank you for using it so that we have the motivation to continue to open source. Thank you for your questions and make this library more perfect.

Asynchronous processing and multi-code execution were provided before 1.2.0, but many people reported that it is impossible to perform asynchronous and multi-code is not very useful, so after repeated consideration, the following changes will be made in 1.2.0 and later versions :

  • Delete the runCmdAsync and runCmdSync methods and change them to runCmd to execute the FFmpeg command
  • Delete multi-command runMoreAsync and runMoreSync methods, runCmd internally realizes automatic synchronization and sequential execution
  • Added error log prompt, use ffmpeg-cmd to filter the error log when an error occurs

We apologize for the inconvenience caused by this modification.

【README-中文】

Summary

In our development, audio and video related content is often used, generally we will choose FFmpeg, but its cross-compilation is a very troublesome thing for us . So here for the convenience of future use, I wrote this FFmpegCommand, FFmpegCommand is composed of FFmpeg core library, and integrates lame, libx264, fdk-aac and libopencore-amr mainstream audio and video processing Android program Note: The current library is only available for Android

If you can’t access all the information, please go to【Domestic Mirror】

The main function

Download License FFmpeg X264 mp3lame fdk-aac fdk-aac

  • Support all FFmpeg commands
  • Support video format conversion : mp4->flv
  • Support audio codec : mp3->pcm pcm->mp3 pcm->aac
  • Support audio transcoding : mp3->aac mp3->amr
  • Support video codec : mp4->yuv yuv->h264
  • Support video transcoding : mp4->flv mp4->avi
  • Support cutting and splicing of audio and video
  • Support video to picture : mp4->png mp4->gif
  • Support audio sound size control and mixing (such as reading sound plus background music)
  • Support some filters, audio fade in, fade out effects, video brightness and contrast, and add watermark
  • Support for generating silent audio
  • Support for obtaining media file information
  • Support continuous execution of FFmpeg commands
Run FFmpeg Get media information
图-1:命令行展示 图-2:命令行执行

Introduce

Choose only one of the following two introductions, and replace the following according to the latest version ${latestVersion},Current latest version Download

// All codecs-larger size
implementation 'com.coder.command:ffmpeg:${latestVersion}'
// Some commonly used codecs-smaller in size, about 6M less than the introduction above
implementation 'com.coder.command:ffmpeg-mini:${latestVersion}'

Change build.gradle under module, the current library only supports armeabi-v7a and arm64-v8a, of course you can use only one (usually using armeabi-v7a for backward compatibility). You can Can refer to 【Android ABI】

android {
    defaultConfig {
        ndk {
            abiFilters "armeabi-v7a",'arm64-v8a'
            moduleName "app"
        }
    }
}

If there is no special codec requirement, it is strongly recommended to use ffmpeg-mini

Of course, if you have special coding and decoding requirements, or have high requirements on the size of the package, you can contact me through the group below for private customization. Of course, this customization is paid, after all, it is not easy to code, the time is like an arrow~~

Use

FFmpegCommand Method

Method Function
FFmpegCommand->setDebug(debug: Boolean) Debug mode, printable log
FFmpegCommand->runCmd(cmd: Array<String?>) Execute ffmpeg command without callback
FFmpegCommand->runCmd(cmd: Array<String?> callBack: IFFmpegCallBack?) Execute ffmpeg command and call back start, complete, cancel, progress, error
FFmpegCommand->getMediaInfo(path: String?, @MediaAttribute type: Int) Get media information: video width and height, bit rate...
FFmpegCommand->getSupportFormat(@FormatAttribute formatType: Int) Get the encapsulation and decapsulation formats supported by the current library
FFmpegCommand->getSupportCodec(@CodecAttribute codecType: Int) Get the codec supported by the current library
FFmpegCommand->cancel() Exit FFmpeg command execution

runCmd

Use runCmd to call FFmpeg to execute FFmpeg commands synchronously. External threads need to be added, otherwise the application will become unresponsive. Direct call FFmpegCommand.runCmd(cmd: Array<String?> callBack: IFFmpegCallBack?) method,The first parameter is provided by the FFmpegUtils tool class, or you can add it yourself

Does not support asynchronous execution of FFmpeg commands, after all, C is a process-oriented language, and resource occupation problems will occur

GlobalScope.launch {
    FFmpegCommand.runCmd(FFmpegUtils.transformAudio(audioPath, targetPath), callback("transcoding complete", targetPath))
}

The second parameter is the callback method

open class CommonCallBack : IFFmpegCallBack {
    // Start callback
    override fun onStart() {}
    // Progress callback
    override fun onProgress(progress: Int, pts: Long) {}
    // Cancel callback
    override fun onCancel() {}
    // Complete callback
    override fun onComplete() {}
    // Error callback
    override fun onError(errorCode: Int, errorMsg: String?) {}
}

It should be noted that in the onProgress method, you can see that the callback returns 2 values:

  • progress:progress, calculated by referring to the first input file (that is the input file after the first -i), and it may be incorrect when there are multiple input files
  • pts:Elapsed time, progress appears incorrectly using the current value for calculation, the calculation method is as follows
var duration :Int? = FFmpegCommand.getMediaInfo(mAudioPath,MediaAttribute.DURATION)
var progress = pts/duration!!

Custom FFmpeg command

This is just a demonstration of audio cutting, many functions such as the above, please refer to it yourself FFmpegUtils If the requirements are not met, you can add your own FFmpeg command, E.g:

var command = "ffmpeg -y -i %s -vn -acodec copy -ss %d -t %d %s"
command = String.format(command, srcFile, startTime, duration, targetFile)

GlobalScope.launch {
    FFmpegCommand.runCmd(command.split(" ").toTypedArray(), callback("Audio cut is complete", targetPath))
}

Multi-process execution

Since the bottom layer is temporarily unable to implement multithreading (after all, C is a process-oriented language), if you need to push the stream at the same time, it is impossible to execute other commands at the same time. To solve this problem, you can use the following multi-process method:

  1. Define other processes different from the main process
<service android:name=".service.FFmpegCommandService" android:process=":ffmpegCommand" />
<service android:name=".service.FFmpegCommandService2" android:process=":ffmpegCommand2" />
  1. Perform push operations in other processes
class FFmpegCommandService : Service() {
    override fun onBind(intent: Intent): IBinder? {
        return null
    }

    override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
        val videoPath = File(externalCacheDir, "test.mp4").absolutePath
        val output = File(externalCacheDir, "output.yuv").absolutePath
        val cmd = "ffmpeg -y -i %s -an -c:v rawvideo -pixel_format yuv420p %s"
        val result = String.format(Locale.CHINA, cmd, videoPath, output)
        val strings: Array<String?> = result.split(" ").toTypedArray()
        FFmpegCommand.runCmd(strings)
        return super.onStartCommand(intent, flags, startId)
    }
}

Cancel execution

After executing the following method, the CommonCallBack->onCancel() method will be called back

FFmpegCommand.cancel();

【common problem】

【new version update】

Reference

【KFFmpegCommandActivity-Command reference】 【KFFmpegInfoActivity-Media Information Reference】 【KFFmppegFormatActivity-Support package format】 【KFFmpegCodecActivity-Support codec】

Compatibility

Compatible with Android minSdkVersion >=21

图-7 Demo下载 图-8 Demo下载 图-9 Demo下载

Compile SO

【Compile FFmpeg for use in Android】 【Custom MP3 encoder】

Experiential exchange

Scan code to download|click to download communication WeChat appreciation
图-4 Demo下载 图-4 Demo下载 图-5 赞赏

Star

If you think it is helpful to you, give a star to support it, and welcome a lot of forks!

Confuse

-keep class com.coder.ffmpeg.** {*;}
-dontwarn  com.coder.ffmpeg.**

License

Copyright 2019 AnJoiner

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].