Mobile-ffmpeg: unknown encoder libx264 when running sample test app and making custom build

Created on 27 Apr 2019  路  19Comments  路  Source: tanersener/mobile-ffmpeg

Description
We are trying to run the test-app and make our custom build with the latest 4.2 LTS release, and with x264 encoder. Everything works fine except that every time we try to call anything in x264, or choose to encode the video with x264 in the sample app, it displays the error message:

Unknown encoder 'libx264'

Command we run to build mobile-ffmpeg libraries: ./android.sh --lts --enable-gpl --enable-x264
Command we run to build the sample app: ./gradlew :test-app:assembleDebug

Environment

  • Platform: Android
  • Architecture: arm-v7a
  • Version (if applicable) v4.2.LTS
  • Android Studio version (if applicable) 3.1.4
  • Android NDK version (if applicable) r19c

Any help would be greatly appreciated!

question

Most helpful comment

@enigmablue can you please elaborate a bit more about usage of this?

If you are looking for android Dependency

implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.4

Update this"mobile-ffmpeg-full-gpl " part according to requirements See Table On main project page

All 19 comments

Can I get answers to these questions?

  1. What are the dependencies in your build.gradle file?
  2. Which source branch do you use?
  3. What version is printed in the mobile-ffmpeg init string?
Loading mobile-ffmpeg.
Loaded mobile-ffmpeg-<version>.

Hi Tanersener,

Thank you so much for your quick response! Here are the answers to your questions:

  1. We are building a react-native app with the prebuilt .so and .a libraries. Here are the dependencies:
dependencies {
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-linear-gradient')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    androidTestImplementation('com.android.support.test:runner:0.5') {
        exclude module: 'support-annotations'
    }
    worldImplementation 'com.google.firebase:firebase-core:11.8.0'
    worldImplementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.1'
    implementation 'com.google.firebase:firebase-ads:11.8.0'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.facebook.react:react-native:+'
    implementation "com.android.support:recyclerview-v7:27.0.2"
    implementation 'org.apache.directory.studio:org.apache.commons.io:2.4'
    implementation 'com.squareup.picasso:picasso:2.5.2'
}
  1. Source branch is master (commit 5f9813877fca1b22ab0f4f7987737f3a97de7467). Basically the latest 4.2 LTS release

3.

Loading mobile-ffmpeg.
Loaded mobile-ffmpeg-full-arm-v7a-neon-4.2

@tanersener I am facing the same issue with x264 encode. Is there any solution for 4.2 LTS release?

We are building a react-native app with the prebuilt .so and .a libraries. Here are the dependencies:

I can't see any local or published mobile-ffmpeg dependencies here. How do you depend on mobile-ffmpeg?

Loading mobile-ffmpeg.
Loaded mobile-ffmpeg-full-arm-v7a-neon-4.2

LTS releases include LTS postfix in the version string. This log shows that you are depending full package of v4.2 not your local build.

Please check your dependencies.

@adapana If you have a similar error, please provide logs about your error. If you have a different error please create a new issue.

Gradle dependency:

implementation group: 'com.arthenica', name: 'mobile-ffmpeg-video', version: '4.2.LTS'

Here is an error log:

ffmpeg version v4.2-dev-480
Copyright (c) 2000-2018 the FFmpeg developers
built with Android (4751641 based on r328903) clang version 7.0.2 (https://android.googlesource.com/toolchain/clang 003100370607242ddd5815e4a043907ea9004281) (https://android.googlesource.com/toolchain/llvm 1d739ffb0366421d383e04ff80ec2ee591315116) (based on LLVM 7.0.2svn)
configuration: --cross-prefix=arm-linux-androideabi- --sysroot=/files/android-sdk/ndk-bundle/toolchains/mobile-ffmpeg-api-21-arm/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=armv7-a --cpu=armv7-a --target-os=android --disable-neon --enable-asm --enable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-lto --enable-optimizations --enable-swscale --enable-shared --disable-v4l2-m2m --disable-outdev=v4l2 --disable-outdev=fbdev --disable-indev=v4l2 --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libkvazaar --enable-libsnappy --enable-libaom --disable-sdl2 --enable-zlib --enable-mediacodec
libavutil 56. 25.100 / 56. 25.100
libavcodec 58. 42.104 / 58. 42.104
libavformat 58. 25.100 / 58. 25.100
libavdevice 58. 6.101 / 58. 6.101
libavfilter 7. 46.101 / 7. 46.101
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
[AVIOContext @ 0xafe6f240]
Statistics: 146954 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 131820 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 195296 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 169005 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 146954 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 131820 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 195296 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 169005 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 146954 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 131820 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 195296 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 169005 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 146954 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 131820 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 195296 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 169005 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 146954 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 131820 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 195296 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 169005 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 146954 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 131820 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 195296 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 169005 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 146954 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 131820 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 195296 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 169005 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 146954 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 131820 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 195296 bytes read, 0 seeks
[AVIOContext @ 0xafe6f240]
Statistics: 169005 bytes read, 0 seeks
Input #0, image2, from '/storage/emulated/0/statusVid/uploads/myD%d.jpg':
Duration:
00:00:00.16
, start:
0.000000
, bitrate:
N/A
Stream #0:0
: Video: mjpeg, 1 reference frame, yuvj420p(pc, bt470bg/unknown/unknown, center), 720x1280 [SAR 1:1 DAR 9:16]
,
25 fps,
25 tbr,
25 tbn,
25 tbc
Unknown encoder 'libx264'

This is the command that I used:

ffmpeg -loop 1 -an -i /storage/emulated/0/statusVid/uploads/myD%d.jpg -vf format=yuv420p,fps=70,zoompan=d=(0.25+0.16)/0.16:s=720x1280:fps=1/1.3,framerate=25:interp_start=0:interp_end=255:scene=100 -vcodec libx264 -profile:v baseline -level 3 -crf 24 -preset fast -y -t 30 /storage/emulated/0/statusVid/uploads/tempVid.mp4

@adapana video package does not include x264 library. Please refer to Using section of README to see which packages include x264.

We are building a react-native app with the prebuilt .so and .a libraries. Here are the dependencies:

I can't see any local or published mobile-ffmpeg dependencies here. How do you depend on mobile-ffmpeg?

Loading mobile-ffmpeg.
Loaded mobile-ffmpeg-full-arm-v7a-neon-4.2

LTS releases include LTS postfix in the version string. This log shows that you are depending full package of v4.2 not your local build.

Please check your dependencies.

Hi Tanersener,

How do you link the test-app against LTS? Should I do anything else other than first running:
./android.sh --lts --enable-gpl --enable-x264
and then run: ./gradlew :test-app:assembleDebug
Anything else I am missing here?

The gradle dependencies I posted is for our own react-native app. We just add those prebuilt .so and .a libraries to our own app through CMakeList. We are not using the .aar files. That's why you don't see the mobile-ffmpeg dependencies.

Thank you!

How do you link the test-app against LTS? Should I do anything else other than first running:
./android.sh --lts --enable-gpl --enable-x264
and then run: ./gradlew :test-app:assembleDebug
Anything else I am missing here?

test-app is used to test both local builds and published releases. mobile-ffmpeg dependency used in test-app/build.gradle defines which one is tested.

If you look inside test-app/build.gradle at commit 5f9813877fca1b22ab0f4f7987737f3a97de7467 you can see the following dependency, which means that mobile-ffmpeg-full-4.2 is tested at that point.

implementation 'com.arthenica:mobile-ffmpeg-full:4.2'

To test your local build, please use the following dependency.

implementation project(':app')

I am running this command in sample test-app itself:

    String command="-i "+video1 + " -i " + video2 +" -filter_complex \"[1:v]setpts=PTS-10/TB[a]" + ";"+
            "[0:v][a]overlay=enable=gte(t\\,5):shortest=1[out]\" " + ""+
            "-map [out] -map 0:a:0? -c:v libx264 -crf 18 -pix_fmt yuv420p -c:a copy "+ videoOut;

Getting unknown encoder libx264.

Any idea what is the issue in command.

@tanersener Your help will be highly appreciated. I am totally stuck in test-app itself after i added my own command.

@seema-spark6 Which mobile-ffmpeg package do you use? x264 is included in only GPL licensed mobile-ffmpeg packages. See README.

had an issue here also with no encoder, and solved by updating to min-gpl.

@enigmablue please can you explain how one can update to min-gpl
The Steps please

for ios

you have to add it to the pod react-native-ffmpeg/[insert package].
Example for min-gps-lts below:

pod 'react-native-ffmpeg/min-gpl-lts', :podspec => '../node_modules/react-native-ffmpeg/react-native-ffmpeg.podspec'

For android its in build.gradle

buildscript {
    ext {
        ...
        reactNativeFFmpegPackage = "min-gpl-lts"
    }

@enigmablue Thank you

@enigmablue can you please elaborate a bit more about usage of this?

@enigmablue can you please elaborate a bit more about usage of this?

If you are looking for android Dependency

implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.4

Update this"mobile-ffmpeg-full-gpl " part according to requirements See Table On main project page

Hi Peers,
If anyone is getting an unknown encoder/codec "libx264" error.
please use min-gpl:x.xx
e.g implementation 'com.arthenica:mobile-ffmpeg-min-gpl:4.4'
It fixed for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

khacchungory picture khacchungory  路  7Comments

arabsiphone picture arabsiphone  路  4Comments

brainstormapps picture brainstormapps  路  7Comments

tim162 picture tim162  路  5Comments

chaocharleswang picture chaocharleswang  路  4Comments