0

I tried to play video from a buffer and append the buffer while playing so the two or more videos play after each other without any delay as they are one video, I tried to use the QMediaPlaylist and append the list during run time, it worked but there is a Noticeable delay between the videos I use this code in the play button

void MainWindow::on_pushButton_2_clicked()
{
    player = new QMediaPlayer(this);

    QFile file("D:/video/first.mp4");
    file.open(QIODevice::ReadOnly);
    arr = new QByteArray();
    arr->append(file.readAll());
    file.close();
    buffer = new QBuffer(arr);
    buffer->open(QIODevice::ReadWrite);

    player->setVideoOutput(ui->widget);

    player->setMedia(QMediaContent(), buffer);
    player->play();
}

and a button to append the second video during the runtime which is here I make many different trys

void MainWindow::on_pushButton_3_clicked()
{
    QFile file("D:/video/second.mp4");
    file.open(QIODevice::ReadOnly);
    QByteArray temp = file.readAll();
    //arr->append(temp, temp.size()); //first to append the QByteArray did not work
    buffer->write(temp.data(), temp.size()); //second write to the buffer but not work
    file.close();
    qDebug() << "Appeneded";
}

first one which is append the array but it did not work, same as when i set the buffer to ReadWrite flage and its the same result, the result is that only the first video is played and it stop, so can you help me to make this work? what i did wrong in my code let the second video not run smoothly after first video and this is the result i want.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
user7179690
  • 1,051
  • 3
  • 17
  • 40
  • Did you get a fix for this? I was getting my source from a livestream and writting to that buffer does not work. It only plays the first frame that is added. – Update Nov 03 '19 at 09:19
  • Hello sorry i did not open stackoverflow for long time, Actually sad i did not find any solution, but i used a stream library that time. – user7179690 Nov 30 '19 at 02:10
  • 1
    I also had to give up. I ended up using libvlc. I think it's a bug or its a concept not yet designed – Update Dec 01 '19 at 04:02

0 Answers0