1

I'm using FFmpegAndroid library in my project to overlay a video.

The ffmpeg process is inside a service and I want to show the user a notification with progress to determine the progress of the process.

I've went through the outputs of the ffmpeg but there's nothing that specify the estimated duration time. Maybe it's possible to calculate it by other params that shown in the output such as fps, bitrate or speed but I have no clue..

Any ideas?

Juvi
  • 1,078
  • 1
  • 19
  • 38

2 Answers2

3

For such purpose you can use FFProbe with this command:

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 example.mp4

The output will be in seconds:

enter image description here

So to show the progress of your video processing, first you use FFProbe to get the video length, then while FFMpeg works on the processing you calculate remaining time from FFMpeg progress output.

Koby Douek
  • 16,156
  • 19
  • 74
  • 103
  • thanks for the quick response, is ffprobe part of the ffmpeg library? – Juvi Jun 14 '17 at 11:37
  • @Juvi Yes it is. – Koby Douek Jun 14 '17 at 11:38
  • So for example, i'm resizing my video, where do i specify the resize command as i do in ffmpeg? i.e: -vf scale=240:360 – Juvi Jun 14 '17 at 11:39
  • First you use ffprobe to get the video length, then while ffmpeg works you calculate remaining time from ffmpeg progress output. – Koby Douek Jun 14 '17 at 11:40
  • I'm getting "ffmpeg Unrecognized option 'show_entries'", might be because it's an android lib of ffmpeg? – Juvi Jun 14 '17 at 11:48
  • it is... "ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 " + screenRecordVideoPath – Juvi Jun 14 '17 at 11:52
  • @Juvi hmmm... You can still use `ffprobe -of default=noprint_wrappers=1:nokey=1 example.mp4` and it will show you the duration, but with all other data... is that OK ? – Koby Douek Jun 14 '17 at 11:56
  • Same issue about unrecognized options.. My guess is that ffprobe isn't supported in the ffmpeg version for android – Juvi Jun 14 '17 at 12:04
  • @Juvi I think that you do not understand that FFprobe is not a command in FFMpeg, it's another EXE in the same library. – Koby Douek Jun 14 '17 at 12:06
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/146653/discussion-between-juvi-and-koby-douek). – Juvi Jun 14 '17 at 12:11
0

The way to calculate the progress is first to get the video duration:

can be done with ffmpeg and also with android native class such as MediaMetadataRetriever as described here.

After we get in onProgress callback of ffmpeg execution the time of the video i.e:

frame=  171 fps= 27 q=29.0 size=      43kB time=00:00:04.06 bitrate=  87.5kbits/s dup=12 drop=9 speed=0.651x

Than we are able to get the progress percent of the excution.

Juvi
  • 1,078
  • 1
  • 19
  • 38