这是我从多个图像创建视频的命令。
File f = new File(Environment.getExternalStorageDirectory() + "/abc.mp4");
try {
f.createNewFile();
ffmpeg.execute(new String[]{"-y","-r","1/5","-i","<parent_path>" + "/" + "image%01d.jpg","-pix_fmt","yuv420p","-c:v","libx264","-crf","23","-s","640x480",f.getPath()}, listener);
} catch (Exception e) {
e.printStackTrace();
}
我有多个图像可供使用,其名称有image1.jpg,image2.jpg等等。
它正在创建大约100-200 KB的视频文件,但它在VLC播放器中显示空白图像。
当我尝试使用Windows Media Player运行它时,它只会在播放器处于重复模式时运行,否则它不会播放。
onSuccess()
[ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/i686-linux-android- --arch=x86 --cpu=i686 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/x86 --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -march=i686' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[mjpeg @ 0xb97270a0] Changing bps to 8
Input #0, image2, from '/storage/emulated/0/Download/image%01d.jpg':
Duration: 00:00:00.08, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 464x317 [SAR 1:1 DAR 464:317], 25 tbr, 25 tbn, 25 tbc
[swscaler @ 0xb9741480] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0xb97287c0] using SAR=348/317
[libx264 @ 0xb97287c0] using cpu capabilities: none!
[libx264 @ 0xb97287c0] profile High, level 2.2
[libx264 @ 0xb97287c0] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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=6 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=1 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/storage/emulated/0/abc.mp4':
Metadata:
encoder : Lavf57.25.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x480 [SAR 348:317 DAR 464:317], q=-1--1, 0.20 fps, 16384 tbn, 0.20 tbc
Metadata:
encoder : Lavc57.24.102 libx264
Side data:
unknown side data type 10 (24 bytes)
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Input stream #0:0 frame changed from size:464x317 fmt:yuvj420p to size:313x470 fmt:yuvj420p
[swscaler @ 0xb9752fc0] deprecated pixel format used, make sure you did set range correctly
frame= 2 fps=0.0 q=-1.0 Lsize= 64kB time=00:00:10.00 bitrate= 52.4kbits/s speed=34.3x
video:63kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.310563%
[libx264 @ 0xb97287c0] frame I:1 Avg QP:14.14 size: 23785
[libx264 @ 0xb97287c0] frame P:1 Avg QP:17.01 size: 40246
[libx264 @ 0xb97287c0] mb I I16..4: 3.3% 82.2% 14.4%
[libx264 @ 0xb97287c0] mb P I16..4: 2.0% 88.1% 9.9% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip: 0.0%
[libx264 @ 0xb97287c0] 8x8 transform intra:85.2%
[libx264 @ 0xb97287c0] coded y,uvDC,uvAC intra: 93.3% 82.2% 71.0%
[libx264 @ 0xb97287c0] i16 v,h,dc,p: 5% 3% 3% 89%
[libx264 @ 0xb97287c0] i8 v,h,dc,ddl,ddr,vr,
答案 0 :(得分:0)
嗨@RaviRupareliya下面为我指挥工作
"-ffmpeg", "-r", "add_your_Preview_Frame_Rate_here", "-b", "1000000", "-vcodec", "mjpeg", "-i", Environment.getExternalStorageDirectory().getPath() + "/image_stored_dir_path/frame_%05d.jpg", Environment.getExternalStorageDirectory().getPath() + "/path_where_you_want_to_store_your_output_video/video.mp4"
您可以根据自己的要求更改此代码 我希望这会对你有所帮助。