今天给大家分享一个专业的查看视频,图片,音频的全部信息的方法,该方法几乎支持所有视频格式如:MP4,RM,AVI,MOV,和音频格式如:MP3,m4a,AAC,WAV,以及常见的图片格式如:jpeg,GIF,jpg,png,其它格式可以自行探索。相关功能我已经集成到了这里,点开就可以使用:https://www.raoyunsoft.com/videotools/get_video_info
使用的核心库是FFmpeg,感兴趣的小伙伴可以去了解一下,具体的安装方法可以百度一下,很多人讲过了
比如我们需要查看一个视频的全部信息输入以下命令就可以了:
ffprobe -v error -show_format -show_streams IMG_4814.MOV
我们可以查询到视频的宽高,编码格式,帧率,时长,比特率。音频的采样率,声道,编码格式,时长,比特率,甚至可以查看到文件的经纬度,这个视频文件是用IPhone拍的,采用AirDrop传到电脑上的(通过微信传输视频,图片位置信息回被抹掉的),位置信息存在了com.apple.quicktime.location.ISO6709字段里面,查看的结果如下:
file_name=IMG_4814.MOV
[STREAM]
index=0
codec_name=hevc
codec_long_name=H.265 / HEVC (High Efficiency Video Coding)
profile=Main
codec_type=video
codec_time_base=1121/33600
codec_tag_string=hvc1
codec_tag=0x31637668
width=1920
height=1080
coded_width=1920
coded_height=1088
has_b_frames=2
sample_aspect_ratio=N/A
display_aspect_ratio=N/A
pix_fmt=yuv420p
level=120
color_range=tv
color_space=bt709
color_transfer=bt709
color_primaries=bt709
chroma_location=unspecified
field_order=unknown
timecode=N/A
refs=1
id=N/A
r_frame_rate=30000/1001
avg_frame_rate=33600/1121
time_base=1/600
start_pts=0
start_time=0.000000
duration_ts=3363
duration=5.605000
bit_rate=8137257
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=168
nb_read_frames=N/A
nb_read_packets=N/A
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
TAG:creation_time=2022-06-29T09:20:44.000000Z
TAG:language=und
TAG:handler_name=Core Media Video
TAG:encoder=HEVC
[/STREAM]
[STREAM]
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=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/44100
start_pts=0
start_time=0.000000
duration_ts=247107
duration=5.603333
bit_rate=164817
max_bit_rate=192000
bits_per_raw_sample=N/A
nb_frames=244
nb_read_frames=N/A
nb_read_packets=N/A
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
TAG:creation_time=2022-06-29T09:20:44.000000Z
TAG:language=und
TAG:handler_name=Core Media Audio
[/STREAM]
[STREAM]
index=2
codec_name=unknown
codec_long_name=unknown
profile=unknown
codec_type=data
codec_tag_string=mebx
codec_tag=0x7862656d
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/600
start_pts=0
start_time=0.000000
duration_ts=3363
duration=5.605000
bit_rate=14
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=1
nb_read_frames=N/A
nb_read_packets=N/A
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
TAG:creation_time=2022-06-29T09:20:44.000000Z
TAG:language=und
TAG:handler_name=Core Media Metadata
[/STREAM]
[STREAM]
index=3
codec_name=unknown
codec_long_name=unknown
profile=unknown
codec_type=data
codec_tag_string=mebx
codec_tag=0x7862656d
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/600
start_pts=0
start_time=0.000000
duration_ts=3363
duration=5.605000
bit_rate=11
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=1
nb_read_frames=N/A
nb_read_packets=N/A
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
TAG:creation_time=2022-06-29T09:20:44.000000Z
TAG:language=und
TAG:handler_name=Core Media Metadata
[/STREAM]
[STREAM]
index=4
codec_name=unknown
codec_long_name=unknown
profile=unknown
codec_type=data
codec_tag_string=mebx
codec_tag=0x7862656d
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/600
start_pts=0
start_time=0.000000
duration_ts=3363
duration=5.605000
bit_rate=34529
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=168
nb_read_frames=N/A
nb_read_packets=N/A
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
TAG:creation_time=2022-06-29T09:20:44.000000Z
TAG:language=und
TAG:handler_name=Core Media Metadata
[/STREAM]
[FORMAT]
nb_streams=5
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=5.605000
size=5852970
bit_rate=8353926
probe_score=100
TAG:major_brand=qt
TAG:minor_version=0
TAG:compatible_brands=qt
TAG:creation_time=2022-06-29T09:20:44.000000Z
TAG:com.apple.quicktime.location.accuracy.horizontal=38.654282
TAG:com.apple.quicktime.location.ISO6709=+31.1917+120.1867+128.700/
TAG:com.apple.quicktime.make=Apple
TAG:com.apple.quicktime.model=iPhone 11 Pro
TAG:com.apple.quicktime.software=15.5
TAG:com.apple.quicktime.creationdate=2022-06-29T17:20:43+0800
[/FORMAT]
查询图片信息:
ffprobe -v error -show_format -show_streams 1b86a909dcf84d9efd0bf4666f74c604.jpeg
结果如下:
file_name=4cc85302cace9bda991bfe1e5ffb1650.jpeg
[STREAM]
index=0
codec_name=mjpeg
codec_long_name=Motion JPEG
profile=Baseline
codec_type=video
codec_time_base=0/1
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=1200
height=675
coded_width=1200
coded_height=675
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuvj420p
level=-99
color_range=pc
color_space=bt470bg
color_transfer=unknown
color_primaries=unknown
chroma_location=center
field_order=unknown
timecode=N/A
refs=1
id=N/A
r_frame_rate=25/1
avg_frame_rate=0/0
time_base=1/25
start_pts=0
start_time=0.000000
duration_ts=1
duration=0.040000
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
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
[/STREAM]
[FORMAT]
nb_streams=1
nb_programs=0
format_name=image2
format_long_name=image2 sequence
start_time=0.000000
duration=0.040000
size=117718
bit_rate=23543600
probe_score=50
[/FORMAT]