This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val rect = cropFrame.cropRect | |
val width = abs(rect.left - rect.right) | |
val height = abs(rect.top - rect.bottom) | |
val x = rect.left | |
val y = rect.top |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun stringForTime(timeMs: Float): String { | |
val totalSeconds = (timeMs / 1000).toInt() | |
val seconds = totalSeconds % 60 | |
val minutes = totalSeconds / 60 % 60 | |
val hours = totalSeconds / 3600 | |
val mFormatter = Formatter() | |
return if (hours > 0) { | |
mFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString() | |
} else { | |
mFormatter.format("%02d:%02d", minutes, seconds).toString() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val command = arrayOf("-y", "-i", inputPath, "-ss", startPosition, "-to", endPosition, "-c", "copy", outputPath) | |
//inputPath - Path of the source video | |
//startPosition - Start position in "%d:%02d:%02d" format | |
//endPosition - End position in "%02d:%02d" format | |
//copy - Copies the result to outputPath | |
//outputPath - Path of the destination |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val command = arrayOf("-i", inputPath, "-filter:v", "crop=$width:$height:$x:$y", "-threads", "5", "-preset", "ultrafast", "-strict", "-2", "-c:a", "copy", outputPath) | |
//inputPath - Path of the source video | |
//crop - Crop with desired Rect values (width, height, x, y) | |
//threads - Number of threads that can be utilised to process the video | |
//preset - ultrafast mode is used for reducing the time taken | |
//copy - Copies the result to outputPath | |
//outputPath - Path of the destination |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun initialize() { | |
val ffmpeg = FFmpeg.getInstance(ctx.applicationContext) | |
try { | |
ffmpeg.loadBinary(object : LoadBinaryResponseHandler() { | |
override fun onFinish() { | |
super.onFinish() | |
} | |
override fun onSuccess() { | |
super.onSuccess() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ff = FFmpeg.getInstance(ctx) | |
ff.loadBinary(object : FFmpegLoadBinaryResponseHandler { | |
override fun onFinish() { | |
Log.e("FFmpegLoad", "onFinish") | |
} | |
override fun onSuccess() { | |
Log.e("FFmpegLoad", "onSuccess") | |
val command = //TODO: command for video options. | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
implementation fileTree(dir: 'libs', include: ['*.jar']) | |
implementation 'com.writingminds:FFmpegAndroid:0.3.2' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val mainHandler = Handler() | |
val url = "YOUR_VIDEO_URL" | |
val bandwidthMeter = DefaultBandwidthMeter() | |
val videoTrackSelectionFactory = AdaptiveTrackSelection.Factory(bandwidthMeter) | |
val trackSelector = DefaultTrackSelector(videoTrackSelectionFactory) | |
val player = ExoPlayerFactory.newSimpleInstance(this, trackSelector) | |
videoView.player = player | |
val dataSourceFactory = DefaultDataSourceFactory(this, Util.getUserAgent(this, "ZohoSocial"), bandwidthMeter) | |
val videoSource = if (url.contains(".m3u8")) HlsMediaSource(Uri.parse(url), dataSourceFactory, mainHandler, null) | |
else ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val url = "YOUR_VIDEO_URL" | |
val player = ExoPlayerFactory.newSimpleInstance(this) | |
videoView.player = player | |
val dataSourceFactory = DefaultDataSourceFactory(this, Util.getUserAgent(this, "ZohoSocial")) | |
val mediaSource = if (url.contains(".m3u8")) DashMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url)) | |
else ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url)) | |
player.prepare(mediaSource) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Bitmap | |
import com.zomato.photofilters.imageprocessors.ImageProcessor | |
import com.zomato.photofilters.imageprocessors.SubFilter | |
class BrightnessSubFilter(brightness: Int) : SubFilter { | |
// Value is in integer | |
private var brightness = 0 | |
init { | |
this.brightness = brightness |