我尝试使用phantomjs创建视频流,从网址创建屏幕截图,然后它会将帧传输到ffmpeg,以便他可以使用它将视频流式传输到rtmp网址。 这是我到目前为止所尝试的:
phantomjs runner.js | ffmpeg -f image2pipe -vcodec png -c:a copy -c:v libx264 -f flv rtmp://localhost/mystream
这是脚本:
var page = require('webpage').create();
page.viewportSize = { width: 640, height: 480 };
page.open('http://www.goodboydigital.com/pixijs/examples/12-2/', function () {
setInterval(function() {
page.render('/dev/stdout', { format: "png" });
}, 25);
});
这是输出:
ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 7.3.0 (clang-703.0.29)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Output #0, flv, to 'rtmp://localhost/mystream':
Output file #0 does not contain any stream
答案 0 :(得分:7)
您现在的命令未指定任何输入,因此请使用
from uitest import Ui_MainWindow
from PyQt5.QtWidgets import QMainWindow
class window(QMainWindow):
def __init__(self, parent=None):
super(window, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
myFont = QtGui.QFont()
myFont.setBold(True)
self.ui.Action1.setFont(myFont)
if __name__ == "__main__":
app = QApplication([])
gui = window()
gui.show()
app.exec_()
没有音频输入,因此设置音频编解码器毫无意义。如果您的输出需要音频流,请使用
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(120, 330, 151, 71))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(360, 330, 151, 71))
self.pushButton_2.setObjectName("pushButton_2")
self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit.setGeometry(QtCore.QRect(160, 80, 321, 181))
self.textEdit.setObjectName("textEdit")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.toolBar1 = QtWidgets.QToolBar(MainWindow)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.toolBar1.sizePolicy().hasHeightForWidth())
self.toolBar1.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(14)
self.toolBar1.setFont(font)
self.toolBar1.setObjectName("toolBar1")
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar1)
self.toolBar = QtWidgets.QToolBar(MainWindow)
font = QtGui.QFont()
font.setPointSize(12)
self.toolBar.setFont(font)
self.toolBar.setObjectName("toolBar")
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
MainWindow.insertToolBarBreak(self.toolBar)
self.toolBar_2 = QtWidgets.QToolBar(MainWindow)
font = QtGui.QFont()
font.setPointSize(10)
self.toolBar_2.setFont(font)
self.toolBar_2.setObjectName("toolBar_2")
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar_2)
MainWindow.insertToolBarBreak(self.toolBar_2)
self.Action1 = QtWidgets.QAction(MainWindow)
self.Action1.setObjectName("Action1")
self.Action2 = QtWidgets.QAction(MainWindow)
self.Action2.setObjectName("Action2")
self.Action3 = QtWidgets.QAction(MainWindow)
self.Action3.setObjectName("Action3")
self.Action4 = QtWidgets.QAction(MainWindow)
self.Action4.setObjectName("Action4")
self.Action5 = QtWidgets.QAction(MainWindow)
self.Action5.setObjectName("Action5")
self.Action6 = QtWidgets.QAction(MainWindow)
self.Action6.setObjectName("Action6")
self.Action7 = QtWidgets.QAction(MainWindow)
self.Action7.setObjectName("Action7")
self.Action8 = QtWidgets.QAction(MainWindow)
self.Action8.setObjectName("Action8")
self.Action9 = QtWidgets.QAction(MainWindow)
self.Action9.setObjectName("Action9")
self.toolBar1.addAction(self.Action1)
self.toolBar1.addSeparator()
self.toolBar1.addAction(self.Action2)
self.toolBar1.addSeparator()
self.toolBar1.addAction(self.Action3)
self.toolBar.addAction(self.Action4)
self.toolBar.addSeparator()
self.toolBar.addAction(self.Action5)
self.toolBar.addSeparator()
self.toolBar.addAction(self.Action6)
self.toolBar_2.addAction(self.Action7)
self.toolBar_2.addSeparator()
self.toolBar_2.addAction(self.Action8)
self.toolBar_2.addSeparator()
self.toolBar_2.addAction(self.Action9)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "PushButton"))
self.pushButton_2.setText(_translate("MainWindow", "PushButton"))
self.toolBar1.setWindowTitle(_translate("MainWindow", "toolBar"))
self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar"))
self.toolBar_2.setWindowTitle(_translate("MainWindow", "toolBar_2"))
self.Action1.setText(_translate("MainWindow", "Action1"))
self.Action2.setText(_translate("MainWindow", "Action2"))
self.Action3.setText(_translate("MainWindow", "Action3"))
self.Action4.setText(_translate("MainWindow", "Action4"))
self.Action5.setText(_translate("MainWindow", "Action5"))
self.Action6.setText(_translate("MainWindow", "Action6"))
self.Action7.setText(_translate("MainWindow", "Action7"))
self.Action8.setText(_translate("MainWindow", "Action8"))
self.Action9.setText(_translate("MainWindow", "Action9"))