利用ffmpeg检查mp3的codec是否为mp3的python的脚本

很简单如下:就是执行命令,然后检查。执行shell命令时文件名中的空格就很悲剧,要用”””转义

 

import  sys

import os

import commands

 

print ‘hello’

for i in sys.argv:

    print i

#

f = open(‘error_file’, ‘w’)

str = os.popen(“ls”).read();

filesList = str.split(“n”);

for file in filesList:

        if (file.find(“.mp3”) > 0):

                mp3Info = commands.getoutput(“ffmpeg -i ” + “”” + file + “””);

                print file;

                #print ‘mp3info = ‘

                #print  mp3Info

                if (not (mp3Info.find(“Audio: mp3”) > 0)):

                        f.write(file + ‘n’)

 

f.close()

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据