Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- #13 issue fixed #14

Merged
merged 1 commit into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ FFmpeg Android runs on the following architectures:

```
dependencies {
implementation 'com.github.SimformSolutionsPvtLtd:SSffmpegVideoOperation:1.0.5'
implementation 'com.github.SimformSolutionsPvtLtd:SSffmpegVideoOperation:1.0.6'
}
```

Expand All @@ -86,7 +86,7 @@ This is all you have to do to load the FFmpeg library.
In this sample code we will run the FFmpeg -version command in background call.
```java
val query:Array<String> = "-i, input,....,...., outout"
CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun statisticsProcess(statistics: Statistics) {
Log.i("FFMPEG LOG : ", statistics.videoFrameNumber)
}
Expand All @@ -108,12 +108,12 @@ In this sample code we will run the FFmpeg -version command in background call.



#### Inbuild query example
#### In-build query example
```java
val startTimeString = "00:01:00" (HH:MM:SS)
val endTimeString = "00:02:00" (HH:MM:SS)
val query:Array<String> = FFmpegQueryExtension.cutVideo(inputPath, startTimeString, endTimeString, outputPath)
CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
val query:Array<String> = FFmpegQueryExtension().cutVideo(inputPath, startTimeString, endTimeString, outputPath)
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun statisticsProcess(statistics: Statistics) {
Log.i("FFMPEG LOG : ", statistics.videoFrameNumber)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.util.concurrent.CyclicBarrier
* Created by Ashvin Vavaliya on 22,January,2021
* Simform Solutions Pvt Ltd.
*/
object CallBackOfQuery {
public class CallBackOfQuery {
fun callQuery(context: AppCompatActivity, query: Array<String>, fFmpegCallBack: FFmpegCallBack) {
val gate = CyclicBarrier(2)
object : Thread() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.text.TextUtils
import androidx.appcompat.app.AppCompatActivity
import com.jaiselrahman.filepicker.activity.FilePickerActivity
import com.jaiselrahman.filepicker.config.Configurations
import com.simform.videooperations.FFmpegQueryExtension.FRAME_RATE
import java.io.File
import java.io.FileInputStream
import java.io.IOException
Expand Down Expand Up @@ -84,7 +83,7 @@ object Common {
val mime = format.getString(MediaFormat.KEY_MIME)
if (mime?.startsWith("video/") == true) {
if (format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
FRAME_RATE = format.getInteger(MediaFormat.KEY_FRAME_RATE)
FFmpegQueryExtension().FRAME_RATE = format.getInteger(MediaFormat.KEY_FRAME_RATE)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package com.simform.videooperations
* Created by Ashvin Vavaliya on 10,December,2020
* Simform Solutions Pvt Ltd.
*/
object FFmpegQueryExtension {
var FRAME_RATE: Int = 25 // Default value
public class FFmpegQueryExtension {
public var FRAME_RATE: Int = 25 // Default value

/**
* startTime = 00:00:00 HH:MM:SS
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.VideoImageEditor">
<activity android:name=".otherFFMPEGProcessActivity.CompressAudioActivity">

</activity>
<activity android:name=".otherFFMPEGProcessActivity.CompressAudioActivity"
android:screenOrientation="portrait" />
<activity
android:name=".otherFFMPEGProcessActivity.CropAudioActivity"
android:screenOrientation="portrait" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.jaiselrahman.filepicker.activity.FilePickerActivity
import com.jaiselrahman.filepicker.model.MediaFile
import com.simform.videoimageeditor.utils.utils.addSupportActionBar
import com.simform.videooperations.FFmpegQueryExtension
import com.simform.videooperations.FileSelection

/**
Expand All @@ -22,11 +22,13 @@ abstract class BaseActivity(view: Int, title: Int) : AppCompatActivity(), View.O
var width: Int? = 0
var mediaFiles: List<MediaFile>? = null
var retriever: MediaMetadataRetriever? = null
val utils = Utils()
val ffmpegQueryExtension = FFmpegQueryExtension()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(layoutView)
addSupportActionBar(this, toolbarTitle)
utils.addSupportActionBar(this, toolbarTitle)
initialization()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.simform.videoimageeditor
import android.view.View
import com.simform.videoimageeditor.middlewareActivity.OtherFFMPEGProcessActivity
import com.simform.videoimageeditor.middlewareActivity.VideoProcessActivity
import com.simform.videoimageeditor.utils.utils.openActivity
import kotlinx.android.synthetic.main.activity_main.imageGifOperation
import kotlinx.android.synthetic.main.activity_main.videoOperation

Expand All @@ -19,10 +18,10 @@ class MainActivity : BaseActivity(R.layout.activity_main, R.string.ffpmeg_title)
override fun onClick(v: View?) {
when (v?.id) {
R.id.videoOperation -> {
openActivity(this, VideoProcessActivity())
utils.openActivity(this, VideoProcessActivity())
}
R.id.imageGifOperation -> {
openActivity(this, OtherFFMPEGProcessActivity())
utils.openActivity(this, OtherFFMPEGProcessActivity())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.simform.videoimageeditor.utils
package com.simform.videoimageeditor

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity

/**
* Created by Ashvin Vavaliya on 22,January,2021
* Created by Ashvin Vavaliya on 06,July,2021
* Simform Solutions Pvt Ltd.
*/
object utils {
class Utils {
fun addSupportActionBar(context: AppCompatActivity, title: Int) {
if (context.supportActionBar != null) {
context.supportActionBar?.setDisplayHomeAsUpEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.simform.videoimageeditor.otherFFMPEGProcessActivity.CompressAudioActi
import com.simform.videoimageeditor.otherFFMPEGProcessActivity.CropAudioActivity
import com.simform.videoimageeditor.otherFFMPEGProcessActivity.FastAndSlowAudioActivity
import com.simform.videoimageeditor.otherFFMPEGProcessActivity.MergeGIFActivity
import com.simform.videoimageeditor.utils.utils.openActivity
import kotlinx.android.synthetic.main.activity_other_ffmpeg_process.btnAudiosVolumeUpdate
import kotlinx.android.synthetic.main.activity_other_ffmpeg_process.btnCompressAudio
import kotlinx.android.synthetic.main.activity_other_ffmpeg_process.btnCutAudio
Expand All @@ -31,22 +30,22 @@ class OtherFFMPEGProcessActivity : BaseActivity(R.layout.activity_other_ffmpeg_p
override fun onClick(v: View?) {
when (v?.id) {
R.id.btnMergeGIF -> {
openActivity(this, MergeGIFActivity())
utils.openActivity(this, MergeGIFActivity())
}
R.id.btnMergeAudios -> {
openActivity(this, AudiosMergeActivity())
utils.openActivity(this, AudiosMergeActivity())
}
R.id.btnAudiosVolumeUpdate -> {
openActivity(this, ChangeAudioVolumeActivity())
utils.openActivity(this, ChangeAudioVolumeActivity())
}
R.id.btnFastAndSlowAudio -> {
openActivity(this, FastAndSlowAudioActivity())
utils.openActivity(this, FastAndSlowAudioActivity())
}
R.id.btnCutAudio -> {
openActivity(this, CropAudioActivity())
utils.openActivity(this, CropAudioActivity())
}
R.id.btnCompressAudio -> {
openActivity(this, CompressAudioActivity())
utils.openActivity(this, CompressAudioActivity())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.simform.videoimageeditor.middlewareActivity
import android.view.View
import com.simform.videoimageeditor.BaseActivity
import com.simform.videoimageeditor.R
import com.simform.videoimageeditor.utils.utils.openActivity
import com.simform.videoimageeditor.videoProcessActivity.*
import kotlinx.android.synthetic.main.activity_video_process.*

Expand Down Expand Up @@ -38,61 +37,61 @@ class VideoProcessActivity : BaseActivity(R.layout.activity_video_process, R.str
override fun onClick(v: View?) {
when (v?.id) {
R.id.btnCutVideo -> {
openActivity(this, CutVideoUsingTimeActivity())
utils.openActivity(this, CutVideoUsingTimeActivity())
}
R.id.btnImageToVideo -> {
openActivity(this, ImageToVideoConvertActivity())
utils.openActivity(this, ImageToVideoConvertActivity())
}
R.id.btnAddWaterMarkOnVideo -> {
openActivity(this, AddWaterMarkOnVideoActivity())
utils.openActivity(this, AddWaterMarkOnVideoActivity())
}
R.id.btnCombineImageVideo -> {
openActivity(this, CombineImageAndVideoActivity())
utils.openActivity(this, CombineImageAndVideoActivity())
}
R.id.btnCombineImages -> {
openActivity(this, CombineImagesActivity())
utils.openActivity(this, CombineImagesActivity())
}
R.id.btnCombineVideos -> {
openActivity(this, CombineVideosActivity())
utils.openActivity(this, CombineVideosActivity())
}
R.id.btnCompressVideo -> {
openActivity(this, CompressVideoActivity())
utils.openActivity(this, CompressVideoActivity())
}
R.id.btnExtractVideo -> {
openActivity(this, ExtractImagesActivity())
utils.openActivity(this, ExtractImagesActivity())
}
R.id.btnExtractAudio -> {
openActivity(this, ExtractAudioActivity())
utils.openActivity(this, ExtractAudioActivity())
}
R.id.btnMotion -> {
openActivity(this, FastAndSlowVideoMotionActivity())
utils.openActivity(this, FastAndSlowVideoMotionActivity())
}
R.id.btnReverseVideo -> {
openActivity(this, ReverseVideoActivity())
utils.openActivity(this, ReverseVideoActivity())
}
R.id.btnFadeInFadeOutVideo -> {
openActivity(this, VideoFadeInFadeOutActivity())
utils.openActivity(this, VideoFadeInFadeOutActivity())
}
R.id.btnVideoConvertIntoGIF -> {
openActivity(this, VideoToGifActivity())
utils.openActivity(this, VideoToGifActivity())
}
R.id.btnVideoRotateFlip -> {
openActivity(this, VideoRotateFlipActivity())
utils.openActivity(this, VideoRotateFlipActivity())
}
R.id.btnMergeVideoAndAudio -> {
openActivity(this, MergeAudioVideoActivity())
utils.openActivity(this, MergeAudioVideoActivity())
}
R.id.btnAddTextOnVideo -> {
openActivity(this, AddTextOnVideoActivity())
utils.openActivity(this, AddTextOnVideoActivity())
}
R.id.btnRemoveAudioFromVideo -> {
openActivity(this, RemoveAudioFromVideoActivity())
utils.openActivity(this, RemoveAudioFromVideoActivity())
}
R.id.btnMergeImageAndAudio -> {
openActivity(this, MergeImageAndMP3Activity())
utils.openActivity(this, MergeImageAndMP3Activity())
}
R.id.btnSetAspectRatio -> {
openActivity(this, AspectRatioActivity())
utils.openActivity(this, AspectRatioActivity())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class AudiosMergeActivity : BaseActivity(R.layout.activity_audios_merge, R.strin
pathsList.add(paths)
}

val query = FFmpegQueryExtension.mergeAudios(pathsList, DURATION_FIRST, outputPath)
val query = ffmpegQueryExtension.mergeAudios(pathsList, DURATION_FIRST, outputPath)

CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun process(logMessage: LogMessage) {
tvOutputPath.text = logMessage.text
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class ChangeAudioVolumeActivity : BaseActivity(R.layout.activity_change_audio_va

private fun mergeAudioProcess() {
val outputPath = Common.getFilePath(this, Common.MP3)
val query = FFmpegQueryExtension.audioVolumeUpdate(tvInputPathAudio.text.toString(), volume = 0.1f, outputPath)
CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
val query = ffmpegQueryExtension.audioVolumeUpdate(tvInputPathAudio.text.toString(), volume = 0.1f, output = outputPath)
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun process(logMessage: LogMessage) {
tvOutputPath.text = logMessage.text
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class CompressAudioActivity : BaseActivity(R.layout.activity_compress_audio, R.s

private fun compressAudioProcess() {
val outputPath = Common.getFilePath(this, Common.MP3)
val query = FFmpegQueryExtension.compressAudio(inputAudioPath = tvInputPathAudio.text.toString(), bitrate = BITRATE_128, output = outputPath)
CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
val query = ffmpegQueryExtension.compressAudio(inputAudioPath = tvInputPathAudio.text.toString(), bitrate = BITRATE_128, output = outputPath)
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun process(logMessage: LogMessage) {
tvOutputPath.text = logMessage.text
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class CropAudioActivity : BaseActivity(R.layout.activity_crop_audio, R.string.cr
@SuppressLint("SetTextI18n")
private fun cutProcess() {
val outputPath = Common.getFilePath(this, Common.MP3)
val query = FFmpegQueryExtension.cutAudio(tvInputPath.text.toString(), startTimeString, endTimeString, outputPath)
CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
val query = ffmpegQueryExtension.cutAudio(tvInputPath.text.toString(), startTimeString, endTimeString, outputPath)
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun process(logMessage: LogMessage) {
tvOutputPath.text = logMessage.text
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class FastAndSlowAudioActivity : BaseActivity(R.layout.activity_fast_and_slow_au
if (!motionType.isChecked) {
atempo = 0.5
}
val query = FFmpegQueryExtension.audioMotion(tvInputPathAudio.text.toString(), outputPath, atempo)
CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
val query = ffmpegQueryExtension.audioMotion(tvInputPathAudio.text.toString(), outputPath, atempo)
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun process(logMessage: LogMessage) {
tvOutputPath.text = logMessage.text
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ class MergeGIFActivity : BaseActivity(R.layout.activity_merge_gif, R.string.merg
val heightScale = height?.let { height ->
(edtYScale.text.toString().toFloat().times(height)).div(100)
}
val query = FFmpegQueryExtension.mergeGIF(pathsList, xPos, yPos, widthScale, heightScale, outputPath)
val query = ffmpegQueryExtension.mergeGIF(pathsList, xPos, yPos, widthScale, heightScale, outputPath)

CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun process(logMessage: LogMessage) {
tvOutputPath.text = logMessage.text
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class AddTextOnVideoActivity : BaseActivity(R.layout.activity_add_text_on_video,
(edtYPos.text.toString().toFloat().times(it)).div(100)
}
val fontPath = getFileFromAssets(this, "little_lord.ttf").absolutePath
val query = FFmpegQueryExtension.addTextOnVideo(tvInputPathVideo.text.toString(), edtText.text.toString(), xPos, yPos, fontPath = fontPath, true, 28, "red", outputPath)
CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
val query = ffmpegQueryExtension.addTextOnVideo(tvInputPathVideo.text.toString(), edtText.text.toString(), xPos, yPos, fontPath = fontPath, isTextBackgroundDisplay = true, fontSize = 28, fontcolor = "red", output = outputPath)
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun process(logMessage: LogMessage) {
tvOutputPath.text = logMessage.text
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.simform.videooperations.Common.VIDEO
import com.simform.videooperations.Common.getFilePath
import com.simform.videooperations.Common.selectFile
import com.simform.videooperations.FFmpegCallBack
import com.simform.videooperations.FFmpegQueryExtension.addVideoWaterMark
import com.simform.videooperations.LogMessage
import java.util.concurrent.CompletableFuture.runAsync
import kotlinx.android.synthetic.main.activity_add_water_mark_on_video.btnAdd
Expand Down Expand Up @@ -110,8 +109,8 @@ class AddWaterMarkOnVideoActivity : BaseActivity(R.layout.activity_add_water_mar
val yPos = height?.let {
(edtYPos.text.toString().toFloat().times(it)).div(100)
}
val query = addVideoWaterMark(tvInputPathVideo.text.toString(), tvInputPathImage.text.toString(), xPos, yPos, outputPath)
CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
val query = ffmpegQueryExtension.addVideoWaterMark(tvInputPathVideo.text.toString(), tvInputPathImage.text.toString(), xPos, yPos, outputPath)
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun process(logMessage: LogMessage) {
tvOutputPath.text = logMessage.text
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class AspectRatioActivity : BaseActivity(R.layout.activity_aspect_ratio, R.strin

private fun applyRatioProcess() {
val outputPath = Common.getFilePath(this, Common.VIDEO)
val query = FFmpegQueryExtension.applyRatio(tvInputPathVideo.text.toString(), RATIO_1, outputPath)
val query = ffmpegQueryExtension.applyRatio(tvInputPathVideo.text.toString(), RATIO_1, outputPath)

CallBackOfQuery.callQuery(this, query, object : FFmpegCallBack {
CallBackOfQuery().callQuery(this, query, object : FFmpegCallBack {
override fun process(logMessage: LogMessage) {
tvOutputPath.text = logMessage.text
}
Expand Down
Loading