我想使用ffmpeg将图像用作绘画文本视频的背景 [英] I want to use image as a background of a drawtext video using ffmpeg

查看:56
本文介绍了我想使用ffmpeg将图像用作绘画文本视频的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我可以使用ffmpeg创建视频,并使用drawtext过滤器在黑色背景上绘制文本.正确的.我想将图像用作绘画文字滤镜的背景.即我想使用图像作为视频的背景,而不是使用背景色或视频背景.请有人指导我完成此操作,这是我的代码`

Currently i am able to create video with ffmpeg using the drawtext filters to draw text on a black background Now Remain one thing that seems difficult to me, I thought it would be easy until i come to discover i don't got it right. I want to use an image as background for the drawtext filters. I.e I want to use image as background of the video instead of using the background color or video background. Please someone should take me through on this this is my code `

echo shell_exec('ffmpeg -f lavfi -i color=color=black -vf drawtext="textfile=text.txt:expansion=normal:fontfile=FreeSerif.otf: y=h-line_h-20:x=-100*t: fontcolor=white: fontsize=50" -t '.$words_count.' textover09.mp4 -report'); `

ffmpeg started on 2018-01-07 at 22:53:03
Report written to "ffmpeg-20180107-225303.log"
Command line:
ffmpeg -loop 1 -i elena.jpg -vf "drawtext=textfile=text.txt:expansion=normal:fontfile=FreeSerif.otf: y=h-line_h-20:x=-100*t: fontcolor=white: fontsize=50" -t 46.2 textover09.mp4 -report
ffmpeg version git-2017-12-28-be4dfbf Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-18)
  configuration: --prefix=/usr/local/ffmpeg --extra-cflags=-I/usr/local/ffmpeg/include --extra-ldflags=-L/usr/local/ffmpeg/lib --bindir=/usr/local/bin --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264 --enable-libtheora --enable-filter=drawtext --enable-libfreetype
  libavutil      56.  7.100 / 56.  7.100
  libavcodec     58.  9.100 / 58.  9.100
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  8.100 /  7.  8.100
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
Splitting the commandline.
Reading option '-loop' ... matched as AVOption 'loop' with argument '1'.
Reading option '-i' ... matched as input url with argument 'elena.jpg'.
Reading option '-vf' ... matched as option 'vf' (set video filters) with argument 'drawtext=textfile=text.txt:expansion=normal:fontfile=FreeSerif.otf: y=h-line_h-20:x=-100*t: fontcolor=white: fontsize=50'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '46.2'.
Reading option 'textover09.mp4' ... matched as output url.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url elena.jpg.
Successfully parsed a group of options.
Opening an input file: elena.jpg.
[NULL @ 0x2c1fe80] Opening 'elena.jpg' for reading
[file @ 0x2c207c0] Setting default whitelist 'file,crypto'
[image2 @ 0x2c1fe80] Format image2 probed with size=2048 and score=50
[image2 @ 0x2c1fe80] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[image2 @ 0x2c1fe80] Opening 'elena.jpg' for reading
[AVIOContext @ 0x2c21f80] Statistics: 3871771 bytes read, 0 seeks
[mjpeg @ 0x2c21940] marker=d8 avail_size_in_buf=3871769
[mjpeg @ 0x2c21940] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x2c21940] marker=e0 avail_size_in_buf=3871767
[mjpeg @ 0x2c21940] marker parser used 16 bytes (128 bits)
[mjpeg @ 0x2c21940] marker=e2 avail_size_in_buf=3871749
[mjpeg @ 0x2c21940] marker parser used 3160 bytes (25280 bits)
[mjpeg @ 0x2c21940] marker=db avail_size_in_buf=3868587
[mjpeg @ 0x2c21940] index=0
[mjpeg @ 0x2c21940] qscale[0]: 2
[mjpeg @ 0x2c21940] index=1
[mjpeg @ 0x2c21940] qscale[1]: 2
[mjpeg @ 0x2c21940] marker parser used 132 bytes (1056 bits)
[mjpeg @ 0x2c21940] marker=c0 avail_size_in_buf=3868453
[mjpeg @ 0x2c21940] Changing bps from 0 to 8
[mjpeg @ 0x2c21940] sof0: picture: 5616x3744
[mjpeg @ 0x2c21940] component 0 2:2 id: 0 quant:0
[mjpeg @ 0x2c21940] component 1 1:1 id: 1 quant:1
[mjpeg @ 0x2c21940] component 2 1:1 id: 2 quant:1
[mjpeg @ 0x2c21940] pix fmt id 22111100
[mjpeg @ 0x2c21940] marker parser used 17 bytes (136 bits)
[mjpeg @ 0x2c21940] marker=c4 avail_size_in_buf=3868434
[mjpeg @ 0x2c21940] marker parser used 0 bytes (0 bits)
[mjpeg @ 0x2c21940] escaping removed 6222 bytes
[mjpeg @ 0x2c21940] marker=da avail_size_in_buf=3868014
[mjpeg @ 0x2c21940] marker parser used 3861792 bytes (30894336 bits)
[mjpeg @ 0x2c21940] marker=d9 avail_size_in_buf=0
[mjpeg @ 0x2c22540] marker parser used 132 bytes (1056 bits)
[mjpeg @ 0x2c22540] marker=c0 avail_size_in_buf=3868453
[mjpeg @ 0x2c22540] sof0: picture: 5616x3744
[mjpeg @ 0x2c22540] component 0 2:2 id: 0 quant:0
[mjpeg @ 0x2c22540] component 1 1:1 id: 1 quant:1
[libx264 @ 0x2c24c40] i16 v,h,dc,p: 40% 53%  4%  3%
[libx264 @ 0x2c24c40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 10% 27%  7%  9%  8%  8%  9% 11%
[libx264 @ 0x2c24c40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 12% 11%  6%  9% 11%  7%  9%  6%
[libx264 @ 0x2c24c40] i8c dc,h,v,p: 53% 17% 21%  8%
[libx264 @ 0x2c24c40] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x2c24c40] ref P L0: 56.3%  9.9% 21.1% 12.8%
[libx264 @ 0x2c24c40] ref B L0: 74.5% 22.4%  3.1%
[libx264 @ 0x2c24c40] ref B L1: 98.3%  1.7%
[libx264 @ 0x2c24c40] kb/s:4673.55
[AVIOContext @ 0x2c28ac0] Statistics: 32768 bytes read, 0 seeks

推荐答案

使用

ffmpeg -loop 1 -i image -vf scale=-2:1080,drawtext="textfile=text.txt:expansion=normal:fontfile=FreeSerif.otf: y=h-line_h-20:x=-100*t: fontcolor=white: fontsize=50" -pix_fmt yuv420p -t '.$words_count.' -movflags +faststart textover09.mp4

这篇关于我想使用ffmpeg将图像用作绘画文本视频的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆