ffmpeg-kit icon indicating copy to clipboard operation
ffmpeg-kit copied to clipboard

FFprobeKit output is not as expected, no matter what the commands and files are

Open tasy5kg opened this issue 2 years ago • 7 comments

Description

FFprobeKit.execute(command).getOutput() result is not as expected, no matter what the commands and files are.


To Reproduce

Sometimes I want to get media properties with FFprobe commands. As sample scripts mentioned on https://trac.ffmpeg.org/wiki/FFprobeTips ,

to get the format duration:

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

It should just return something like 30.024000, and I got similar results when using the FFmpeg command line tool on my computer.

But when I try to execute it in FFprobeKit:

FFprobeKit.execute("-v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "+path).getOutput()

It always returns something like this:

1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
und
VideoHandler
[0][0][0][0]
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
und
SoundHandler
[0][0][0][0]
38.058000
isom
512
isomiso2avc1mp41
Lavf58.45.100

Another example:

To get frame rate, without formatted:

ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate input.mp4

When using the FFmpeg command line tool on my computer, it should return something like this:

[STREAM]
avg_frame_rate=32835/569
[/STREAM]

Execute it in FFprobeKit:

FFprobeKit.execute("-v error -select_streams v:0 -show_entries stream=avg_frame_rate "+path).getOutput()

returns:

[STREAM]
avg_frame_rate=32835/569
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
TAG:language=und
TAG:handler_name=VideoHandler
TAG:vendor_id=[0][0][0][0]
[/STREAM]
[FORMAT]
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2avc1mp41
TAG:encoder=Lavf58.45.100
[/FORMAT]

It seems these strange outputs are returned regardless of the command and file.


Expected behavior

Returns consistent results with command line tools.


Environment

  • Platform: Android 12
  • Architecture: arm64-v8a
  • Version: com.arthenica:ffmpeg-kit-min:4.5.1-1
  • Android Studio version: 2021.2.1 Patch 2

tasy5kg avatar Aug 11 '22 17:08 tasy5kg

I don't see this issue in the current test applications we have under ffmpeg-kit-test. They all work as expected.

Consider providing detailed instructions to reproduce this if you need help.

tanersener avatar Aug 11 '22 18:08 tanersener

@tanersener ,Hello.

I have cloned ffmpeg-kit-test/android to local and built test-app-maven-central . The same issue has been reproduced.

~~Update: There is no problem with the source code. I didn't download the SDK tools 30 version, so I changed the compileSdkVersion from 30 to 32, which caused this problem.~~

Update: This is still not the right reason. Please check out later posts. Sorry for the misunderstanding.


Environment

  • Platform: Android 12 (Physical device)
  • Architecture: arm64-v8a
  • Android Studio version: 2021.2.1 Patch 2
  • compileSdkVersion: 32
  • Sample video: 20220811_114433_500.mp4 (4.96 MB)

In test-app-maven-central

Input command:

-v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 /storage/emulated/0/Download/20220811_114433_500.mp4

Then click RUN FFPROBE, result:

Screenshot_2022-08-12-03-02-04-488_com arthenica


In shell (expected behavior)

Input command:

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 /storage/emulated/0/Download/20220811_114433_500.mp4

Result:

15.240000

Screenshot_2022-08-12-02-47-04-727_com termux-edi

tasy5kg avatar Aug 11 '22 19:08 tasy5kg

~~Maybe I found the reason... When switching compileSdkVersion from 32 to 30 it returned the correct result.~~

Update: This is still not the right reason. Please check out later posts. Sorry for the misunderstanding.

Screenshot_2022-08-12-03-13-33-450_com arthenica

tasy5kg avatar Aug 11 '22 19:08 tasy5kg

Does this occur on emulators?

None of my physical devices are on Android 12. I tested this on an arm64 Android 12 emulator. But didn't see any problems on it.

tanersener avatar Aug 11 '22 19:08 tanersener

@tanersener , I went ahead and tried a few things and found that the issue is not related to the SDK version.

Seems to be an issue with SAF.


The following operation runs ffmpeg-kit-test/android/test-app-maven-central without modifying compileSdkVersion or any other code.


If you

  1. open the test-app
  2. execute the FFprobe command directly in the COMMAND menu

you can get the correct result like this screen record:

https://user-images.githubusercontent.com/30869777/184234897-bcbcd691-a1d4-43cd-8d50-bd7980b37146.mp4


If you

  1. open the test-app
  2. switch to SAF menu
  3. click RUN FFPROBE
  4. select any media file
  5. get result
  6. back to COMMAND menu
  7. input FFprobe command below
-v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 /storage/emulated/0/Download/20220811_114433_500.mp4

you will get unexpected result like this screen record:

https://user-images.githubusercontent.com/30869777/184235783-5af75914-04a6-4536-9501-92db83e5579f.mp4

This issue is reproducible on physical and virtual machines. Test on API 26 x86_64 and API 32 arm64-v8a.

tasy5kg avatar Aug 11 '22 20:08 tasy5kg

Thanks. I managed to reproduce it using the instructions in the latest post.

We need to debug & analyse this to understand why it is happening.

tanersener avatar Aug 11 '22 22:08 tanersener

Yes there bug in android 12+

ArtiomYak avatar Aug 13 '22 06:08 ArtiomYak

My tests show that this bug doesn't originate from saf. It is a generic issue about ffprobe. It affects ffprobe on all platforms.

I fixed it on the development branch. The fix will be included in the next release which I'm working on.

tanersener avatar Aug 25 '22 21:08 tanersener