0

I have a problem with https://github.com/WritingMinds/ffmpeg-android-java. It's Java wrapper lib for ffmpeg on Android and is was working pretty good. But is seems that you can not run two video encodings in a row. Actually it will encode video only once in a lifetime. Every next time you try to encode a video it will freeze. This is the output that I get when it freeze:

Build.CPU_ABI : arm64-v8a
Loading FFmpeg for armv7 CPU
Running publishing updates method
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/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --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/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20160731-WA0005.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp41mp42isom
    creation_time   : 2016-07-31 17:24:29
  Duration: 00:00:13.63, start: 0.000000, bitrate: 1641 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 544x960, 1573 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2016-07-31 17:24:29
      handler_name    : Core Media Video
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 62 kb/s (default)
    Metadata:
      creation_time   : 2016-07-31 17:24:29
      handler_name    : Core Media Audio

I'm not sure what is going on. It seems like ffmpeg leaves something after the first encoding that locks it for any future encoding. And it will work only if i uninstall and then reinstall application.

  • If you kill an app from background this issue remains.
  • If you kill it and restart the device issue remains.
  • If you use force quit in the settings the issue remains.

Only reinstall enables me to encode new video once. After that nothing works.

Ante Braovic
  • 457
  • 4
  • 13

1 Answers1

0

It was actually quite simple. I've been using same output filename in both tries. And ffmpeg was asking me if I want to overwrite an existing one. The problem was that this lib didn't log that line. onProgress listener would log last line before that and it was looking like it freezes.

The solution is to add "-y" which would overwrite output file without asking.

Ante Braovic
  • 457
  • 4
  • 13