如何使用ffmpeg将文字添加到avi视频? [英] How to use ffmpeg to add a text to avi video?
问题描述
我正在使用Ubuntu 12.04上的ffmpeg,在视频的底部放一个简单的文字。我试过这个在几个地方建议的:
I am trying to put a simple text on the bottom of video using ffmpeg on Ubuntu 12.04 . I tried this which is suggested in several places:
ffmpeg -i input.avi -vf drawtext="fontfile=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf:text='Text to write':fontsize=20:fontcolor=black:x=100:y=100" output.avi
但是每次都会收到此错误:
But I get this error each time:
ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
built on Jun 12 2012 16:37:58 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, avi, from 'input.avi':
Duration: 04:09:09.66, start: 0.000000, bitrate: 480 kb/s
Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 320x240 [PAR 1:1 DAR 4:3], 45 tbr, 45 tbn, 45 tbc
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 64 kb/s
[buffer @ 0x860d5a0] w:320 h:240 pixfmt:yuv420p
Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
[ac3 @ 0x8607a00] invalid bit rate
Output #0, avi, to 'output.avi':
Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 45 tbc
Stream #0.1: Audio: ac3, 48000 Hz, stereo, flt, 200 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.1 - maybe incorrect parameters such as bit_rate, rate, width or height
欣赏您的帮助。
推荐答案
文档显示您可以使用其他参数与 x
或 y
如输入视频的高度和宽度以及文字宽度和高度。将文本放在底部的一个方法是 y = main_h-text_h
。如果你想在底部有一点填充,你可以使用 y = main_h-(text_h * 2)
要水平使用 x =(main_w / 2-text_w / 2)
。
The documentation shows that you can use other parameters with x
or y
such as input video height and width and text width and height. To place the text on the bottom one method is y=main_h-text_h
. If you want a little padding on the bottom you can use y=main_h-(text_h*2)
To center it horizontally use x=(main_w/2-text_w/2)
.
这篇关于如何使用ffmpeg将文字添加到avi视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!