使用正则表达式和ffmpeg获取视频的长度 [英] Get length of a video using regex and ffmpeg

查看:1260
本文介绍了使用正则表达式和ffmpeg获取视频的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从以下 ffmpeg -i 输出,如何获取长度(00:35) -

From the following ffmpeg -i output, how would I get the length (00:35)--

$ ffmpeg -i 1video.mp4

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/david/Desktop/1video.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
     creation_time   : 2010-01-24 00:55:16
  Duration: 00:00:35.08, start: 0.000000, bitrate: 354 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 640x360 [PAR 1:1 DAR 16:9], 597 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc
    Metadata:
      creation_time   : 2010-01-24 00:55:16
    Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 109 kb/s
    Metadata:
      creation_time   : 2010-01-24 00:55:17
At least one output file must be specified


推荐答案

您可以使用shell

You can use the shell

$ ff=$(ffmpeg -i video.mp4 2>&1)
$ d="${ff#*Duration: }"
$ echo "${d%%,*}"

这篇关于使用正则表达式和ffmpeg获取视频的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆