今さらPython

これはなに?

我が家で長年使っていた、Ruby版の雑品のひとつを書き換えます。
これはアクションカメラの動画やネットで拾った動画から音声だけを抜き出すものです。ffmpegを中で呼んでいます。

注意点

#!/usr/bin/python3 

import os
import re
import subprocess

p2 = re.compile(r'\.([Ww][Aa][Vv]|[Oo][Gg][Gg])$')
p = re.compile(r'\.([a-zA-Z]+)$')
#p = re.compile(r'\.([Ww][Ee][Bb][Mm])$')
for f in os.listdir("."):
   if((p.search(f) != None) and (p2.search(f) == None)):
           f2 = p.sub('.ogg',f)
           if os.path.isfile(f2):
               print("あり:"+f2)
           else:
               print("なし:"+f2)
               x = "ffmpeg " + "-vn -i \"" + f + "\" \"" + f2 + "\""
               print(x)
               subprocess.run(x,shell=True)

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-12-03 (土) 02:52:51