Qt接收mjpgstreamer视频流解析Word格式.docx
- 文档编号:21407233
- 上传时间:2023-01-30
- 格式:DOCX
- 页数:22
- 大小:24.45KB
Qt接收mjpgstreamer视频流解析Word格式.docx
《Qt接收mjpgstreamer视频流解析Word格式.docx》由会员分享,可在线阅读,更多相关《Qt接收mjpgstreamer视频流解析Word格式.docx(22页珍藏版)》请在冰豆网上搜索。
存w在QQ:
1206110987)"
);
SetWindow();
InitStatusBar();
//初始化状态栏
Mkdirfile();
showTime=newQTimer;
showTime->
setInterval(100);
//毫秒级
QObject:
connect(showTime,SIGNAL(timeout()),this,SLOT(flushPic()));
manager=newQNetworkAccessManager(this);
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(slot_replyFinished(QNetworkReply*)));
connect(ui->
Openaction,SIGNAL(triggered()),this,SLOT(OpenFileNameSlot()));
Quitaction,SIGNAL(triggered()),qApp,SLOT(quit()));
AboutQtaction,SIGNAL(triggered()),qApp,SLOT(aboutQt()));
//关于Qt
Softwareaction,SIGNAL(triggered()),this,SLOT(slot_software()));
//关于软件
LANaction,SIGNAL(triggered()),this,SLOT(slot_LAN()));
WANaction,SIGNAL(triggered()),this,SLOT(slot_WAN()));
button_movieIsClicked=false;
//初始化ButtonMovie按钮的状态
IsLan=true;
//初始化内网模式
//音频
audio=newPhonon:
MediaObject(this);
//媒体对象
audio->
setTickInterval
(1);
audioOutput=newPhonon:
AudioOutput(Phonon:
MusicCategory,this);
//音频输出
Phonon:
createPath(audio,audioOutput);
//连接媒体对象与音频输出
volumeSlider=newPhonon:
VolumeSlider(audioOutput,this);
//音量滑动条
volumeSlider->
move(650,520);
resize(200,20);
setStyleSheet("
background-color:
rgb(255,255,255,100)"
setFixedWidth(100);
//固定音量条大小
seekSlider=newPhonon:
SeekSlider(audio,this);
//进度滑动条
seekSlider->
move(250,525);
resize(350,20);
creatActions();
connect(audio,SIGNAL(tick(qint64)),this,SLOT(UpdateTime(qint64)));
//时间更新
connect(audio,SIGNAL(aboutToFinish()),this,SLOT(AboutToFinish()));
OpenWAVaction,SIGNAL(triggered()),this,SLOT(slot_OpenMusic()));
musicInformationMediaObject=newPhonon:
//音乐信息对象
metaInformationAudioOutput=newPhonon:
MusicCategory,this);
createPath(musicInformationMediaObject,metaInformationAudioOutput);
tableWidget,SIGNAL(customContextMenuRequested(constQPoint&
)),this,SLOT(ShowContextMenu(constQPoint&
)));
connect(audio,SIGNAL(stateChanged(Phonon:
State,Phonon:
State)),this,SLOT(StateChanged(Phonon:
State)));
connect(musicInformationMediaObject,SIGNAL(stateChanged(Phonon:
State,Phonon:
State)),this,SLOT(MetaStateChanged(Phonon:
connect(audio,SIGNAL(currentSourceChanged(Phonon:
MediaSource)),this,SLOT(SourceChanged(Phonon:
MediaSource)));
tableWidget,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(tableClicked(int)));
}
~MainWindow()
deleteui;
QFile:
remove("
mjpg-streamer/temp1.jpg"
voidMainWindow:
slot_replyFinished(QNetworkReply*reply)
if(button_movieIsClicked==true)
{
QPixmappix;
QByteArraydata=reply->
readAll();
pix.loadFromData(data,"
JPG"
pix.save("
mjpg-streamer/tmp1.jpg"
"
100);
//文件名图像格式压缩率图片质量
if(!
(img->
load("
)))
stop();
QMessageBox:
information(this,tr("
打开图像失败"
),tr("
打开图像失败!
"
));
button_movieIsClicked=false;
return;
}
*scaledimg=img->
scaled(640,480,Qt:
KeepAspectRatio);
PicLabel->
setPixmap(QPixmap:
fromImage(*scaledimg));
else
QPixmappixmap("
/new/prefix1/背景.jpg"
setPixmap(pixmap);
flushPic()
request.setUrl(QUrl(PU));
manager->
get(request);
SetWindow()
resize(861,572);
setGeometry(230,0,640,480);
//ui->
setText("
视频通道一"
ButtonMovie->
setGeometry(10,160,51,23);
setFrameShape(QFrame:
Box);
//边框
border:
2pxsolidblack"
//#999999"
//红色边框风格ff0000
QLabel{border-image:
url(:
/new/prefix1/wifi.jpg);
}"
TaiLongLabel->
/new/prefix1/TaiLong.png);
视频"
InitStatusBar()//初始化状态栏
QStatusBar*bar=ui->
statusBar;
//获取状态栏
first_statusLabel=newQLabel;
//新建标签
first_statusLabel->
setMinimumSize(100,10);
//设置标签最小尺寸
//first_statusLabel->
setFrameShape(QFrame:
WinPanel);
//设置标签形状
setFrameShadow(QFrame:
Sunken);
//设置标签阴影
second_statusLabel=newQLabel;
second_statusLabel->
setMinimumSize(200,10);
//second_statusLabel->
bar->
addWidget(first_statusLabel);
addWidget(second_statusLabel);
QDateTimetime=QDateTime:
currentDateTime();
//获取系统现在的时间
QStringstr=time.toString("
yyyy-MM-ddhh:
mm:
ssddd"
//设置显示格式
setText(tr("
就绪"
//初始化内容
setText(str);
//在标签上显示时间
Mkdirfile()
/*QDir*temp=newQDir;
boolexist=temp->
exists("
F:
//temp"
//if(exist)
//QMessageBox:
创建文件夹"
文件夹已经存在!
exist)
temp->
mkdir("
}*/
QDir("
mjpg-streamer"
).exists())//相对路径
QDirdir;
dir.mkpath("
photos"
).exists())
Musics"
slot_software()//关于软件dialog窗口
SoftWare*aboutsoftware=newSoftWare;
aboutsoftware->
show();
slot_WAN()
IsLan=false;
模式切换"
远程视频模式!
slot_LAN()
内网视频模式!
on_ButtonMovie_clicked()
if(IsLan==true)//判断是否为内网视频
{Address=ui->
AddressLineEdit->
text();
Port=ui->
PortlineEdit->
PU="
http:
//"
+Address+"
+Port+"
/?
action=snapshot"
;
RemoteAddress=ui->
RemoteLineEdit->
RemotePort=ui->
RemotePortlineEdit->
+RemoteAddress+"
if(button_movieIsClicked==false)
button_movieIsClicked=true;
结束"
start();
on_ScreenshotButton_clicked()//截图
QStringstr_time,photo;
QDateTimetime=QDateTime:
str_time=time.toString("
yyyy-MM-ddhh-mm-ss"
photo="
photos/"
+str_time+"
.jpg"
QPixmap:
fromImage(*img).save(photo,"
100);
//和load相似
/*QMessageBox:
information(this,
tr("
save"
),
PICTUREhasbeensavedtofolder'
photo!
'
*/
OpenFileNameSlot()
QStringFileName=QFileDialog:
getOpenFileName(this,tr("
打开图片"
),"
temp"
Images(*.png*.xpm*.jpg)"
if(FileName.isEmpty())
information(this,"
错误信息"
请选择图片"
QImagesrc(FileName);
fromImage(src));
//以下为音频输出函数
creatActions()
Next->
setEnabled(false);
Last->
PlayPause->
Stop->
setIcon(QIcon("
/new/prefix1/Pause.png"
tableWidget->
setContextMenuPolicy(Qt:
CustomContextMenu);
setRowCount(0);
//一定要初始化行和列作为一个标度
setColumnCount
(2);
setColumnWidth(0,2*ui->
width()/3);
setColumnWidth(1,ui->
setHorizontalScrollBarPolicy(Qt:
ScrollBarAlwaysOn);
QStringListlist;
list<
<
音乐标题"
)<
tr("
时长"
setHorizontalHeaderLabels(list);
setSelectionMode(QAbstractItemView:
SingleSelection);
//设置只能选择单行
setSelectionBehavior(QAbstractItemView:
SelectRows);
setShowGrid(false);
//设置不显示网格
slot_OpenMusic()
QStringListLists=QFileDialog:
getOpenFileNames(this,tr("
打开音乐文件"
//,tr("
*.wmv"
//使用QFileDialog的getOpenFileNames方法获取若干个音乐文件
intindex=sourceList.size();
QStringfile;
foreach(file,Lists)//使用Qt中的foreach遍历每个选中的文件,将其添加到播放列表中。
MediaSourcesource(file);
sourceList.append(source);
sourceList.isEmpty())
//如果媒体源列表不为空,则将新加入的第一个媒体源作为当前媒体源
musicInformationMediaObject->
setCurrentSource(sourceList.at(index));
setEnabled(true);
on_Stop_clicked()
on_PlayPause_clicked()
if(sourceList.isEmpty())
//QMessageBox:
information(this,tr("
nomusicfiles"
),tr("
nofilestoplay"
return;
//audio->
setQueue(sourceList);
//列表循环
if(audio->
state()==Phonon:
PlayingState)
pause();
setToolTip("
暂停"
play();
播放"
on_Last_clicked()
intindex=sourceList.indexOf(audio->
currentSource());
setCurrentSource(sourceList.at(index-1));
on_Next_clicked()
intindex=sourceL
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Qt 接收 mjpgstreamer 视频 解析