Android FFmpeg reports “file protocol not found”

2019-07-18 05:46发布

问题:

I am trying to convert sequence images to video using ffmpeg command in android. I have build ffmpeg for android and put ffmpeg binary file in /data/local folder. I am running ffmpeg command using Runtime.getruntime.execute("mycommand") in Android.

Stucture of mycommand is like this

"/data/local/ffmpeg -r 40 qscale 2 -i /mnt/sdcard/images/img%d.jpg /mnt/sdcard/images/finalvideo.mp4" 

mycommand contains the path of a folder where I placed all my sequence images. Running this command gives me error "protocol not found".

Also I read that file protocol is default in ffmpeg documentation.

How can I run such commands?

The Error I am getting after running simple command like ffmpeg -i /mnt/sdcard/vid.mp4

ffmpeg version 0.11.1.git Copyright (c) 2000-2012 the FFmpeg developers
built on Sep 26 2012 11:58:35 with gcc 4.4.3 (GCC)
configuration: --target-os=linux --prefix=/home/esteves/android-ffmpeg --enable-cross-compile --enable-runtime-cpudetect --disable-asm --arch=arm --cc=/home/esteves/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --cross-prefix=/home/esteves/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- --disable-stripping --nm=/home/esteves/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-nm --sysroot=/home/esteves/android-ndk/platforms/android-8/arch-arm --enable-nonfree --enable-version3 --disable-everything --enable-gpl --disable-doc --enable-avresample --enable-demuxer=amr --enable-demuxer=aac --enable-demuxer=rawvideo --enable-demuxer=rtsp --enable-muxer=rtsp --enable-muxer=flv --enable-muxer=mpegts --enable-muxer=mp4 --enable-demuxer=rtp --enable-demuxer=rtp --disable-ffplay --disable-ffserver --enable-ffmpeg --disable-ffprobe --enable-libx264 --enable-encoder=libx264   libavutil      51. 72.100 / 51. 72.100
libavcodec     54. 55.100 / 54. 55.100
libavformat    54. 25.105 / 54. 25.105
libswscale      2.  1.101 /  2.  1.101
error of main   libswresample   0. 15.100 /  0. 15.100
error of main   libpostproc    52.  0.100 / 52.  0.100
/mnt/sdcard/vid.mp4: Protocol not found

回答1:

Avoid compiling with --disable-everything

It will disable all components including protocol support.

If you must use --disable-everything

You will have to manually enable your desired components, such as --enable-protocols or in a piecemeal fashion such as --enable-protocol=file,pipe. However, this is difficult to do properly because users often forget to enable something they need. See the output of ./configure --help for more info.



回答2:

It was the ffmpeg compile problem.You should enable protocols releate in configure. Here is my config you can refer to:

export TMPDIR=/Users/yourpath/SourceCode/FFmpeg/tmpdir
NDK=/Users/yourpath/Android/android-ndk-r10d
SYSROOT=$NDK/platforms/android-16/arch-arm/
TOOLCHAIN=/Users/yourpath/Android/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64

CPU=arm
PREFIX=/Users/liuchao/SourceCode/FFmpeg/ffmpeg_install/
#ADDI_CFLAGS="-marm"
ADDI_CFLAGS="-mfpu=neon -mfloat-abi=softfp"

function build_one
{
./configure \
--prefix=$PREFIX \
--target-os=linux \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--arch=arm \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--cc=$TOOLCHAIN/bin/arm-linux-androideabi-gcc \
--nm=$TOOLCHAIN/bin/arm-linux-androideabi-nm \
--disable-shared \
--enable-static \
--disable-asm \
--disable-yasm \
--enable-gpl \
--enable-stripping \
--enable-runtime-cpudetect \
--enable-cross-compile \
--enable-version3 \
--enable-nonfree
--enable-libx265 \
--enable-w32threads \
--enable-hwaccels \
--enable-neon \
--enable-decoders \
--enable-devices \
--enable-encoders \
--enable-muxers \
--enable-encoder=rawvideo \
--enable-protocols \
--enable-protocol=file \
--enable-avfilter \
--enable-network \
--enable-avdevice \
--enable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-doc \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG