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

Anjdroid video ediutor #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion compileSdk
compileSdkVersion 30
defaultConfig {
applicationId "com.obs.marveleditor"
minSdkVersion minSdk
minSdkVersion 21
targetSdkVersion targetSdk
versionCode 1
versionCode 2
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
Expand All @@ -36,15 +36,20 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlinVersion}"

implementation "com.android.support:appcompat-v7:${appCompat}"
implementation "com.android.support.constraint:constraint-layout:${constraint}"
implementation "com.android.support:design:${appCompat}"
implementation "androidx.appcompat:appcompat:${appCompat}"
implementation "androidx.constraintlayout:constraintlayout:${constraint}"
implementation "androidx.cardview:cardview:${cardView}"
implementation 'com.google.android.material:material:1.2.1'

//exoplayer
//implementation "com.google.android.exoplayer:exoplayer:${exoPlayer}"
implementation "com.google.android.exoplayer:exoplayer-core:${exoPlayerCore}"
implementation "com.google.android.exoplayer:exoplayer-dash:${exoPlayer}"
implementation "com.google.android.exoplayer:exoplayer-ui:${exoPlayer}"

// RecyclerView
implementation "androidx.recyclerview:recyclerview:${recyclerView}"

//ffmpeg
implementation "com.writingminds:FFmpegAndroid:${FFmpeg}"
implementation "org.jcodec:jcodec-android:${jcodec}"
Expand All @@ -61,7 +66,7 @@ dependencies {
//fresco
implementation "com.facebook.fresco:fresco:${fresco}"

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
tools:node="replace"/>
<uses-permission android:name="com.android.providers.media.MediaProvider"/>

<uses-sdk tools:overrideLibrary="com.github.guilhe.views.rangedseekbar" />

<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down Expand Up @@ -48,7 +50,7 @@

<!--FileProvider-->
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/obs/marveleditor/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package com.obs.marveleditor

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import com.facebook.drawee.backends.pipeline.Fresco
import com.obs.marveleditor.fragments.OptiMasterProcessorFragment

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/obs/marveleditor/OptiSplashScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package com.obs.marveleditor
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity

class OptiSplashScreen : AppCompatActivity() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import com.obs.marveleditor.videoTrimmer.OptiHgLVideoTrimmer;
import com.obs.marveleditor.videoTrimmer.interfaces.OptiOnHgLVideoListener;
import com.obs.marveleditor.videoTrimmer.interfaces.OptiOnTrimVideoListener;
Expand Down
55 changes: 46 additions & 9 deletions app/src/main/java/com/obs/marveleditor/OptiVideoEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class OptiVideoEditor private constructor(private val context: Context) {
private var audioFile: File? = null
//for filter
private var filterCommand: String? = null
//for merge
private var width: String? = null
private var height: String? = null
private var textFile: File? = null
private var isMP4: Boolean? = false

companion object {
fun with(context: Context): OptiVideoEditor {
Expand Down Expand Up @@ -123,6 +128,18 @@ class OptiVideoEditor private constructor(private val context: Context) {
return this
}

fun setFileWidthHeight(width: String, height: String): OptiVideoEditor {
this.width = width
this.height = height
return this
}

fun setTextFile(file: File, isMP4: Boolean): OptiVideoEditor {
textFile = file
this.isMP4 = isMP4
return this
}

fun setSize(size: String): OptiVideoEditor {
this.size = size
return this
Expand Down Expand Up @@ -199,28 +216,43 @@ class OptiVideoEditor private constructor(private val context: Context) {
cmd = arrayOf(
"-y", "-i", videoFile!!.path, "-vf",
"drawtext=fontfile=" + font!!.path + ": text=" + text + ": fontcolor=" + color + ": fontsize=" + size + border + ": " + position,
"-c:v", "libx264", "-c:a", "copy", "-movflags", "+faststart", outputFile.path)
"-c:v", "libx264", "-crf", "23", "-preset", "ultrafast", "-c:a", "copy", "-movflags", "+faststart", outputFile.path)
}

OptiConstant.VIDEO_CLIP_ART_OVERLAY -> {
//Clipart overlay on video - Need video file, image path, position to apply & output file
cmd = arrayOf("-y", "-i", videoFile!!.path, "-i", imagePath!!, "-filter_complex", position!!, "-codec:a", "copy", outputFile.path)
cmd = arrayOf("-y", "-i", videoFile!!.path, "-i", imagePath!!, "-filter_complex", position!!,
"-c:v", "libx264", "-crf", "23", "-preset", "ultrafast", "-codec:a", "copy", outputFile.path)
}

OptiConstant.MERGE_VIDEO -> {
//Merge videos - Need two video file, approx video size & output file
cmd = arrayOf("-y", "-i", videoFile!!.path, "-i", videoFileTwo!!.path, "-strict", "experimental", "-filter_complex",
/*cmd = arrayOf("-y", "-i", videoFile!!.path, "-i", videoFileTwo!!.path, "-strict", "experimental", "-filter_complex",
"[0:v]scale=iw*min(1920/iw\\,1080/ih):ih*min(1920/iw\\,1080/ih), pad=1920:1080:(1920-iw*min(1920/iw\\,1080/ih))/2:(1080-ih*min(1920/iw\\,1080/ih))/2,setsar=1:1[v0];[1:v] scale=iw*min(1920/iw\\,1080/ih):ih*min(1920/iw\\,1080/ih), pad=1920:1080:(1920-iw*min(1920/iw\\,1080/ih))/2:(1080-ih*min(1920/iw\\,1080/ih))/2,setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1",
"-ab", "48000", "-ac", "2", "-ar", "22050", "-s", "1920x1080", "-vcodec", "libx264", "-crf", "27",
"-q", "4", "-preset", "ultrafast", outputFile.path)
"-ab", "48000", "-ac", "2", "-ar", "22050", "-s", "1920x1080", "-vcodec", "-c:v", "libx264", "-crf", "23",
"-preset", "veryfast", outputFile.path)*/
cmd = if(!isMP4!!) {
//concat video filter for other video format files
arrayOf(
"-y", "-i", videoFile!!.path, "-i", videoFileTwo!!.path, "-filter_complex",
"[0:v]setsar=1:1[v0];[1:v]scale=$width:$height,setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1",
"-c:v", "libx264", "-crf", "23", "-preset", "ultrafast", outputFile.path
)
} else {
//concat demuxer - for mp4 video format files
arrayOf("-y", "-f", "concat", "-safe", "0", "-i", textFile!!.path,
"-c:v", "libx264", "-crf", "23", "-preset", "ultrafast", "-c:a", "copy", "-strict", "-2", outputFile.path)
}
}

OptiConstant.VIDEO_PLAYBACK_SPEED -> {
//Video playback speed - Need video file, speed & tempo value according to playback and output file
cmd = if (havingAudio) {
arrayOf("-y", "-i", videoFile!!.path, "-filter_complex", ffmpegFS!!, "-map", "[v]", "-map", "[a]", outputFile.path)
arrayOf("-y", "-i", videoFile!!.path, "-filter_complex", ffmpegFS!!, "-map", "[v]", "-map", "[a]",
"-c:v", "libx264", "-crf", "23", "-preset", "ultrafast", outputFile.path)
} else {
arrayOf("-y", "-i", videoFile!!.path, "-filter:v", ffmpegFS!!, outputFile.path)
arrayOf("-y", "-i", videoFile!!.path, "-filter:v", ffmpegFS!!,
"-c:v", "libx264", "-crf", "23", "-preset", "ultrafast", outputFile.path)
}
}

Expand All @@ -236,7 +268,11 @@ class OptiVideoEditor private constructor(private val context: Context) {

OptiConstant.VIDEO_TRIM -> {
//Video trim - Need video file, start time, end time & output file
cmd = arrayOf("-y", "-i", videoFile!!.path, "-ss", startTime, "-t", endTime, "-c", "copy", outputFile.path)
//-t will have the duration (in seconds) that we want to trim from startTime
Log.v(tagName, "final: $startTime, $endTime")
//cmd = arrayOf("-y", "-i", videoFile!!.path, "-ss", startTime, "-t", endTime, "-c", "copy", outputFile.path)
cmd = arrayOf("-y", "-i", videoFile!!.path, "-ss", startTime, "-t", endTime, "-c", "copy",
"-preset", "ultrafast", outputFile.path)
}

OptiConstant.VIDEO_TRANSITION -> {
Expand All @@ -246,7 +282,8 @@ class OptiVideoEditor private constructor(private val context: Context) {

OptiConstant.CONVERT_AVI_TO_MP4 -> {
//Convert .avi to .mp4 - Need avi video file, command, mp4 output file
cmd = arrayOf("-y", "-i", videoFile!!.path, "-c:v", "libx264", "-crf", "19", "-preset", "slow", "-c:a", "aac", "-b:a", "192k", "-ac", "2", outputFile.path)
//cmd = arrayOf("-y", "-i", videoFile!!.path, "-c:v", "libx264", "-crf", "19", "-preset", "slow", "-c:a", "aac", "-b:a", "192k", "-ac", "2", outputFile.path)
cmd = arrayOf("-y", "-i", videoFile!!.path, "-c:v", "libx264", "-crf", "19", "-preset", "ultrafast", "-c:a", "aac", "-b:a", "192k", "-ac", "2", outputFile.path)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ package com.obs.marveleditor.adapter
import android.content.Context
import android.graphics.Color
import android.net.Uri
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.appcompat.widget.AppCompatImageView
import androidx.recyclerview.widget.RecyclerView
import com.obs.marveleditor.R
import com.obs.marveleditor.interfaces.OptiClipArtListener
import java.io.File
Expand Down Expand Up @@ -64,6 +65,6 @@ class OptiClipArtAdapter(clipArtList: ArrayList<String>, val context: Context, o
}

class MyPostViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var tvClipArt: ImageView = itemView.findViewById(R.id.tv_clip_art)
var tvClipArt: AppCompatImageView = itemView.findViewById(R.id.tv_clip_art)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ package com.obs.marveleditor.adapter
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
import android.support.constraint.ConstraintLayout
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.appcompat.widget.AppCompatTextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.recyclerview.widget.RecyclerView
import com.facebook.drawee.view.SimpleDraweeView
import com.obs.marveleditor.R
import com.obs.marveleditor.interfaces.OptiFilterListener
Expand Down Expand Up @@ -64,7 +65,7 @@ class OptiFilterAdapter(filterList: ArrayList<String>, bitmap: Bitmap, val conte
}

class MyPostViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var tvFilter: TextView = itemView.findViewById(R.id.tvFilter)
var tvFilter: AppCompatTextView = itemView.findViewById(R.id.tvFilter)
var ivFilter: SimpleDraweeView = itemView.findViewById(R.id.ivFilter)
var clFilter: ConstraintLayout = itemView.findViewById(R.id.clFilter)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ package com.obs.marveleditor.adapter

import android.content.Context
import android.graphics.Color
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.RecyclerView
import com.obs.marveleditor.R
import com.obs.marveleditor.interfaces.OptiPlaybackSpeedListener
import com.obs.marveleditor.utils.OptiConstant
Expand Down Expand Up @@ -95,6 +96,6 @@ class OptiPlaybackSpeedAdapter(private val playbackList: ArrayList<String>, val
}

class MyPostViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var tvSpeed: TextView = itemView.findViewById(R.id.tv_speed)
var tvSpeed: AppCompatTextView = itemView.findViewById(R.id.tv_speed)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ package com.obs.marveleditor.adapter

import android.content.Context
import android.graphics.Color
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.RecyclerView
import com.obs.marveleditor.R
import com.obs.marveleditor.interfaces.OptiPositionListener

Expand Down Expand Up @@ -63,6 +64,6 @@ class OptiPositionAdapter(positionList: ArrayList<String>, val context: Context,
}

class MyPostViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var tvSpeed: TextView = itemView.findViewById(R.id.tv_speed)
var tvSpeed: AppCompatTextView = itemView.findViewById(R.id.tv_speed)
}
}
Loading