Python libass или VapourSynth?
Я использую VapourSynth в качестве оболочки libass для предварительного просмотра видео приложения, которое генерирует специальные файлы.ass, возвращенный видеокадр должен быть выведен в объект QImage pyqt4.
Я прочитал документацию VapourSynth о get_read_ptr, они говорят, что это указатель на изображение, закодированное как frame.format, в моем случае frame.format это RGB24. Мой вопрос: как я могу получить доступ к необработанным данным кадра и разделить их на объект QImage для отображения?
Вот мой код, я не очень хорош в ctypes:/
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>
1 ответ
Вы можете получить ответ, разместив сообщение в ветке VapourSynth на Doom9. Автор очень полезен.
Кроме того, теперь есть собственный плагин libass для VS. Как ни странно, называется Ассвапур. 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