umair13adil / kotlinffmpeg Goto Github PK
View Code? Open in Web Editor NEWExamples of using FFMpeg library on Android with Kotlin
Home Page: http://umairadil.com/
License: GNU General Public License v3.0
Examples of using FFMpeg library on Android with Kotlin
Home Page: http://umairadil.com/
License: GNU General Public License v3.0
I get CANNOT LINK EXECUTABLE ffmpeg: has text relocations running Api >23
how to fix that?
Can you add code for Convert .gif to .mp4
Salam, Adil bhai thanks for this library
I need help with merging, i have 1 video with audio and other video has no audio wo when i merge the video that has no audio it gives me this exception
Stream specifier ':a' in filtergraph description [0:v]setpts=PTS-STARTPTS,setsar=1,setdar=4/3,scale=640x480[v0]; [0:a]asetpts=PTS-STARTPTS[a0];[1:v]setpts=PTS-STARTPTS,setsar=1,setdar=4/3,scale=640x480[v1]; [1:a]asetpts=PTS-STARTPTS[a1];[v0][a0][v1][a1]concat=n=2:v=1:a=1[v][a] matches no streams.
for specific info :
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from'/storage/emulated/0/Movies/Metal_Wind_Chimes_at_Sunset.mp4':
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 28037 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 157 kb/s (default)
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Movies/AbstractRotatingCubesVidevo.mov':
Stream #1:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 13097 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
Stream #1:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default) Here there is no audio in this video
Please tell me how can i merge the video having no audio as well, Thanks
@umair13adil : Hi, it would be possible to use this module, on a video that is online (http), the video weighs 658 (mb)?
ffmpeg java android stop working in android 10
so please make another incredible git repo with ffmpeg mobile
thanks in advance man
Hi, It is really Nice project.I am not understanding how to add to my project or how to use this.
means any gradle line for integrate this library.
Thanks in advance
How to combine sound with a video file with original audio video? Or how combine two sound?
Can you please help me out i wand to add transition between videos
i want to achive something like this
https://www.youtube.com/watch?v=INiRu2_XdJE
https://www.youtube.com/watch?v=V-lL1MTPkSQ
fun mergeWithFade() {
if (videos == null || videos!!.isEmpty()) {
callback!!.onFailure(IOException("File not exists"))
return
}
for (v in videos!!) {
if (!v.canRead()) {
callback!!.onFailure(IOException("Can't read the file. Missing permission?"))
return
}
}
val outputLocation = getConvertedFile(outputPath, outputFileName)
val inputCommand = arrayListOf<String>()
//Add all paths
for (i in videos!!) {
inputCommand.add("-i")
inputCommand.add(i.path)
}
//Apply filter graph
inputCommand.add("-filter_complex")
//Compose concatenation commands
val stringBuilder = StringBuilder()
// stringBuilder.append("[1:v][0:v]blend=all_expr='A*(if(gte(T,3),1,T/3))+B*(1-(if(gte(T,3),1,T/3)))'[v0];");
for (i in 0 until videos!!.size) {
val fade = Constant.DURATION_FADE_TRANSITION;
val mp = MediaPlayer.create(context, Uri.fromFile(videos!!.get(i)))
val duration = mp.duration / 1000
mp.release()
val startDuration = duration - fade;
stringBuilder.append("[$i:v]fade=type=out:duration=" + Constant.DURATION_FADE_TRANSITION + ":start_time=" + startDuration + ",setpts=PTS-STARTPTS,setsar=1,scale='min(480,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,pad=480:320:(ow-iw)/2:(oh-ih)/2[v$i]; [$i:a]afade=type=out:duration=" + Constant.DURATION_FADE_TRANSITION + ":start_time=" + startDuration + ",asetpts=PTS-STARTPTS[a$i];");
}
for (i in 0 until videos!!.size) {
stringBuilder.append("[v$i][a$i]")
}
// Concat command
stringBuilder.append("concat=n=${videos!!.size}:v=1:a=1[v][a]")
//Complete Command
val cmd = arrayOf<String>(
"-map",
"[v]",
"-map",
"[a]",
"-preset", //Presets can be ultrafast, superfast, veryfast, faster, fast, medium (default), slow and veryslow.
"ultrafast", //Using a slower preset gives you better compression, or quality per file size.
"-crf", //Constant Rate Factor
"23", //Value from 0 to 51, 23 is default, Large Value for highest quality
outputLocation.path,
"-y" //Overwrite output files without asking
)
val finalCommand = (inputCommand + stringBuilder.toString() + cmd).toTypedArray()
try {
FFmpeg.getInstance(context).execute(finalCommand, object : ExecuteBinaryResponseHandler() {
override fun onStart() {}
override fun onProgress(message: String?) {
callback!!.onProgress(message!!)
}
override fun onSuccess(message: String?) {
refreshGallery(outputLocation.path, context)
callback!!.onSuccess(outputLocation, OutputType.TYPE_VIDEO)
}
override fun onFailure(message: String?) {
if (outputLocation.exists()) {
outputLocation.delete()
}
callback!!.onFailure(IOException(message))
}
override fun onFinish() {
callback!!.onFinish()
}
})
} catch (e: Exception) {
callback!!.onFailure(e)
} catch (e2: FFmpegCommandAlreadyRunningException) {
callback!!.onNotAvailable(e2)
}
}
I'm very interested in your example, I wanna convert images to video. So, FFMpeg can do it?
If so, please guide , if you can. Thanks
I'm using VideoResizer
. How can I kill ongoing resizing task & start a new one.
How we can merge audio and video with trim option like start time and endtime both in one command call?
I am trying add the text to video. But always calling onFailure method?
What it is the problem?
file path : Correct
video path : Correct
I'm using VideoResizer
. The output video is
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
What I want is
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (mp41/mp42/isom)
current cmd
is
I've tried using (reference 8.5.2 Examples)
val cmd = arrayOf("-i", video!!.path, "-c:a", "libfdk_aac", "-profile:a", "aac_he", "-b:a", "64k", "scale=" + size, outputLocation.path) /*, "-hide_banner"*/
I've got following error
java.io.IOException: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/DCIM/Camera/20180731_115412.mp4':
Metadata:
07-31 16:30:18.049 17290-17290/com.riglynx.riglynx.test W/System.err: major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2018-07-31 06:24:19
location : +23.0260+072.5079/
location-eng : +23.0260+072.5079/
com.android.version: 7.0
Duration: 00:00:05.63, start: 0.000000, bitrate: 17341 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 17051 kb/s, SAR 1:1 DAR 16:9, 29.98 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2018-07-31 06:24:19
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
Metadata:
creation_time : 2018-07-31 06:24:19
handler_name : SoundHandle
[NULL @ 0xf052f600] Unable to find a suitable output format for 'scale=720:1280'
scale=720:1280: Invalid argument
How can I get my desire output
Thanks.
Hi, can you confirm if this works on Android API level 30 and above should we still use this library or switch to new FFmpegKit
Using this library (or others), is it possible to merge audio&video together, so that the output video will be of the same duration as the input video, and have the audio loop if it's shorter than the video?
I've asked about it here too:
https://stackoverflow.com/q/54769976/878126
Hello,
May I know if I need to place the FFMPEG binary file somewhere before I can use your code? Or, putting the two lines on Gradle does the work?
Thanks.
Getting Error
java.io.IOException: Cannot run program "/data/user/0/com.ps.giffy/files/ffmpeg": error=2, No such file or directory
I copied my selected file into My app folder and I want to save all extracted images into that folder but getting this above error.
Is it possible to have the time duration between images set so that it varies from one image to another. For example, in the code used to create a video from the png files, it uses a framerate of 3.784 seconds. Can I set the time for the first frame to say 1 second, the time on the second frame to 3 seconds, the time on the third frame to 7 seconds, etc?
Can this library be used to convert .Ts video to .mp4?.
permission denied and error 13 came to my side why?
How can we merge multiple audio files using ffmpeg?
Using MovieMaker.kt class convert() i need to give aspect ratio for image original size i dont want to fit in full screen so, its stretching my images.
Added "-preset", "ultrafast" commands. But this commands works for video trim alone. Not improving processing speed of play back speed, add text, add sticker & merge two videos. For 4-5 minutes video file it takes more than 5 minute processing time. It is too long.
Did anyone facing same issue as this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.