Android多媒体信息获取
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android多媒体信息获取相关的知识,希望对你有一定的参考价值。
参考技术A android开发中,常常需要获取本地或者网络多媒体的一些基本信息。MediaMetadataRetriever类位于android.media包下,提供了用于从输入媒体文件检索帧和元数据的统一接口,可以很方便实现这些功能。本例中提供了获取本地视频和网络视频第一帧图片的功能,首先初始化MediaMetadataRetriever,如果是本地视频设置数据源时通过 Uri.fromFile()转化为Uri对象,再通过MediaMetadataRetriever的getFrameAtTime()方法默认获取第一帧图片。如果是网络视频直接将url设置为数据源即可。
ffmpeg音视频开发: 使用ffprobe获取媒体信息
一、环境介绍
操作系统: win10 64位
ffmpge: 4.2.2 (官网下载的可执行文件命令)
win32下使用FFMPEG 4.2.2库下载地址:https://download.csdn.net/download/xiaolong1126626497/12321684
二、ffprobe用法
2.1 基本使用: 查看媒体信息
用法:
C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffprobe.exe -i .\\jiyi.mp4
示例:
PS D:\\> C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffprobe.exe -i .\\jiyi.mp4
ffprobe version 4.2.2 Copyright (c) 2007-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\\jiyi.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.29.100
Duration: 00:00:54.15, start: 0.000000, bitrate: 574 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 960x544, 518 kb/s, 29.97 fps, 29.97 tbr, 19200 tbn, 38400 tbc (default)
Metadata:
handler_name : Core Media Video
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 47 kb/s (default)
Metadata:
handler_name : Core Media Audio
PS D:\\>
2.2 使用JSON格式输出信息
用法:
C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffprobe.exe -v quiet -of json -i .\\jiyi.mp4 -show_streams
示例:
PS D:\\> C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffprobe.exe -v quiet -of json -i .\\jiyi.mp4 -show_streams
{
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "High",
"codec_type": "video",
"codec_time_base": "8123/486900",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 960,
"height": 544,
"coded_width": 960,
"coded_height": 544,
"has_b_frames": 1,
"pix_fmt": "yuv420p",
"level": 31,
"color_range": "tv",
"color_space": "bt709",
"color_transfer": "bt709",
"color_primaries": "bt709",
"chroma_location": "left",
"refs": 1,
"is_avc": "true",
"nal_length_size": "4",
"r_frame_rate": "30000/1001",
"avg_frame_rate": "243450/8123",
"time_base": "1/19200",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 1039744,
"duration": "54.153333",
"bit_rate": "518796",
"bits_per_raw_sample": "8",
"nb_frames": "1623",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"language": "und",
"handler_name": "Core Media Video"
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio",
"codec_time_base": "1/44100",
"codec_tag_string": "mp4a",
"codec_tag": "0x6134706d",
"sample_fmt": "fltp",
"sample_rate": "44100",
"channels": 1,
"channel_layout": "mono",
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 2387471,
"duration": "54.137664",
"bit_rate": "47025",
"max_bit_rate": "47025",
"nb_frames": "2332",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"language": "und",
"handler_name": "Core Media Audio"
}
}
]
}
PS D:\\>
以上是关于Android多媒体信息获取的主要内容,如果未能解决你的问题,请参考以下文章