tanersener / mobile-ffmpeg

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.
https://tanersener.github.io/mobile-ffmpeg
GNU General Public License v3.0
3.85k stars 787 forks source link

How to change the libavformat library version when building android executable files? #638

Closed yyan7223 closed 3 years ago

yyan7223 commented 3 years ago

Description

Happy new year tanersener!

I use Windows ffmpeg to encode rendered frames and transmit the encoded result through the network, then use Android ffmpeg to perform decoding on Android phone.

This is the argument I used for encoding on Windows ffmpeg: private const string argu = "-y -f rawvideo -vcodec rawvideo -pixel_format rgba -video_size {0}x{1} -r {4} -i - " + "-preset ultrafast -vcodec libx264 -tune zerolatency -maxrate {2}k -bufsize {3}k -r {4} -f flv -";

And this is the argument I used for decoding on Android ffmpeg: private const string argu = "-y -probesize 32 -flags low_delay -f flv -vcodec h264 -i - " + "-video_size {0}x{1} -f rawvideo -vcodec rawvideo -pix_fmt rgba - ";

Unity only accept raw video format, that is why I start with rawvideo and also end with it.

The problem is that the argument settings above only works when I do the loop back test, which is that I don't export Android application and use the same Windows ffmpeg for both encoding and decoding. If I want it works on Android, I have to change the '-f' options from 'flv' to 'mpeg' for both encoding and decoding arguments, but 'mpeg' container format is very slow compared with 'flv'.

I suspect the reason of this problem is that the libavformat library version difference, because these sets of arguments works perfectly fine if use same Windows ffmpeg for both encoding and decoding Windows ffmpeg uses libavformat library version 58. 45.100 while Android ffmpeg uses libavformat library version 58. 35.101 (The executable file is built from v4.3.1 Tag)

So is there any method to change the libavformat library version when building ffmpeg Android executable files? Or you think this issue may caused by other reasons..

Thanks in Advance

Expected behavior The argument setting above with 'flv' container format works when export the application to Android .

Current behavior The argument setting above only works after changing the '-f' option from 'flv' to 'mpeg'

Logs This is the log of Android ffmpeg when using '-f flv' in the argument settings above:

ffmpeg version git-2020-01-26-46b538107 Copyright (c) 2000-2020 the FFmpeg developers built with Android (5900059 based on r365631c) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 207d7abc1a2abf3ef8d4301736d6a7ebc224a290) (based on LLVM 9.0.8svn) configuration: --cross-prefix=aarch64-linux-android- --sysroot=/home/wangguan/Android/Sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/wangguan/Downloads/mobile-ffmpeg/prebuilt/android-arm64/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --cc=aarch64-linux-android24-clang --cxx=aarch64-linux-android24-clang++ --target-os=android --enable-neon --enable-asm --enable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --disable-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 --enable-lto --disable-neon-clobber-test --disable-ffplay --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --enable-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-libx264 --enable-gpl --disable-sdl2 --disable-zlib libavutil 56. 38.100 / 56. 38.100 libavcodec 58. 65.102 / 58. 65.102 libavformat 58. 35.101 / 58. 35.101 libavdevice 58. 9.103 / 58. 9.103 libavfilter 7. 70.101 / 7. 70.101 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 [flv @ 0x77a4c58600] Read FLV header error, input file is not a standard flv format, first PreviousTagSize0 always is 0 pipe:: could not find codec parameters

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.