![在 android (4.4.2) kitkat 中,使用 ffmpeg 将音频添加到视频无法正常工作](https://linux22.com/image/1403694/%E5%9C%A8%20android%20(4.4.2)%20kitkat%20%E4%B8%AD%EF%BC%8C%E4%BD%BF%E7%94%A8%20ffmpeg%20%E5%B0%86%E9%9F%B3%E9%A2%91%E6%B7%BB%E5%8A%A0%E5%88%B0%E8%A7%86%E9%A2%91%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C.png)
我正在尝试将音频文件混合到视频文件中。我为此使用的 ffmpeg 命令如下:
ffmpeg -i video.avi -i audio.mp3 -map 0:a:0 -map 1:v:0 -codec copy -shortest output_video.avi
它在 4.4 以下版本的 Android 手机上运行良好,但当我尝试对 Android kitkat(4.4.2)运行相同的命令时,它给出了退出代码 0,但输出无法在默认的 Android 播放器上播放,它给出了无法播放视频的消息,但如果我尝试在外部媒体播放器(如 VLC(适用于 Android))中播放相同的输出,那么它就可以播放输出视频。logcat 结果如下所示:
ffmpeg version git-2013-12-11-3b28564 Copyright (c) 2000-2014 the FFmpeg developers built on Jan 22 2014 13:22:00 with gcc 4.6 (GCC) 20120106 (peelease) configuration: --arch=arm --target-os=linux --enable-cross-compile --cross-prefix=/Users/sunitha/Downloads/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi- --prefix=../build --sysroot=/Users/sunitha/Downloads/android-ndk-r9c/platforms/android-9/arch-arm --extra-cflags=' -I/Users/sunitha/Downloads/android-ndk-r9c/platforms/android-9/arch-arm/usr/include -I../libmp3lame/include -I../libx264/include -DANDROID -marm -march=armv6 ' --extra-ldflags=' -L/Users/sunitha/Downloads/android-ndk-r9c/platforms/android-9/arch-arm/usr/lib -L../libmp3lame/lib -L../libx264/lib' --disable-debug --enable-libmp3lame --enable-libx264 --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avfilter --enable-decoders --enable-demuxers --enable-encoders --enable-filters --enable-indevs --enable-network --enable-parsers --enable-protocols --enable-swscale --enable-gpl --enable-nonfree libavutil 52. 63.100 / 52. 63.100 libavcodec 55. 48.102 / 55. 48.102 libavformat 55. 25.101 / 55. 25.101 libavdevice 55. 5.102 / 55. 5.102 libavfilter 4. 1.100 / 4. 1.100 libswscale 2. 5.101 / 2. 5.101 libswresample 0. 17.104 / 0. 17.104 libpostproc 52. 3.100 / 52. 3.100[mp3 @ 0x18ea210] Header missingInput #0, mp3, from '/storage/emulated/0/trimmedaudio.mp3': Metadata: publisher : Ninja Tune encoder : Lavf55.25.101 Duration: 00:00:54.99, start: 0.011995, bitrate: 227 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s Stream #0:1:
Video: png, rgb24, 512x512, 90k tbr, 90k tbn, 90k tbc Metadata: title : thumbnail comment : Cover (front)Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/DCIM/input0.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2013-04-08 10:00:41 Duration: 00:00:55.70, start: 0.000000, bitrate: 545 kb/s Stream #1:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x360, 446 kb/s, 29.97 fps, 29.97 tbr, 60k tbn, 59.94 tbc (default) Metadata: handler_name : VideoHandler Stream #1:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
Metadata: creation_time : 2013-04-08 10:00:42 5-11-2011Output #0, mp4, to '/storage/emulated/0/Videowthnwaudio.mp4': Metadata: publisher encoder : Lavf55.25.101 Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 480x360, q=2-31, 446 kb/s, 29.97 fps, 60k tbn, 60k tbc (default) Metadata: handler_name : VideoHandler Stream #0:1: Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, stereo, 192 kb/sStream mapping: Stream #1:0 -> #0:0 (copy) Stream #0:0 -> #0:1 (copy)Press [q] to stop, [?] for helpframe= 1669 fps=0.0 q=-1.0 Lsize= 4364kB time=00:00:55.65 bitrate= 642.4kbits/s video:3034kB audio:1290kB subtitle:0 global headers:0kB muxing overhead 0.924174%