在Android手机(不同的手机型号)中,它需要ffmpeg转换视频长度的5倍。 1分钟的视频需要近5分钟才能进行转码。我尝试过以下方法来提高性能,但没有任何帮助,
-b:v 16K to 1024K
-s 180x120 to 1920x1080
-preset ultrafast
-profile:v baseline
-r 24 to 100
maxrate 64K to 512K
rate 64K to 512K
-threads 0 to 16
似乎没有任何帮助。当然,其中一些将速度从5倍提高到3倍。
请帮助我,因为我的选项已用完。
我目前的代码是,
ffmpeg -y -i /storage/emulated/0/DCIM/Camera/VID_20150819_220414.mp4 -strict experimental -s 480x270 -vcodec libx264 -r 24 -c:a copy /storage/emulated/0/Android/data/<myApp>/cache/VID_-K-qMCldTSzZomKakNzq.mp4
控制台日志-----
configuration: --arch=arm --cpu=cortex-a8 --target-os=linux --enable-runtime-cpudetect --prefix=/data/data/info.guardianproject.ffmpeg/app_opt --enable-pic --disable-shared --enable-static --cross-prefix=/home/n8fr8/dev/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi- --sysroot=/home/n8fr8/dev/android/ndk/platforms/android-16/arch-arm --extra-cflags='-I../x264 -mfloat-abi=softfp -mfpu=neon -fPIE -pie' --extra-ldflags='-L../x264 -fPIE -pie' --enable-version3 --enable-gpl --disable-doc --enable-yasm --enable-decoders --enable-encoders --enable-muxers --enable-demuxers --enable-parsers --enable-protocols --enable-filters --enable-avresample --enable-libfreetype --disable-indevs --enable-indev=lavfi --disable-outdevs --enable-hwaccels --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-network --enable-libx264 --enable-zlib
libavutil 51. 54.100 / 51. 54.100
10-05 10:29:22.288: V/VideoEditor(7655): shellOut: libavcodec 54. 23.100 / 54. 23.100
10-05 10:29:22.288: V/VideoEditor(7655): shellOut: libavformat 54. 6.100 / 54. 6.100
10-05 10:29:22.288: V/VideoEditor(7655): shellOut: libavdevice 54. 0.100 / 54. 0.100
10-05 10:29:22.288: V/VideoEditor(7655): shellOut: libavfilter 2. 77.100 / 2. 77.100
10-05 10:29:22.288: V/VideoEditor(7655): shellOut: libswscale 2. 1.100 / 2. 1.100
10-05 10:29:22.288: V/VideoEditor(7655): shellOut: libswresample 0. 15.100 / 0. 15.100
10-05 10:29:22.288: V/VideoEditor(7655): shellOut: libpostproc 52. 0.100 / 52. 0.100
10-05 10:29:22.740: V/VideoEditor(7655): shellOut: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/DCIM/Camera/VID_20151002_152817.mp4':
10-05 10:29:22.740: V/VideoEditor(7655): shellOut: Metadata:
10-05 10:29:22.741: V/VideoEditor(7655): shellOut: major_brand : mp42
10-05 10:29:22.741: V/VideoEditor(7655): shellOut: minor_version : 0
10-05 10:29:22.742: V/VideoEditor(7655): shellOut: compatible_brands: isommp42
10-05 10:29:22.742: V/VideoEditor(7655): shellOut: creation_time : 2015-10-02 22:29:32
10-05 10:29:22.743: V/VideoEditor(7655): shellOut: Duration: 00:01:14.13, start: 0.000000, bitrate: 17112 kb/s
10-05 10:29:22.745: V/VideoEditor(7655): shellOut: Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 16991 kb/s, SAR 65536:65536 DAR 16:9, 29.84 fps, 29.85 tbr, 90k tbn, 180k tbc
10-05 10:29:22.745: V/VideoEditor(7655): shellOut: Metadata:
10-05 10:29:22.747: V/VideoEditor(7655): shellOut: creation_time : 2015-10-02 22:29:32
10-05 10:29:22.748: V/VideoEditor(7655): shellOut: handler_name : VideoHandle
10-05 10:29:22.749: V/VideoEditor(7655): shellOut: Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, s16, 96 kb/s
10-05 10:29:22.749: V/VideoEditor(7655): shellOut: Metadata:
10-05 10:29:22.750: V/VideoEditor(7655): shellOut: creation_time : 2015-10-02 22:29:32
10-05 10:29:22.751: V/VideoEditor(7655): shellOut: handler_name : SoundHandle
10-05 10:29:22.760: V/VideoEditor(7655): shellOut: [buffer @ 0xb5caa0a0] w:1920 h:1080 pixfmt:yuv420p tb:1/90000 sar:65536/65536 sws_param:flags=2
10-05 10:29:22.760: V/VideoEditor(7655): shellOut: [buffersink @ 0xb5caa0d0] No opaque field provided
10-05 10:29:22.802: V/VideoEditor(7655): shellOut: [scale @ 0xb5caa100] w:1920 h:1080 fmt:yuv420p sar:65536/65536 -> w:720 h:404 fmt:yuv420p sar:404/405 flags:0x4
10-05 10:29:22.803: V/VideoEditor(7655): shellOut: [libx264 @ 0xb5c28000] using SAR=1/1
10-05 10:29:22.818: V/VideoEditor(7655): shellOut: [libx264 @ 0xb5c28000] using cpu capabilities: ARMv6 NEON
10-05 10:29:22.904: V/VideoEditor(7655): shellOut: [libx264 @ 0xb5c28000] profile High, level 3.0
shellOut: [libx264 @ 0xb5c28000] 264 - core 125 r680+1521 37be552 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=512 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
10-05 10:29:22.909: V/VideoEditor(7655): shellOut: Output #0, mp4, to '/storage/emulated/0/Android/data/com.myapp/cache/VID_-K-t2E4MtV_RTw4a1JXb.mp4':
10-05 10:29:22.910: V/VideoEditor(7655): shellOut: Metadata:
10-05 10:29:22.911: V/VideoEditor(7655): shellOut: major_brand : mp42
10-05 10:29:22.912: V/VideoEditor(7655): shellOut: minor_version : 0
10-05 10:29:22.913: V/VideoEditor(7655): shellOut: compatible_brands: isommp42
10-05 10:29:22.913: V/VideoEditor(7655): shellOut: creation_time : 2015-10-02 22:29:32
10-05 10:29:22.914: V/VideoEditor(7655): shellOut: encoder : Lavf54.6.100
10-05 10:29:22.916: V/VideoEditor(7655): shellOut: Stream #0:0(eng): Video: h264 (![0][0][0] / 0x0021), yuv420p, 720x404 [SAR 1:1 DAR 180:101], q=-1--1, 512 kb/s, 24 tbn, 24 tbc
10-05 10:29:22.916: V/VideoEditor(7655): shellOut: Metadata:
10-05 10:29:22.917: V/VideoEditor(7655): shellOut: creation_time : 2015-10-02 22:29:32
10-05 10:29:22.918: V/VideoEditor(7655): shellOut: handler_name : VideoHandle
10-05 10:29:22.919: V/VideoEditor(7655): shellOut: Stream #0:1(eng): Audio: aac (@[0][0][0] / 0x0040), 48000 Hz, mono, 96 kb/s
10-05 10:29:22.920: V/VideoEditor(7655): shellOut: Metadata:
10-05 10:29:22.921: V/VideoEditor(7655): shellOut: creation_time : 2015-10-02 22:29:32
10-05 10:29:22.922: V/VideoEditor(7655): shellOut: handler_name : SoundHandle
10-05 10:29:22.922: V/VideoEditor(7655): shellOut: Stream mapping:
10-05 10:29:22.923: V/VideoEditor(7655): shellOut: Stream #0:0 -> #0:0 (h264 -> libx264)
10-05 10:29:22.924: V/VideoEditor(7655): shellOut: Stream #0:1 -> #0:1 (copy)
10-05 10:29:22.924: V/VideoEditor(7655): shellOut: Press [q] to stop, [?] for help
10-05 10:29:23.637: V/VideoEditor(7655): shellOut: frame= 6 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate= 0.0kbits/s
10-05 10:29:24.205: V/VideoEditor(7655): shellOut: frame= 12 fps= 10 q=0.0 size= 0kB time=00:00:00.00 bitrate= 0.0kbits/s
10-05 10:29:24.735: I/chromium(7655): [INFO:CONSOLE(25)] "No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.", source: file:///android_asset/www/plugins/cordova-plugin-whitelist/whitelist.js (25)
10-05 10:29:24.756: V/VideoEditor(7655): shellOut: frame= 17 fps=9.8 q=0.0 size= 0kB time=00:00:00.00 bitrate= 0.0kbits/s dup=0 drop=1
10-05 10:29:25.327: V/VideoEditor(7655): shellOut: frame= 22 fps=9.5 q=0.0 size= 0kB time=00:00:00.00 bitrate= 0.0kbits/s dup=0 drop=2
10-05 10:29:25.904: V/VideoEditor(7655): shellOut: frame= 26 fps=9.1 q=0.0 size= 0kB time=00:00:00.00 bitrate= 0.0kbits/s dup=0 drop=4