[英]Get duration of an uploaded audio/video file
I want to get the duration of audio/video files that are being uploaded into the system. 我想获取上传到系统中的音频/视频文件的持续时间。 Earlier I had used hachoir-metadata
, but it's not maintained anymore I guess, as there is no python 3 compatible module for that. 之前我使用过hachoir-metadata
,但是我猜它不再维护了,因为没有python 3兼容模块。
For anyone looking for this particular thing, follow following steps: 对于寻找此特定事物的任何人,请执行以下步骤:
avconv
command. 您可以通过键入并尝试执行avconv
命令来检查它。 If not present, do sudo apt-get install libav-tools
如果不存在,请执行sudo apt-get install libav-tools
ffmpeg -i myvideo 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//
然后,尝试使用此命令ffmpeg -i myvideo 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//
ffmpeg -i myvideo 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//
ffmpeg -i myvideo 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//
(I found this command here ). ffmpeg -i myvideo 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//
(我在这里找到此命令)。 Correct me if I am wrong somewhere 如果我在某个地方错了,请纠正我
if you know about ffmpeg
, you can use ffmpeg to read the audio or video, it will output the duration of audio or video 如果您了解ffmpeg
,则可以使用ffmpeg读取音频或视频,它将输出音频或视频的持续时间
$ ffmpeg -i "Gotye - Somebody That I Used To Know (feat. Kimbra) - official video.mp4" 2>&1 | grep -E -o "Duration: \S+"
Duration: 00:04:03.90,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.