bravobit / FFmpeg-Android

FFMpeg/FFprobe compiled for Android
https://bravobit.nl/
MIT License
739 stars 175 forks source link

stuck in onProgress callback #71

Closed fartymonk closed 5 years ago

fartymonk commented 5 years ago

Hi, I've encountered a problem while using this lib.

Sometimes, when I tried to process a video (trim, scale, and transcode all in one command), ffmpeg will read the metadata of said video, but then nothing. I've put log in every callback to print the message (if any) and progress state. onStart() always run just fine. But, during onProgress() the message just stop after showing the video metadata, no message showing any process happening.

I've tried with multiple commands, from simple ones (just copy the video) to more complex, but sometimes it just happens. I've tried waiting for nearly an hour to see if it will eventually 'work' but it still shows nothing. The process itself (when it works fine) should only take about 2-3 minutes with the video I'm testing with.

This is how I call ffmpeg. Note: I'm testing mainly testing with BlueStacks4, no instant run, but testing in physical device still, although not as often as BS4, gave me this issue.

ffmpegTask = ffmpeg.execute( command, new ExecuteBinaryResponseHandler() {
                    @Override
                    public void onStart() {
                        startTime = SystemClock.elapsedRealtime();

                        Log.d(TAG_DEBUG, "transcode started " );
                        progress = 0;
                        progressState = ProgressState.STARTED;
                    }

                    @Override
                    public void onProgress( String message ) {
                        Log.d( TAG_DEBUG, "onprogress " + message );
                        progress = getTranscodeProgress( message, videoLengthInMillis ).intValue();
                        progressState = ProgressState.PROGRESS;
                        endTime = SystemClock.elapsedRealtime();
                    }

                    @Override
                    public void onFailure( String message ) {
                        Log.d( TAG_DEBUG, "transcode failed " + message );
                    }

                    @Override
                    public void onSuccess( String message ) {
                        Log.d( TAG_DEBUG, "transcode success" + message );
                    }

                    @Override
                    public void onFinish() {
                        Log.d( TAG_DEBUG, "transcode done" + message );
                    }
                } );

This is how the log appears in my logcat (formatted to make it a bit readable).

2018-10-24 13:08:22.979 14447-15037/? D/AppDebug: command: [-ss, 00:00:00, -i, /storage/emulated/0/Android/.../temps/vid(5).mp4, -t, 00:03:44, -vf, scale='w=if(gt(a,4/3),min(720,iw),-2)':h='if(gt(a,4/3),-2,min(480,ih))', -vcodec, libx264, -preset, ultrafast, -crf, 27, -c:a, copy, /storage/emulated/0/.../temps/vid(5)_conv.mp4]

2018-10-24 13:08:22.980 14447-15037/? D/AppDebug: transcode started 

2018-10-24 13:08:22.990 14447-14447/? D/AppDebug: onprogress message=ffmpeg version n4.0-39-gda39990 Copyright (c) 2000-2018 the FFmpeg developers

2018-10-24 13:08:22.991 14447-14447/? D/AppDebug: onprogress  message=  built with gcc 4.9.x (GCC) 20150123 (prerelease)

2018-10-24 13:08:22.991 14447-14447/? D/AppDebug: onprogress message=  configuration: --target-os=linux --cross-prefix=/root/bravobit/ffmpeg-android/toolchain-android/bin/i686-linux-android- --arch=x86 --cpu=i686 --enable-runtime-cpudetect --sysroot=/root/bravobit/ffmpeg-android/toolchain-android/sysroot --disable-asm --enable-pic --enable-libx264 --enable-libfreetype --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libopus --enable-pthreads --enable-libass --enable-libfribidi --enable-fontconfig --enable-libfdk-aac --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 --disable-asm --pkg-config=pkg-config --pkg-config-flags=--static --prefix=/root/bravobit/ffmpeg-android/build/x86 --extra-cflags='-I/root/bravobit/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -march=i686' --extra-ldflags='-L/root/bravobit/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-cxxflags=

2018-10-24 13:08:22.991 14447-14447/? D/AppDebug: onprogress message=  libavutil      56. 14.100 / 56. 14.100
2018-10-24 13:08:22.991 14447-14447/? D/AppDebug: onprogress message=  libavcodec     58. 18.100 / 58. 18.100
2018-10-24 13:08:22.992 14447-14447/? D/AppDebug: onprogress message=  libavformat    58. 12.100 / 58. 12.100
2018-10-24 13:08:22.992 14447-14447/? D/AppDebug: onprogress message=  libavdevice    58.  3.100 / 58.  3.100
2018-10-24 13:08:22.992 14447-14447/? D/AppDebug: onprogress message=  libavfilter     7. 16.100 /  7. 16.100
2018-10-24 13:08:22.992 14447-14447/? D/AppDebug: onprogress message=  libavresample   4.  0.  0 /  4.  0.  0
2018-10-24 13:08:22.992 14447-14447/? D/AppDebug: onprogress message=  libswscale      5.  1.100 /  5.  1.100
2018-10-24 13:08:22.993 14447-14447/? D/AppDebug: onprogress message=  libswresample   3.  1.100 /  3.  1.100
2018-10-24 13:08:22.993 14447-14447/? D/AppDebug: onprogress message=  libpostproc    55.  1.100 / 55.  1.100
2018-10-24 13:08:23.024 14447-14447/? D/AppDebug: onprogress message=Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/.../files/temps/vid(5).mp4':

2018-10-24 13:08:23.024 14447-14447/? D/AppDebug: onprogress message=  Metadata:
2018-10-24 13:08:23.025 14447-14447/? D/AppDebug: onprogress message=    major_brand     : isom
2018-10-24 13:08:23.025 14447-14447/? D/AppDebug: onprogress message=    minor_version   : 512
2018-10-24 13:08:23.026 14447-14447/? D/AppDebug: onprogress message=    compatible_brands: isomiso2avc1mp41
2018-10-24 13:08:23.026 14447-14447/? D/AppDebug: onprogress message=    encoder         : Lavf56.40.101
2018-10-24 13:08:23.027 14447-14447/? D/AppDebug: onprogress message=  Duration: 00:06:34.51, start: 0.000000, bitrate: 1683 kb/s
2018-10-24 13:08:23.027 14447-14447/? D/AppDebug: onprogress message=    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1550 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
2018-10-24 13:08:23.027 14447-14447/? D/AppDebug: onprogress message=    Metadata:
2018-10-24 13:08:23.028 14447-14447/? D/AppDebug: onprogress message=      handler_name    : VideoHandler
2018-10-24 13:08:23.028 14447-14447/? D/AppDebug: onprogress message=    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 126 kb/s (default)
2018-10-24 13:08:23.028 14447-14447/? D/AppDebug: onprogress message=    Metadata:
2018-10-24 13:08:23.029 14447-14447/? D/AppDebug: onprogress message=      handler_name    : SoundHandler
ixLikro commented 5 years ago

metoo

have you found a solution?

ixLikro commented 5 years ago

i found a solution, at least in my case fixed the -y flag the problem

Brianvdb commented 5 years ago

-y flag should fix this.