我正在使用VapourSynth作为libass包装,用于应用程序的视频预览生成特殊的.ass文件,返回的视频帧应该输出到pyqt4的QImage对象。
我读过VapourSynth关于get_read_ptr的文档,他们说它是frame.format所说的图像的指针,在我的例子中,frame.format是RGB24。我的问题是:如何访问原始帧数据并将其存储到QImage对象以供显示?
这是我的代码,我不擅长ctype :/
import vapoursynth as vs
# needed for stdout
import sys
from PyQt4 import QtGui
import ctypes
# create a core instance
core = vs.Core()
core.std.LoadPlugin(path=r'C:\Shared\VapourSynth\plugins\ffms2.dll')
# open a video file; ret is now a clip object
ret = core.ffms2.Source(source='Fisica.o.Chimica.S01E01.iTALiAN.WWW.ITALIA-LINK.COM .avi')
# output the clip to stdout with y4m headers (useful for x264 encoding/mplayer playback)
# ret.output(sys.stdout, y4m=True)
print(str(ret.width)+"x"+str(ret.height)+"@"+str(ret.fps_den)+"fps")
print(ret.format)
frame = ret.get_frame(10000)
data = frame.get_read_ptr(0)
print(data)
d = ctypes.pointer(data)
print(d)
print(d.contents)
print(frame.props)目前返回:
640x480@1fps
Format Descriptor
Id: 3000010
Name: YUV420P8
Color Family: YUV
Sample Type: Integral
Bits Per Sample: 8
Bytes Per Sample: 1
Planes: 3
Subsampling W: 1
Subsampling H: 1
c_void_p(100597856)
<__main__.LP_c_void_p object at 0x02FD0170>
c_void_p(100597856)
<vapoursynth.VideoProps object at 0x02D78050>
发布于 2013-01-17 03:12:36
您可以通过在VapourSynth线程中发布Doom9来得到答案。作者很有帮助。
另外,现在有一个用于VS的本地libass插件。奇怪的是,它被命名为“水蒸气”。http://code.google.com/p/vapoursynth/source/browse/trunk/src/filters/assvapour/assvapour.c?spec=svn384&r=384
Doom9线程:http://forum.doom9.org/showthread.php?t=165771
https://stackoverflow.com/questions/14256418
复制相似问题