利用Python库VideoFileClip读取MP4视频长度的代码

01- 安装库VideoFileClip

pip install -i https://mirrors.aliyun.com/pypi/simple moviepy

在这里插入图片描述

02-代码如下:

from moviepy.editor import VideoFileClip

video_path = r"E:\My_Data\视频素材\H-264\V00099E.mp4"

# 加载视频文件
clip = VideoFileClip(video_path)

# 获取视频总时长(以秒为单位)
total_duration = clip.duration

# 打印总时长
print("视频总时长:{} 秒".format(total_duration))

# 关闭视频文件
clip.close()

运行效果如下:
在这里插入图片描述

相关推荐

  1. python转换视频格式为mp4

    2024-01-27 02:18:01       15 阅读
  2. 代码】jetson+OLED屏幕+显示mp4视频

    2024-01-27 02:18:01       13 阅读
  3. 数据读取长度不正确 python

    2024-01-27 02:18:01       6 阅读
  4. 解决mp4视频无法拖动进度条问题

    2024-01-27 02:18:01       111 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-27 02:18:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-27 02:18:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-27 02:18:01       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-27 02:18:01       20 阅读

热门阅读

  1. vue开发的PC端项目使用postcss-to-viewport适配移动端

    2024-01-27 02:18:01       40 阅读
  2. WordPress wp-file-manager 文件上传漏洞 CVE-2020-25213

    2024-01-27 02:18:01       30 阅读
  3. element中form校验中清除校验不通过的提示语

    2024-01-27 02:18:01       37 阅读
  4. 【Git】Conventional Commit提交规范

    2024-01-27 02:18:01       29 阅读
  5. [GN] Vue3.2 快速上手 ----常用API及其新组件

    2024-01-27 02:18:01       32 阅读
  6. CentOS7开机自动执行脚本

    2024-01-27 02:18:01       38 阅读
  7. 算法37:最大矩形(力扣84、85题)---单调栈

    2024-01-27 02:18:01       37 阅读
  8. KMean 聚类

    2024-01-27 02:18:01       36 阅读