0

PC のイーサネット ソケットに接続されたライブ カメラからビデオをキャプチャする必要があります。まず、システム内のファイルからビデオをキャプチャするために Phonon を使用しました。それは正常に動作します。次に、ビデオを読み取るためのソケットを作成しました。ここで、バッファリングされたデータを取得して、フォノン ビデオのソースとして設定する方法がわかりません。誰かがこれで私を助けることができれば、私は感謝します.

ビデオを読み取るコードは次のとおりです。

void PlayVideo::rollOn()
   {
   media = new Phonon::MediaObject(movieLabel);
   media->setCurrentSource(Phonon::MediaSource(QString("/home/saman/4.7/phonon_test/sample.mp4")));
   videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, movieLabel);
   videoPlayer->setFixedSize(QSize(400, 300));
   videoPlayer->show();
   connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));
   videoPlayer->play(media->currentSource());
   }

これがコードにソケットを追加した方法です。

  void PlayVideo::rollOn()
   {
   udpSocketin = new QUdpSocket(this);
   udpSocketin->bind(localPort);
   connect(udpSocketin, SIGNAL(readyRead()),this, SLOT(readDatagrams()));
   QDataStream out(&datagramout, QIODevice::WriteOnly);
   out.setVersion (QDataStream::Qt_4_7);
   timer2 = new QTimer(this);
   connect(timer2, SIGNAL(timeout()), this, SLOT(playbuff()));
   media = new Phonon::MediaObject(movieLabel);
   media->setCurrentSource(Phonon::MediaSource(QString("/home/saman/4.7/phonon_test/sample.mp4")));

   //media->setCurrentSource (Phonon::MediaSource());
   videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, movieLabel);     
   videoPlayer->setFixedSize(QSize(400, 300));     
   videoPlayer->show();     
   connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));     
   videoPlayer->play(media->currentSource());
   }    
   void PlayVideo::readDatagrams()
   {
   if(udpSocketin->hasPendingDatagrams ())
   {
   datagramin.resize (udpSocketin->pendingDatagramSize ());
   qint64 receiveBytes = udpSocketin->readDatagram (datagramin.data (), datagramin.size ));
   if(receivedBytes <= 0)
   {
   qDebug("receivedBytes <= 0");
   }    

} }

4

1 に答える 1

1

QBufferのサブクラスである にデータを入れることができますQIODevice。次に、 を受け入れるメディア ソース コンストラクターがありますQIODevice

于 2012-08-14T07:41:55.403 に答える