bravobit / FFmpeg-Android

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

get Information as JSON or key value #111

Open MohtashamVahid opened 5 years ago

MohtashamVahid commented 5 years ago

Hi How can I get information about a video as JSON for example Duration or bitrate
now I get as string

input


execFFmpegBinary(new String[]{"-i",inputPath});

output


Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/test1/20180113_112128.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2018-01-13 07:52:30 com.android.version: 6.0 Duration: 00:01:00.59, start: 0.000000, bitrate: 6107 kb/s Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 640x480, 5909 kb/s, SAR 1:1 DAR 4:3, 29.60 fps, 29.58 tbr, 90k tbn, 180k tbc (default) Metadata: rotate : 90 creation_time : 2018-01-13 07:52:30 handler_name : VideoHandle Side data: displaymatrix: rotation of -90.00 degrees Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 156 kb/s (default) Metadata: creation_time : 2018-01-13 07:52:30 handler_name : SoundHandle At least one output file must be specified

liamcottle commented 5 years ago

You could use FFProbe to retrieve the information you want from the video.

If you want JSON, then you will need to create a JSONObject yourself, and populate it with the keys you want, and the apropriate data from the FFProbe output.