我有一个任务,添加运行的文本到视频流(或文件)接收。视频需要用Armbian在cubieboard上运行。我使用mpv进行了测试,使用了标志--hwdec=vdpau,视频运行起来比没有mpv时更流畅。为了添加连续的文本,我尝试使用lavfi drawtext过滤器,但是当我使用它时,mpv又回到了软件解码,并且看到了lag。下面是我使用的一个例子:
mpv --hwdec=vdpau Videos/VID* -vf lavfi=[drawtext=fontsize=40:fontcolor=yellow:x=w-50*t:y=h/2:textfile=livetext.txt:reload=1]该命令的输出为--msg-level=vd=v,它来自我的工作PC,在cubieboard上它还警告音频/视频不同步:
Playing: Videos/VID_20180129_120726.mp4
(+) Video --vid=1 (*) (h264 1080x1920 30.000fps)
(+) Audio --aid=1 --alang=eng (*) (aac 2ch 44100Hz)
[vd] Container reported FPS: 30.000000
[vd] Codec list:
[vd] h264 - H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
[vd] h264_crystalhd (h264) - CrystalHD H264 decoder
[vd] h264_cuvid (h264) - Nvidia CUVID H264 decoder
[vd] Opening video decoder h264
[vd] Probing 'vdpau'...
[vd] Trying hardware decoding.
[vd] Selected video codec: h264 (H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10)
Opening video filter: [lavfi graph=drawtext=fontsize=40:fontcolor=yellow:x=w-50*t:y=h/2:textfile=/opt/mpv-text/livetext.txt:reload=1]
[vd] Pixel formats supported by decoder: vdpau vaapi_vld yuv420p
[vd] Codec profile: High (0x64)
[vd] Requesting pixfmt 'vdpau' from decoder.
Using hardware decoding (vdpau).
[vd] Decoder format: 1080x1920 vdpau[yuv420p] bt.709/bt.709/bt.1886/limited CL=mpeg2/4/h264
[ffmpeg] Impossible to convert between the formats supported by the filter 'src' and the filter 'auto_scaler_0'
[lavfi] Can't configure libavfilter graph.
Video filter chain:
[in] 1080x1920 vdpau[yuv420p] bt.709/bt.709/bt.1886/limited SP=1.000000 CL=mpeg2/4/h264
[lavfi] "lavfi.00" 1080x1920 vdpau[yuv420p] bt.709/bt.709/bt.1886/limited SP=1.000000 CL=mpeg2/4/h264 <---
[out] ???
Falling back to software decoding.
[vd] Detected 8 logical cores.
[vd] Requesting 9 threads for decoding.
AO: [pulse] 44100Hz stereo 2ch float
[vd] Decoder format: 1080x1920 yuv420p bt.709/bt.709/bt.1886/limited CL=mpeg2/4/h264
VO: [opengl] 1080x1920 yuv420p
AV: 00:00:03 / 00:00:36 (9%) A-V: 0.000
[vd] Uninit video.经过长时间的搜索,我怀疑在这里使用mpv的硬件加速是可能的。如果是这样的话,也许你可以在其他工具上给出建议来实现这一点?我是这个领域的新手,也许有一种更有效的方法可以将文本添加到视频中。谢谢。
发布于 2018-01-31 15:05:12
我发现了一种可以移动文本的字幕格式(ASS),所以不需要视频过滤器。Tag \move(x1,y1,x2,y2)可以做到这一点,参考下面的标签:
http://docs.aegisub.org/3.2/ASS_Tags/
https://stackoverflow.com/questions/48502117
复制相似问题