Coder Social home page Coder Social logo

ffmpeg-android's Introduction

FFmpeg-Android

Download Buy us a beer

FFMpeg/FFprobe compiled for Android. Execute FFmpeg & FFprobe commands with ease in your Android project.

About

This project is a continued fork of FFmpeg Android Java by WritingMinds. This fork fixes the CANNOT LINK EXECUTABLE ffmpeg: has text relocations issue on x86 devices along with some other bugfixes, new features and the newest FFmpeg builds.

Architectures

Bravobit FFmpeg-Android runs on the following architectures:

  • armv7
  • armv7-neon
  • armv8
  • x86
  • x86_64

FFmpeg build

FFmpeg in this project was built with the following libraries:

  • x264 r2851 ba24899
  • libpng 1.6.21
  • freetype2 2.8.1
  • libmp3lame 3.100
  • libvorbis 1.3.5
  • libvpx v1.6.1-1456-g7d1bf5d
  • libopus 1.2.1
  • fontconfig 2.11.94
  • libass 0.14.0
  • fribidi 0.19.7
  • expat 2.1.0
  • fdk-aac 0.1.6

Features

  • Uses the latest FFmpeg release n4.0-39-gda39990
  • Uses native CPU capabilities on ARM architectures
  • FFprobe is bundled in this library too
  • Enabled network capabilities
  • Multithreading

Usage

Getting Started

Include the dependency

dependencies {
    implementation 'nl.bravobit:android-ffmpeg:1.1.7'
}

Check if FFmpeg is supported

To check whether FFmpeg is available on your device you can use the following method.

if (FFmpeg.getInstance(this).isSupported()) {
  // ffmpeg is supported
} else {
  // ffmpeg is not supported
}

This is all you have to do to load the FFmpeg library.

Run FFmpeg command

In this sample code we will run the ffmpeg -version command.

FFmpeg ffmpeg = FFmpeg.getInstance(context);
  // to execute "ffmpeg -version" command you just need to pass "-version"
ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {

    @Override
    public void onStart() {}

    @Override
    public void onProgress(String message) {}

    @Override
    public void onFailure(String message) {}

    @Override
    public void onSuccess(String message) {}

    @Override
    public void onFinish() {}

});

Stop (or Quit) the FFmpeg process

If you want to stop the running FFmpeg process, simply call .sendQuitSignal() on the FFtask that is running:

FFmpeg ffmpeg = FFmpeg.getInstance(context);
FFtask ffTask = ffmpeg.execute( ... )

ffTask.sendQuitSignal();

NOTE: This will result in onFailure being called instead of onSuccess.

Check if FFprobe is supported

To check whether FFprobe is available on your device you can use the following method.

if (FFprobe.getInstance(this).isSupported()) {
  // ffprobe is supported
} else {
  // ffprobe is not supported
}

This is all you have to do to load the FFprobe library.

Run FFprobe command

In this sample code we will run the ffprobe -version command.

FFprobe ffprobe = FFprobe.getInstance(context);
// to execute "ffprobe -version" command you just need to pass "-version"
ffprobe.execute(cmd, new ExecuteBinaryResponseHandler() {

    @Override
    public void onStart() {}

    @Override
    public void onProgress(String message) {}

    @Override
    public void onFailure(String message) {}

    @Override
    public void onSuccess(String message) {}

    @Override
    public void onFinish() {}

});

Special Thanks To

Licensing

ffmpeg-android's People

Contributors

brianvdb avatar joshuapinter avatar stanvanheumen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ffmpeg-android's Issues

Building FFmpeg executable from source

Hi,
I can see that you've fixed the text relocations issue on x86 devices. but I want to know how you fixed this and can you share the steps or commands you used for this fix?

FFmpeg compiling sources

Any chance to get the sources to compile ffmpeg with linux?
I would need to compile it with fewer libraries to reduce its size, but i'm really struggling into doing that.

Is there any way to improve process time?

Hi @Brianvdb , How can I improve process time?

  • I execute this command to join videos and add overlay, speed about 0.6. How can I improve it?
    String overlay = "-i " + video1 + " -i " + video2 + " -i " + exclusivePhoto + " -filter_complex [0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[vv][a];[vv][2:v]overlay=0:0[v] -map [v] -map [a] -b:v 3650000";

X.265 HEVC codec

Hi,

is it possible to use your FFmpeg build to process x.265 mp4 videos? In the readme is only a support for x.265 declared.

I tried it, but I've got only a strange error message. All x.264 encoded mp4 video worked well without a problem.
Format mov,mp4,m4a,3gp,3g2,mj2 detected only with low score of 1, misdetection possible!
moov atom not found
Invalid data found when processing input

If it isn't possible with your build, can you give me a hint how I can use FFmpeg on Android with x.265 encoded videos? Should I compile my own version of FFmpeg or did you know a simpler way.

config file

I search too much to find a build bash for making ffmpeg prebuilt but every time I want to use to final result I got so many errors like :
error: only position independent executables (PIE) are supported.

so could you please give us your configuration build bash .
I try to use from but I couldn't

especially thanks.

Support h264_mediacodec on amlogic S905

Hi bravobit. Thank you for the project.

I see that you configure ffmpeg with hwaccel enabled. But when I run it on my S905 it doesn't seem to deligate to hw decoder.

I am getting a Rockchip to test on. But do I need to specifically use -hwaccel h264_mediacodec in the command. Is it an amlogic bug, or is it just your ffmpeg wasn't compiled with this option on?

Thank you.

HTTPS links fail to load

Getting this error when trying to load https links

https protocol not found, recompile FFmpeg with openssl, gnutls or securetransport enabled.

Would be great if https support is added, because without it network capabilities of the library are quite limited.

Maximize CPU usage/Improve performance

Even a simple command like

ffmpeg -i convert.mp4 toThis.mkv

For converting a small video file to another format takes an insane amount of time, I routinely see a ~25MB file taking upwards of 30 minutes to finish (and about ~700 of my users have explicitly told me the same).

Upon investigating, I noticed in the profiler that the CPU usage never rises above 1-2% which seems a little shocking. I'm not sure what a 'fix' for this would be like.

How do we tell android "Hey! This is important! Give it everything you got!"

Any ideas?

How can I use this with streaming media?

Hi there, I'm new to FFmpeg. I just want to use ffprobe to get some info from streaming media on android. I write my codes on this sample module and run it on my device, but I get an error log which says Protocol not found. Can you please help me with this? Thx a lot.

BTW, my command array is this:

{"-v", "error", "-show_entries", "stream=codec_name,height,width:format=filename,format_name", "-of", "json", "http://223.75.11.92:9090/live/cctv1hd_1500.m3u8"}

And I do it well on my Mac's terminal, which is:

ffprobe -v error -show_entries stream=codec_name,height,width:format=filename,format_name -of json http://223.75.11.92:9090/live/cctv1hd_1500.m3u8

And the snapshot of the error log:
screen shot 2018-01-18 at 20 28 27
screen shot 2018-01-18 at 20 29 57

Argument FFcommandExecuteAsyncTask for isCommandRunning()

I'm using the latest version 1.1.2 and I need to check if ffmpeg is already running a command, isCommandRunning() needs an argument of type FFcommandExecuteAsyncTask but FFmpeg.execute() returns an object of type FFTask.

In previous version (1.0.4) isCommandRunning() didn't have any argument.

Same with the killRunningProcesses() method.

Would you mind to upload dynamic(.so) & static(.a) libraries also?

I asked because when I am executing binary with cmds. Its working fine till, I am not closing screen. but when I press poweroff button, then process stopped suddenly. I was thinking may be I load .so file & execute cmd from JNI, then may be it will work. or may be you can fix poweroff process kill issue.

AAC support

When I try to convert input file to an HLS stream I get "Unknown encoder 'libfdk_aac'" error. I tried to explicitly add '-c:a aac' to use builtin aac converter instead of libfdk but it didn't help. Is it because libavcodec is not included? Can you build ffmpeg with it? Or am I missing something?

aac support

Hello,

It is possible to add aac support for libffmpeg.so?
I tried to add it, but even if using fdk-aac or vo-aacenc libraries, I cannot play the aac files.

Many thanks.

Well, when I try to execute the ffmpeg it tells me the following error, it could help me.

FFmpeg: Exception while trying to run: [/data/app/com.example.trabajo.democameradraw-2/lib/arm/ffmpeg.so, -version] java.io.IOException: Error running exec(). Command: [/data/app/com.example.trabajo.democameradraw-2/lib/arm/ffmpeg.so, -version] Working Directory: null Environment: null
I already gave him the permissions in the manifiest of reading and writing



cuando se inicializa el ffmpeg es obligatorio hacerlo en la activity principal. por que necesito usarlo en otra activity?
protected void onCreate(Bundle savedInstanceState) {
if (FFmpeg.getInstance(this).isSupported()) {
ffmpeg= FFmpeg.getInstance(this);
// ffmpeg is supported
} else {
Log.d("Ffmpeg","Este dispositivo no soporta Ffmpeg");
// ffmpeg is not supported
}

execFFmpegBinary(new String[]{"-version"}, 0);

private void execFFmpegBinary(final String[] command, final int type) {
if (ffmpeg == null) {
Log.d("Tag", "ffmpeg : null");
ffmpeg = FFmpeg.getInstance(X00000011111.this);
}
try {
ffmpeg.getInstance(this).execute(command, new ExecuteBinaryResponseHandler() {
@OverRide
public void onFailure(String s) {
Log.d("TAG", "FAILED with output : " + s);
runOnUiThread(
new Runnable() {
@OverRide
public void run() {
new MaterialDialog.Builder(X00000011111.this)
.title(R.string.Information)

            }

            @Override
            public void onSuccess(String s) {
                Log.d("TaG", "SUCCESS with output :" + s);

            }

ARM support enhancement for ARM-v7 and ARM-v8 with libx264

Hello,

Using the FFMPEG executable from this project I notice in the logs that it is using "cpu capabilities: ARMv6-neon" on devices with arm v7 and v8 CPUs. This of course gives a great performance boost against "using cpu capabilities: none!" but I was wondering if there could be even more performance in case libx264 could use the full capabilities of the CPU.

Thanks in advance for your response.

java.io.FileNotFoundException: x86/ffmpeg

Thanks for your helpful ffmpeg library for Android and your contributions. I was able to run ffmpeg command from past few days. But unfortunately, I am getting the following error.
D/FFmpeg: Build.CPU_ABI : x86
D/FFmpeg: file does not exist, creating it...
E/FFmpeg: error while opening assets
java.io.FileNotFoundException: x86/ffmpeg
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:374)
at android.content.res.AssetManager.open(AssetManager.java:348)
at nl.bravobit.ffmpeg.FFmpeg.isSupported(FFmpeg.java:65)

How to reproduce this error?
I am not sure but I clear the emulator data and from then onwards I am not able to run FFMpeg commands. I clearly understand this library support x86 architecture. So, I don't this there is any problem. Kindly have a look and let me know if there is anything needed from my side.

Kindly ignore the issue. I was as i was using ignoreAssetsPattern "!ffprobe:!x86:" and after the data is cleared i lost the ffmpeg file.

How to exclude both ffprobe and arm/ffmpeg?

This would cut my debug build apk sizes in half. I don't use ffprobe at all, so I don't want it in the debug builds and I dev mostly on emulator so no point in shipping arm binary.

I've tried the following

            ignoreAssetsPattern "!ffprobe:!arm"

And it doesn't work, but

            ignoreAssetsPattern "!ffprobe"

and

            ignoreAssetsPattern "!arm"

do work individually. But what I want is only ffmpeg in x86, any ideas?

Support APK fragmentation?

The library adds 30Mb to my app.

I was wondering if there was a way to exclude the ARM binary assets in a development productFlavor (since I mostly develop on emulators which are x86). I'm not sure how this works for a library.

Thoughts?

Support OPUS?

Were the binaries compiled with --enable-libopus? I see opus as one of the listed codecs but when doing a simple conversion, say

ffmpeg -i "input.mp3" -acodec libopus -strict -2 "output.opus"

The ffmpeg process gets stuck after spitting out the input file metadata and the only way to stop it is to kill the process.

Also, do you think it would be possible to release the binary compilation configuration? That way other devs can just fork and add their own binaries with their own preferred configuration, instead of bloating this library.

Subtitle support

compile ffmpeg with --enable-libass flags to enable hardcoding subtitles and other features

File Not Found IOException

For some reason the FFMPEG binary is not located on the /data/data/my.app.package/files
So whenever I try to use th FFMPEG I get
java.io.IOException: Error running exec(). Command: [/data/data/my.app.package/files/ffmpeg (...) ] Working Directory: null Environment: null

It used to work ok, but I had some major changes on other parts of the apps combined with a new SSD and now it's broken. Any idea?

Removing audio from video

@Brianvdb
Gradle: implementation 'nl.bravobit:android-ffmpeg:1.1.5'

I get following in logs :
[mp4 @ 0xb8e5d550] Non-monotonous DTS in output stream 0:0; previous: 19, current: 0; changing to 20. This may result in incorrect timestamps in the output file.

When I try to remove the audio from video using the command:
-y -i /storage/emulated/0/video_trimmed.mp4 -an -vcodec copy /storage/emulated/0/no_audio.mp4 ,

Also, the video has a little glitch between starting 0 to 2 seconds !!

how to generate the file in your project

well ,thank you very much, how to generate the file in your project(android-ffmepg) below the arm or x86 using the FFmpeg 3.4.1. I want to generate file using FFmpeg 3.3.6.but I don't know how to generate ,I only can produce the file ffmpeg.so file .please help me .thank you ,thank you very much

Could not crop the video with ratio height = width of device

Hi ,
I am trying to use this library to fix the x86 issues on Android 7. However, I have the below issue.

When tried to crop the video with this setting, it throws an error
String[] cmds = new String[]{"-i", file.getAbsolutePath(), "-filter:v", "crop=out_h=in_w", croppedUrl};

Error:
cropVideo:onProgress(): Failed to set value 'crop=out_h=in_w' for option 'filter:v': Option not found.

Please could you help to get this work?

[Question] What did you do to solve

I'm having the same problem with CANNOT LINK EXECUTABLE ffmpeg: has text relocations would you mind to share what did you to fix the problem?

Which compiler parameters did you use and which ffmpeg configuration...

thanks

Trimming video: incorrect duration

@Brianvdb

When I try to trim a video to 3 sec the output video becomes 01 mins :23 sec

Following is the command for trimming: (88 and 91 are the start and end time in seconds)
-y -i /storage/emulated/0/abc.mp4 -ss 88 -t 91 -async 1 -c copy /storage/emulated/0/video_trimmed.mp4

Video file details:
Duration: 02 mins 51 secs
Size: 1280x720

Below are the logs:

TrimUtil -- > Cmd : -y -i /storage/emulated/0/abc.mp4 -ss 88 -t 91 -async 1 -c copy /storage/emulated/0/video_trimmed.mp4
 D/FFmpeg: Build.CPU_ABI : arm64-v8a
D/FFmpeg: ffmpeg is ready!
TrimUtil -- > FFMPEG isSupported
TrimUtil -- > FFMPEG onStart

D/FFmpeg: Running publishing updates method
TrimUtil -- > FFMPEG progress:ffmpeg version n3.4.2-9-ga877ab7 Copyright (c) 2000-2018 the FFmpeg developers
TrimUtil -- > FFMPEG progress:  built with gcc 4.9.x (GCC) 20150123 (prerelease)
TrimUtil -- > FFMPEG progress:  configuration: --target-os=linux --cross-prefix=/root/bravobit/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/root/bravobit/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-fontconfig --enable-libass --enable-libvpx --enable-ffprobe --enable-yasm --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-linux-perf --disable-doc --disable-shared --enable-static --enable-runtime-cpudetect --enable-nonfree --enable-network --enable-avresample --enable-avformat --enable-avcodec --enable-indev=lavfi --enable-hwaccels --enable-ffmpeg --enable-zlib --enable-gpl --enable-small --pkg-config=/root/bravobit/ffmpeg-android/ffmpeg-pkg-config --prefix=/root/bravobit/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/root/bravobit/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/root/bravobit/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-cxxflags= --extra-libs='-lpng -lx264 -lexpat -lm -logg'
TrimUtil -- > FFMPEG progress:  libavutil      55. 78.100 / 55. 78.100
TrimUtil -- > FFMPEG progress:  libavcodec     57.107.100 / 57.107.100
TrimUtil -- > FFMPEG progress:  libavformat    57. 83.100 / 57. 83.100
TrimUtil -- > FFMPEG progress:  libavdevice    57. 10.100 / 57. 10.100
TrimUtil -- > FFMPEG progress:  libavfilter     6.107.100 /  6.107.100
TrimUtil -- > FFMPEG progress:  libavresample   3.  7.  0 /  3.  7.  0
TrimUtil -- > FFMPEG progress:  libswscale      4.  8.100 /  4.  8.100
TrimUtil -- > FFMPEG progress:  libswresample   2.  9.100 /  2.  9.100
TrimUtil -- > FFMPEG progress:  libpostproc    54.  7.100 / 54.  7.100
TrimUtil -- > FFMPEG progress:Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/abc.mp4':
TrimUtil -- > FFMPEG progress:  Metadata:
TrimUtil -- > FFMPEG progress:    major_brand     : isom
TrimUtil -- > FFMPEG progress:    minor_version   : 512
TrimUtil -- > FFMPEG progress:    compatible_brands: isomiso2avc1mp41
TrimUtil -- > FFMPEG progress:    creation_time   : 1970-01-01T00:00:00.000000Z
TrimUtil -- > FFMPEG progress:    encoder         : Lavf53.24.2
TrimUtil -- > FFMPEG progress:  Duration: 00:02:50.86, start: 0.000000, bitrate: 1474 kb/s
TrimUtil -- > FFMPEG progress:    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1086 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
TrimUtil -- > FFMPEG progress:    Metadata:
TrimUtil -- > FFMPEG progress:      creation_time   : 1970-01-01T00:00:00.000000Z
TrimUtil -- > FFMPEG progress:      handler_name    : VideoHandler
TrimUtil -- > FFMPEG progress:    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
TrimUtil -- > FFMPEG progress:    Metadata:
TrimUtil -- > FFMPEG progress:      creation_time   : 1970-01-01T00:00:00.000000Z
TrimUtil -- > FFMPEG progress:      handler_name    : SoundHandler
TrimUtil -- > FFMPEG progress:Output #0, mp4, to '/storage/emulated/0/video_trimmed.mp4':
TrimUtil -- > FFMPEG progress:  Metadata:
TrimUtil -- > FFMPEG progress:    major_brand     : isom
TrimUtil -- > FFMPEG progress:    minor_version   : 512
TrimUtil -- > FFMPEG progress:    compatible_brands: isomiso2avc1mp41
TrimUtil -- > FFMPEG progress:    encoder         : Lavf57.83.100
TrimUtil -- > FFMPEG progress:    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1086 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
TrimUtil -- > FFMPEG progress:    Metadata:
TrimUtil -- > FFMPEG progress:      creation_time   : 1970-01-01T00:00:00.000000Z
TrimUtil -- > FFMPEG progress:      handler_name    : VideoHandler
TrimUtil -- > FFMPEG progress:    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
TrimUtil -- > FFMPEG progress:    Metadata:
TrimUtil -- > FFMPEG progress:      creation_time   : 1970-01-01T00:00:00.000000Z
TrimUtil -- > FFMPEG progress:      handler_name    : SoundHandler
TrimUtil -- > FFMPEG progress:Stream mapping:
TrimUtil -- > FFMPEG progress:  Stream #0:0 -> #0:0 (copy)
TrimUtil -- > FFMPEG progress:  Stream #0:1 -> #0:1 (copy)
TrimUtil -- > FFMPEG progress:Press [q] to stop, [?] for help
TrimUtil -- > FFMPEG progress:frame= 1978 fps=0.0 q=-1.0 size=   14592kB time=00:01:20.25 bitrate=1489.5kbits/s speed= 161x    
TrimUtil -- > FFMPEG progress:frame= 2042 fps=0.0 q=-1.0 Lsize=   15212kB time=00:01:22.83 bitrate=1504.3kbits/s speed= 161x    
TrimUtil -- > FFMPEG progress:video:11277kB audio:3888kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.306889%
TrimUtil -- > FFMPEG onSuccess:ffmpeg version n3.4.2-9-ga877ab7 Copyright (c) 2000-2018 the FFmpeg developers
      built with gcc 4.9.x (GCC) 20150123 (prerelease)
      configuration: --target-os=linux --cross-prefix=/root/bravobit/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/root/bravobit/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-fontconfig --enable-libass --enable-libvpx --enable-ffprobe --enable-yasm --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-linux-perf --disable-doc --disable-shared --enable-static --enable-runtime-cpudetect --enable-nonfree --enable-network --enable-avresample --enable-avformat --enable-avcodec --enable-indev=lavfi --enable-hwaccels --enable-ffmpeg --enable-zlib --enable-gpl --enable-small --pkg-config=/root/bravobit/ffmpeg-android/ffmpeg-pkg-config --prefix=/root/bravobit/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/root/bravobit/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/root/bravobit/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-cxxflags= --extra-libs='-lpng -lx264 -lexpat -lm -logg'
      libavutil      55. 78.100 / 55. 78.100
      libavcodec     57.107.100 / 57.107.100
      libavformat    57. 83.100 / 57. 83.100
      libavdevice    57. 10.100 / 57. 10.100
      libavfilter     6.107.100 /  6.107.100
      libavresample   3.  7.  0 /  3.  7.  0
      libswscale      4.  8.100 /  4.  8.100
      libswresample   2.  9.100 /  2.  9.100
      libpostproc    54.  7.100 / 54.  7.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/abc.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        creation_time   : 1970-01-01T00:00:00.000000Z
        encoder         : Lavf53.24.2
      Duration: 00:02:50.86, start: 0.000000, bitrate: 1474 kb/s
        Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1086 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
        Metadata:
          creation_time   : 1970-01-01T00:00:00.000000Z
          handler_name    : VideoHandler
        Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
        Metadata:
          creation_time   : 1970-01-01T00:00:00.000000Z
          handler_name    : SoundHandler
    Output #0, mp4, to '/storage/emulated/0/video_trimmed.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf57.83.100
        Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1086 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
        Metadata:
          creation_time   : 1970-01-01T00:00:00.000000Z
          handler_name    : VideoHandler
        Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
05-28 18:20:07.584 3488-3488/com.example.ritesh.exoplayertrim I/System.out:     Metadata:
          creation_time   : 1970-01-01T00:00:00.000000Z
          handler_name    : SoundHandler
    Stream mapping:
      Stream #0:0 -> #0:0 (copy)
      Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    frame= 1978 fps=0.0 q=-1.0 size=   14592kB time=00:01:20.25 bitrate=1489.5kbits/s speed= 161x    
    frame= 2042 fps=0.0 q=-1.0 Lsize=   15212kB time=00:01:22.83 bitrate=1504.3kbits/s speed= 161x    
    video:11277kB audio:3888kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.306889%
TrimUtil -- > FFMPEG onFinish

Is the library support drawtext?

I was applying filter on image and got Option 'drawtext' not found everything else seems to be ok.
Following is my current command.

Error initializing filter 'scale' with args '-1:480: drawtext="text=WedMojo: fontcolor=white: fontsize=24: box=1: [email protected]: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2":flags=bicubic'

Error while filtering: Out of memory

I'm trying to mix multiple audio into one audio sequence with each having different delay. The command looks like.

./ffmpeg -i ./drum2.wav -filter_complex "[0]adelay=651|651[s0];[0]adelay=2576|2576[s1];[0]adelay=2700|2700[s2];[s0][s1][s2]amix=3[mixout]" -map "[mixout]" -y result.mp3

It runs successfully and output correct file when I it from my PC's terminal. Implementing the same thing in an Android app throw out of memory error during filter process(Testing on Xiaomi Mi A1 with Android Oreo). Is the NDK the only way to use without memory limitation or am I missing something? The complete log in my Android:

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, ogg, from '/sdcard/drum.ogg':
Duration: 00:00:02.02, start: 0.000000, bitrate: 89 kb/s
Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 80 kb/s
Output #0, mp3, to '/sdcard/audioMerged.mp3':
Metadata:
TSSE : Lavf57.25.100
Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, fltp (default)
Metadata:
encoder : Lavc57.24.102 libmp3lame
Stream mapping:
Stream #0:0 (vorbis) -> adelay
Stream #0:0 (vorbis) -> adelay
Stream #0:0 (vorbis) -> adelay
amix -> Stream #0:0 (libmp3lame)
Press [q] to stop, [?] for help
size= 22kB time=00:00:01.35 bitrate= 131.8kbits/s speed= 2.7x
size= 40kB time=00:00:02.53 bitrate= 130.1kbits/s speed=2.48x
Error while filtering: Out of memory
size= 43kB time=00:00:02.71 bitrate= 129.9kbits/s speed=2.44x
video:0kB audio:43kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.576507%

Failed to resolve implementation

Hi, i am trying to use ffmpeg in my android studio project,
but it's get failed on resolving the depency 'nl.bravobit:android-ffmpeg:1.1.1'
What can i do ?

amr and x86 files make the apk too large

well, ffmpeg needs arm and x86 to support multiple phones, but the files are too large. It builds apk more than 30M. If I delete the files, the apk becomes 2.1M. How can I sovle this problem?

Cryptic warnings..

I tested this on the API 22 x86 default Android emulator, executing ffmpeg -version gives the following output:

WARNING: linker: /data/data/xeus.timbre/files/ffmpeg: unused DT entry: type 0x6ffffffe arg 0x1e54
12-16 21:09:04.677 8449-8449/xeus.timbre D/xxx_ConsoleActivity: 

WARNING: linker: /data/data/xeus.timbre/files/ffmpeg: unused DT entry: type 0x6fffffff arg 0x3
12-16 21:09:04.682 8449-8449/xeus.timbre D/xxx_ConsoleActivity: onSuccess: WARNING: linker: /data/data/xeus.timbre/files/ffmpeg: unused DT entry: type 0x6ffffffe arg 0x1e54
                                                                

WARNING: linker: /data/data/xeus.timbre/files/ffmpeg: unused DT entry: type 0x6fffffff arg 0x3
                                                                ffmpeg version n3.4.1 Copyright (c) 2000-2017 the FFmpeg developersbuilt with gcc 4.9.x (GCC) 20150123 (prerelease)configuration: --target-os=linux --cross-prefix=/root/bravobit/ffmpeg-android/toolchain-android/bin/i686-linux-android- --arch=x86 --cpu=i686 --enable-runtime-cpudetect --sysroot=/root/bravobit/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libfreetype --enable-libmp3lame --enable-libvorbis --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-linux-perf --disable-doc --disable-shared --enable-static --enable-runtime-cpudetect --enable-nonfree --disable-network --enable-avresample --enable-avformat --enable-avcodec --enable-indev=lavfi --enable-hwaccels --enable-ffmpeg --enable-zlib --enable-gpl --enable-small --disable-asm --pkg-config=/root/bravobit/ffmpeg-android/ffmpeg-pkg-config --prefix=/root/bravobit/ffmpeg-android/build/x86 --extra-cflags='-I/root/bravobit/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -march=i686' --extra-ldflags='-L/root/bravobit/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-cxxflags= --extra-libs='-lpng -lx264 -lm -logg'libavutil      55. 78.100 / 55. 78.100libavcodec     57.107.100 / 57.107.100libavformat    57. 83.100 / 57. 83.100libavdevice    57. 10.100 / 57. 10.100libavfilter     6.107.100 /  6.107.100libavresample   3.  7.  0 /  3.  7.  0libswscale      4.  8.100 /  4.  8.100libswresample   2.  9.100 /  2.  9.100libpostproc    54.  7.100 / 54.  7.100

I'd be more comfortable pushing to production if this can be fixed :)

Any idea what's causing this?

Any way to send "q" to stop the recording gracefully?

diegoperini/ffmpeg-android-java#3 This issue remains here as well.

Hi, I need to record a RTSP stream for a while, I don't know how much time i'll be recording when i start. So if i just stop using the killRunningProcesses the recording seems to be unusable. How can i stop it gracefully. I stumbled upon this code on the internet, but seriously I dont know how to compile the whole project, Im using it as a library

        try {

            if (!ffmpeg.Util.isProcessCompleted(process)) {

                int pid = -1;
                Field f = process.getClass().getDeclaredField("pid");
                f.setAccessible(true);
                pid = f.getInt(process);
                f.setAccessible(false);

                if (pid != -1) {
                    android.os.Process.sendSignal(pid, 15); // 15 is the value for SIG_TERM
                }
            }

        } catch (Exception e) {

        }

I have two suggestions. Either we can expose the pid for advanced use cases and/or we can encapsulate Process.sendSignal in an easy to use interface with good naming.

Remove FFprobe, to reduce APK?

Could you please give some highlights of removing FFprobe? It significantly raises APK size, and i don't need it in my project. Should i fork it, or maybe, you have separate build?

Not working on API 16...

onFailure: reloc_library[1311]:  1421 cannot locate 'log2'...
CANNOT LINK EXECUTABLE
��

I tried this on an API 16 genymotion emulator and received the above output message in onFailure() (The command was ffmpeg -version). I can confirm that the exact same apk did work correctly on API 22 and 26.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.