5

ffmpegを使用してaviにテキストを追加しようとしていますが、正しく設定できないようです。

助けてください:

import subprocess

ffmpeg = "C:\\ffmpeg_10_6_11.exe"
inVid = "C:\\test_in.avi"
outVid = "C:\\test_out.avi"

proc = subprocess.Popen(ffmpeg + " -i " + inVid + " -vf drawtext=fontfile='arial.ttf'|text='test' -y " + outVid , shell=True, stderr=subprocess.PIPE)
proc.wait()
print proc.stderr.read()
4

2 に答える 2

6

コロン「:」と円記号「\」は、drawtextのパラメータを指定するときに特別な意味を持ちます。したがって、「:」を「\:」に、「\」を「\\」に変換して、それらをエスケープすることができます。また、パスにスペースが含まれている場合は、フォントファイルへのパスを一重引用符で囲むことができます。

だからあなたは

ffmpeg -i C:\Test\rec\vid_1321909320.avi -vf drawtext=fontfile='C\:\\Windows\\Fonts\\arial.ttf':text=test vid_1321909320.flv
于 2013-01-25T16:58:37.483 に答える
5

HA

C:\ Windows \ Fontsなどの二重コロン「:」が分割として機能していたことが判明したため、フォントのフルパスを入力しているときにffmpegは次のようにコマンドを読み取っていました

元のコマンド

" -vf drawtext=fontfile='C:\\Windows\\fonts\\arial.ttf'|text='test' "

ffmpegの解釈

-vf drawtext=  # command

fontfile='C    # C is the font file because the : comes after it signalling the next key

arial.ttf'     # is the next key after fontfile = C (because the C is followed by a : signalling the next key)

:text          # is the value the key "arial.tff" is pointing to

='test'        # is some arb piece of information put in by that silly user

したがって、これを修正するには、フォントファイルパスの:を削除する必要があります。

私の最終的な作業コード:

import subprocess

ffmpeg = "C:\\ffmpeg_10_6_11.exe"
inVid = "C:\\test_in.avi"
outVid = "C:\\test_out.avi"

subprocess.Popen(ffmpeg + " -i " + inVid + ''' -vf drawtext=fontfile=/Windows/Fonts/arial.ttf:text=test ''' + outVid , shell=True)
于 2011-11-21T13:58:28.593 に答える