English 中文(简体)
FFmpeg从多个线路上提取文字
原标题:FFmpeg drawtext over multiple lines

我有以下法典:

import subprocess , os

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

if os.path.exists( outVid ):
os.remove( outVid )
proc = subprocess.Popen(ffmpeg + " -i " + inVid +     -vf drawtext=fontfile=/Windows/Fonts/arial.ttf:text="onLine1 onLine2 onLine3":fontcolor=white:fontsize=20 -y     + outVid , shell=True, stderr=subprocess.PIPE)
proc.wait()
print proc.stderr.read()
os.startfile( outVid )

a. 书写录像文件。 但我想写出许多行文,而不是仅仅把案文放在一行。

我如何能够这样做?

最佳回答

你们可以通过使用[打]标签,在一份档案中注明多条文字,并用 com语列出每一条文字。 如果你通过各自的定位方法引导每一条案文,这允许你使用多个线。 举例来说,指挥线照此办理(在屏幕中排出第1行,随后将第25条列以下):

ffmpeg -i test_in.avi -vf "[in]drawtext=fontsize=20:fontcolor=White:fontfile= /Windows/Fonts/arial.ttf :text= onLine1 :x=(w)/2:y=(h)/2, drawtext=fontsize=20:fontcolor=White:fontfile= /Windows/Fonts/arial.ttf :text= onLine2 :x=(w)/2:y=((h)/2)+25, drawtext=fontsize=20:fontcolor=White:fontfile= /Windows/Fonts/arial.ttf :text= onLine3 :x=(w)/2:y=((h)/2)+50[out]" -y test_out.avi
问题回答

看看ffmpeg的源代码(vs_drawtext.c):

static inline int is_newline(uint32_t c)
{
    return c ==  
  || c ==  
  || c ==  f  || c ==  v ;
}

您可在与<代码>^L或.v对应的正文行中插入f>>。 例如:

-filter_complex "[in] drawtext=fontsize=40:fontcolor=white:fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf:x=(w-tw)/2:y=(h-th)/2:box=1:[email protected]:text= two^Llines [out]"

<代码>^L显然是实际的Ctrl-L特性,而不是>L

我简单地增加了指挥中的新线,并妥善处理。

ffmpeg -i input.avi -vf "[in]drawtext=fontsize=20:text= hello
world :x=(w)/2:y=(h)/2:fontcolor=white[out]" -y out.mp4

No Ctrl+L, Ctrl+K hacks are needed!

页: 1 我在敲响了钟。

You can do it editing script file or even in bash command line.

我已设法从指挥线开展工作,具体指明了文件记录仪参数,并将我的文本列入档案。

。 更多帮助。 利用刺.在窗户上修建N-35057-g2c44a,但重要的是,你最近版本的校正。

仅将案文分为一段长度的行文(20个特性,你可根据您的需要确定),然后通过<条码>ffeg。

import subprocess , os

ffmpeg = "C:\ffmpeg_10_6_11.exe"
inVid = "C:\test_in.avi"
outVid = "C:\test_out.avi"
length = 20
txt = "onLine1 onLine2 onLine3"
inpTxt = split_txt_into_multi_lines(txt,length)

if os.path.exists( outVid ):
  os.remove( outVid )
  proc = subprocess.Popen(ffmpeg + " -i " + inVid + f    -vf drawtext=fontfile=/Windows/Fonts/arial.ttf:text={inpTxt}:fontcolor=white:fontsize=20 -y     + outVid , shell=True, 
  stderr=subprocess.PIPE)
  proc.wait()
  print proc.stderr.read()
  os.startfile( outVid )


#################################################################
def split_txt_into_multi_lines(input_str: str, line_length: int):
    words = input_str.split(" ")
    line_count = 0
    split_input = ""
    for word in words:
        line_count += 1
        line_count += len(word)
        if line_count > line_length:
            split_input += "
"
            line_count = len(word) + 1
            split_input += word
            split_input += " "
        else:
            split_input += word
            split_input += " "
    
    return split_input
        


TEXT=$(printf "$1") 

书写

附上你的案文,作为你的书面论点,包括新的行文性质





相关问题
Encode an Array of Images into a movie file? (iPhone)

My app takes time-lapse photos, and also records audio to go with it. The problem is, I have absolutely no idea how to go about turning it into a .mov/.mpeg file (I am new to this type of iPhone ...

How to use FFmpeg

I m trying to extract frames from a video and I ve picked ffmpeg ( tell me if you know something better ) for this task. I ve downloaded its source and don t know how to use it ?? how can I compile it?...

stitching videos together using ffmpeg on the command line

Does anybody know how to stitch two (or more) videos together using ffmpeg (or another cli)? This is assuming that all the videos are in the same format and the video format being used allows for ...

Using FFmpeg or wrapper to get mp3 from mp4 in C#

I m trying to extract an mp3 from a flash compatible mp4 file and have so far found FFMpeg and a bunch of different wrappers that all claim to be able to do the job. Ideally, I d like to not have to ...

Convert a video to MP4 (H.264/AAC) with ffmpeg

If I don t make a mistake, Safari currently need MP4 (H.264/AAC) video encoded for the HTML5 <video> element. So I tried to convert a video to this format with ffmpeg. However when I enter the ...

calculating filesize of a response?

im tryingto code a script to do dynamic transcoding of video and audio (likely just audio for now) and streaming to mobile devices, currently im using the script posted elsewhere on here (How do you ...

C# and FFmpeg preferably without shell commands?

I d like to be able to use FFmpeg to convert a video file from within my C# program. I know I can just call a shell command, but is there a better way? The issue with invoking a command via the ...

convert movie file to bitmap files with DirectShow

I want to convert movie files like AVI, MOV etc. to Bitmap-Files, like JPEG, JPEG2000, TIFF etc. Is it possible to realize that with DirectX / DirectShow? Is AVCodec from ffmpeg the much more better ...

热门标签