我不知道为什么这个 FFmpeg 命令在 android 中不起作用?

我不知道为什么这个 FFmpeg 命令在 android 中不起作用?

请拯救我的一天

D/FFmpeg  (10151): Build.CPU_ABI : arm64-v8a
D/FFmpeg  (10151): ffmpeg is ready!
[GETX] CLOSE TO ROUTE /UploadView
D/FFmpeg  (10151): Running publishing updates method
I/message (10151): /storage/emulated/0/convert
I/message (10151): [-y, -i, /data/user/0/com.brahmand.sanju/cache/file_picker/VID-20210104- WA0003.mp4, -preset, slow, -g, 48, -sc_threshold, 0, -map, 0:0, -map, 0:1, -map, 0:0, -map, 0:1,  -s:v:0, 640x360, -c:v:0, libx264, -b:v:0, 365k, -s:v:1, 960x540, -c:v:1, libx264, -b:v:1, 2000k, -c:a, copy, -var_stream_map, v:0, a:0, v:1, a:1, -master_pl_name, master.m3u8, -f, hls, -hls_time, 6, -hls_list_size, 0, -hls_segment_filename,   /storage/emulated/0/convert/%v_fileSequence_%d.ts,   /storage/emulated/0/convert/%v_playlistVariant.m3u8]
D/FFmpeg  (10151): Running publishing updates method
E/FFmpeg  (10151): ffmpeg version n4.0-39-gda39990 Copyright (c) 2000-2018 the FFmpeg developers
E/FFmpeg  (10151):   built with gcc 4.9.x (GCC) 20150123 (prerelease)
E/FFmpeg  (10151):   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-ffprobe --enable-libopus --enable-libvorbis --enable-libfdk-aac --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-libvpx --enable-libass --enable-yasm --enable-pthreads --disable-debug --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 --enable-nonfree --pkg-config=pkg-config --pkg-config-flags=--static --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=
E/FFmpeg  (10151):   libavutil      56. 14.100 / 56. 14.100
E/FFmpeg  (10151):   libavcodec     58. 18.100 / 58. 18.100
E/FFmpeg  (10151):   libavformat    58. 12.100 / 58. 12.100
E/FFmpeg  (10151):   libavdevice    58.  3.100 / 58.  3.100
E/FFmpeg  (10151):   libavfilter     7. 16.100 /  7. 16.100
E/FFmpeg  (10151):   libavresample   4.  0.  0 /  4.  0.  0
E/FFmpeg  (10151):   libswscale      5.  1.100 /  5.  1.100
E/FFmpeg  (10151):   libswresample   3.  1.100 /  3.  1.100
E/FFmpeg  (10151):   libpostproc    55.  1.100 / 55.  1.100
E/FFmpeg  (10151): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/com.brahmand.sanju/cache/file_picker/VID-20210104-WA0003.mp4':
E/FFmpeg  (10151):   Metadata:
E/FFmpeg  (10151):     major_brand     : mp42
E/FFmpeg  (10151):     minor_version   : 1
E/FFmpeg  (10151):     compatible_brands: mp41mp42isom
E/FFmpeg  (10151):     creation_time   : 2020-04-20T10:07:33.000000Z
E/FFmpeg  (10151):   Duration: 00:00:50.38, start: 0.000000, bitrate: 1651 kb/s
E/FFmpeg  (10151):     Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, unknown/bt470bg/unknown, progressive), 640x640, 1519 kb/s, 30 fps, 30 tbr, 15360 tbn, 30720 tbc (default)
E/FFmpeg  (10151):     Metadata:
E/FFmpeg  (10151):       creation_time   : 2020-04-20T10:07:33.000000Z
E/FFmpeg  (10151):       handler_name    : Core Media Video
E/FFmpeg  (10151):     Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
E/FFmpeg  (10151):     Metadata:
E/FFmpeg  (10151):       creation_time   : 2020-04-20T10:07:33.000000Z
E/FFmpeg  (10151):       handler_name    : Core Media Audio
E/FFmpeg  (10151): [NULL @ 0xec29c200] Unable to find a suitable output format for 'a:0'
E/FFmpeg  (10151): a:0: Invalid argument

这是我使用 ffmpeg 将 mp4 视频转换为 hls 文件的命令

 String exec =
            "-y -i "+mediaPath+
                    " -preset slow -g 48 -sc_threshold 0"+
                    " -map 0:0 -map 0:1 -map 0:0 -map 0:1"+
                    " -s:v:0 640x360 -c:v:0 libx264 -b:v:0 365k"+
                    " -s:v:1 960x540 -c:v:1 libx264 -b:v:1 2000k"+
                    " -c:a copy"+
                    " -var_stream_map"+
                    " v:0 a:0 "+ "v:1 a:1"+
                    " -master_pl_name master.m3u8"+
                    " -f hls -hls_time 6 -hls_list_size 0"+
                    " -hls_segment_filename "+outDirPath+"/%v_fileSequence_%d.ts "+
                    outDirPath+"/%v_playlistVariant.m3u8";
    Log.i("message", outDirPath);

    String[] splitCmd = exec.split(" ");
    Log.i("message", Arrays.toString(splitCmd));
    //String[] command = {"-i", mediaPath, "output.mov"};


    FFmpeg.getInstance(this).execute(splitCmd, new ExecuteBinaryResponseHandler() {
    //execution 
    }

答案1

使用:

-var_stream_map 'v:0,a:0 v:1,a:1'
  • 变体流组之间以空格分隔。
  • 每个组内的流以逗号分隔。
  • 引用该字符串以防止不正确的解析。

查看HLS 多路复用器文档了解更多信息。

相关内容