0

Here is my command to create a video from multiple images.

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();
}

I have multiple images available at with having names like image1.jpg, image2.jpg etc etc.

It is creating video file with some 100-200 KB but it showing blank images in VLC player.

When i try to run it with Windows Media Player, it only runs if it is in repeat mode from player, otherwise it is not playing.

Output in 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,
Ravi
  • 34,851
  • 21
  • 122
  • 183
  • 1
    There are only two images in the sequence. And they are not the same resolution. VLC doesn't like that. – Gyan Apr 05 '17 at 06:02
  • @Mulvya so what could be the possible way to overcome this? – Ravi Apr 05 '17 at 06:09
  • 1
    Make sure all of your image inputs are the same width and height beforehand, or use filtering to scale, crop, and/or pad to make them all the same. There are probably several duplicate questions here with answers that provide examples. Also, unrelated, but `using cpu capabilities: none!` is not good. Recompile x264 and ffmpeg so it shows `NEON` and `ARMv7` or similar for a significant encoding speed improvement. – llogan Apr 05 '17 at 19:22

1 Answers1

0

Hi @RaviRupareliya below command work for me

"-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"

you can change this code as per your requirements
I hope this will help you.

Harin Kaklotar
  • 305
  • 7
  • 22