python获取mp3音频数据,python 读取音频文件的详细信息

有一项测试的需求是判断录像是否和预期一致,检查项是:分辨率、录像时长等内容

c1c31cfdda1a3a030b5efddb73ddeaa1.png 文件的详细信息.png

os模块有一个stat()方法

st_mode: inode 保护模式

st_ino: inode 节点号。

st_dev: inode 驻留的设备。

st_nlink: inode 的链接数。

st_uid: 所有者的用户ID。

st_gid: 所有者的组ID。

st_size: 普通文件以字节为单位的大小;包含等待某些特殊文件的数据。

st_atime: 上次访问的时间。

st_mtime: 最后一次修改的时间。

st_ctime: 由操作系统报告的"ctime"。在某些系统上(如Unix)是最新的元数据更改的时间,在其它系统上(如Windows)是创建时间。常规属性

26d9fb7f2e19f3ac077d472c59273d40.png 文件的常规属性.png

pymediainfo

pymediainfo 安装

1、使用pip安装

1pip install pymediainfo

2、下载MediaInfo

528685d83c11afbf075206f15ff5e26e.png 获取dll文件.png

将dll文件复制到python更目录下

以上就完成了环境的搭建

开始获取音频文件的详细信息

1.从网上下载一个ts媒体文件

1from pymediainfo import MediaInfo

2media_info = MediaInfo.parse('C:\\Users\\Administrator\\Desktop\\test.ts')

3data = media_info.to_json()

4print(data)

更多用法欢迎去pymediainfo的官方文档查找,虽然我没找到data中就包含了我们所需要的内容,大概长这样,不过里面不知道为什么有很多重复的内容,但是已经满足需求了。

1{

2  "tracks": [

3    {

4      "track_type": "General",

5      "count": "332",

6      "count_of_stream_of_this_kind": "1",

7      "kind_of_stream": "General",

8      "other_kind_of_stream": [

9        "General"

10      ],

11      "stream_identifier": "0",

12      "track_id": 1,

13      "other_track_id": [

14        "1 (0x1)"

15      ],

16      "count_of_video_streams": "1",

17      "count_of_audio_streams": "1",

18      "count_of_menu_streams": "1",

19      "video_format_list": "AVC",

20      "video_format_withhint_list": "AVC",

21      "codecs_video": "AVC",

22      "audio_format_list": "AAC",

23      "audio_format_withhint_list": "AAC",

24      "audio_codecs": "AAC LC",

25      "menu_format_list": "AVC / AAC",

26      "menu_format_withhint_list": "AVC / AAC",

27      "menu_codecs": "AVC / AAC LC",

28      "complete_name": "C:\\Users\\Administrator\\Desktop\\test.ts",

29      "folder_name": "C:\\Users\\Administrator\\Desktop",

30      "file_name": "test.ts",

31      "other_file_name": [

32        "test"

33      ],

34      "file_extension": "ts",

35      "format": "MPEG-TS",

36      "other_format": [

37        "MPEG-TS"

38      ],

39      "format_extensions_usually_used": "ts m2t m2s m4t m4s tmf ts tp trp ty",

40      "commercial_n

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值