使用Python借助pymediainfo读取视频文件的详细信息

1. 按

对于mp4文件,目前已测试在Windows10上设置后支持显示的的详细信息有:标题(title)、备注(comment)、流派(genre)、作曲者(composer
在这里插入图片描述
如需查看更多的详细信息,可以参考本文自己进行编写Python代码来查看。
如需编程批量设置视频文件的详细信息,可以参考:使用FFmpeg设置视频文件的详细信息

2. 代码

安装pymediainfo可以参考:Python3安装pymediainfo

from pymediainfo import MediaInfo
from moviepy.editor import VideoFileClip

media_info = MediaInfo.parse('t2.mp4')

data = media_info.to_json()
print(data)

3. 输出结果

注意:详细信息只有不为空的时候才能找到,如标题(title)为空,则无法找到title这个键。

{
	"tracks": [{
		"track_type": "General",
		"count": "334",
		"count_of_stream_of_this_kind": "1",
		"kind_of_stream": "General",
		"other_kind_of_stream": ["General"],
		"stream_identifier": "0",
		"count_of_video_streams": "1",
		"video_format_list": "AVC",
		"video_format_withhint_list": "AVC",
		"codecs_video": "AVC",
		"video_language_list": "English",
		"complete_name": "t2.mp4",
		"file_name_extension": "t2.mp4",
		"file_name": "t2",
		"file_extension": "mp4",
		"format": "MPEG-4",
		"other_format": ["MPEG-4"],
		"format_extensions_usually_used": "braw mov mp4 m4v m4a m4b m4p m4r 3ga 3gpa 3gpp 3gp 3gpp2 3g2 k3g jpm jpx mqv ismv isma ismt f4a f4b f4v",
		"commercial_name": "MPEG-4",
		"format_profile": "Base Media",
		"internet_media_type": "video/mp4",
		"codec_id": "isom",
		"other_codec_id": ["isom (isom/iso2/avc1/mp41)"],
		"codec_id_url": "http://www.apple.com/quicktime/download/standalone.html",
		"codecid_compatible": "isom/iso2/avc1/mp41",
		"file_size": 6997537,
		"other_file_size": ["6.67 MiB", "7 MiB", "6.7 MiB", "6.67 MiB", "6.673 MiB"],
		"duration": 7842,
		"other_duration": ["7 s 842 ms", "7 s 842 ms", "7 s 842 ms", "00:00:07.842", "00:00:07;25", "00:00:07.842 (00:00:07;25)"],
		"overall_bit_rate": 7138523,
		"other_overall_bit_rate": ["7 139 kb/s"],
		"frame_rate": "29.970",
		"other_frame_rate": ["29.970 FPS"],
		"frame_count": "235",
		"stream_size": 4297,
		"other_stream_size": ["4.20 KiB (0%)", "4 KiB", "4.2 KiB", "4.20 KiB", "4.196 KiB", "4.20 KiB (0%)"],
		"proportion_of_this_stream": "0.00061",
		"headersize": "40",
		"datasize": "6993248",
		"footersize": "4249",
		"isstreamable": "No",
		"title": "coco56_title",
		"collection": "coco56_show",
		"album": "coco56_album",
		"album_performer": "coco56_album_artist",
		"track_name": "coco56_title",
		"grouping": "coco56_grouping",
		"composer": "coco56_composer",
		"genre": "coco56_genre",
		"description": "coco56_description",
		"file_creation_date": "UTC 2020-08-25 16:19:09.863",
		"file_creation_date__local": "2020-08-26 00:19:09.863",
		"file_last_modification_date": "UTC 2020-08-26 10:51:05.790",
		"file_last_modification_date__local": "2020-08-26 18:51:05.790",
		"writing_application": "Lavf58.50.100",
		"other_writing_application": ["Lavf58.50.100"],
		"copyright": "coco56_copyright",
		"lyrics": "coco56_lyrics",
		"comment": "coco56_comment",
		"longdescription": "coco56_synopsis",
		"part_id": "coco56_episode_id",
		"tvnetworkname": "coco56_network"
	}, {
		"track_type": "Video",
		"count": "378",
		"count_of_stream_of_this_kind": "1",
		"kind_of_stream": "Video",
		"other_kind_of_stream": ["Video"],
		"stream_identifier": "0",
		"streamorder": "0",
		"track_id": 1,
		"other_track_id": ["1"],
		"format": "AVC",
		"other_format": ["AVC"],
		"format_info": "Advanced Video Codec",
		"format_url": "http://developers.videolan.org/x264.html",
		"commercial_name": "AVC",
		"format_profile": "High@L5.1",
		"format_settings": "CABAC / 4 Ref Frames",
		"format_settings__cabac": "Yes",
		"other_format_settings__cabac": ["Yes"],
		"format_settings__reference_frames": 4,
		"other_format_settings__reference_frames": ["4 frames"],
		"internet_media_type": "video/H264",
		"codec_id": "avc1",
		"codec_id_info": "Advanced Video Coding",
		"duration": 7842,
		"other_duration": ["7 s 842 ms", "7 s 842 ms", "7 s 842 ms", "00:00:07.842", "00:00:07;25", "00:00:07.842 (00:00:07;25)"],
		"bit_rate": 7134890,
		"other_bit_rate": ["7 135 kb/s"],
		"width": 4096,
		"other_width": ["4 096 pixels"],
		"height": 2048,
		"other_height": ["2 048 pixels"],
		"sampled_width": "4096",
		"sampled_height": "2048",
		"pixel_aspect_ratio": "1.000",
		"display_aspect_ratio": "2.000",
		"other_display_aspect_ratio": ["2.000"],
		"rotation": "0.000",
		"frame_rate_mode": "CFR",
		"other_frame_rate_mode": ["Constant"],
		"framerate_mode_original": "VFR",
		"frame_rate": "29.970",
		"other_frame_rate": ["29.970 (30000/1001) FPS"],
		"framerate_num": "30000",
		"framerate_den": "1001",
		"frame_count": "235",
		"color_space": "YUV",
		"chroma_subsampling": "4:2:0",
		"other_chroma_subsampling": ["4:2:0"],
		"bit_depth": 8,
		"other_bit_depth": ["8 bits"],
		"scan_type": "Progressive",
		"other_scan_type": ["Progressive"],
		"bits__pixel_frame": "0.028",
		"stream_size": 6993240,
		"other_stream_size": ["6.67 MiB (100%)", "7 MiB", "6.7 MiB", "6.67 MiB", "6.669 MiB", "6.67 MiB (100%)"],
		"proportion_of_this_stream": "0.99939",
		"writing_library": "x264 - core 160",
		"other_writing_library": ["x264 core 160"],
		"encoded_library_name": "x264",
		"encoded_library_version": "core 160",
		"encoding_settings": "cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00",
		"language": "en",
		"other_language": ["English", "English", "en", "eng", "en"],
		"codec_configuration_box": "avcC"
	}]
}
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页