Skip to content
QtWS25 Call for Papers
  • 0 Votes
    6 Posts
    8k Views
    D

    @Ajith_P_V , maybe, you need not RGB, but BGR model. I didn't work with graphics in qt, but in OpenCV all work was gone in BGR.

  • 0 Votes
    20 Posts
    7k Views
    SurajS

    Thank all for your replay,
    I solve my problem by using Phonon: :video player

    Steps:-

    i. Add Phonon::Video Player in ui file. I rename its programing name as "Video Player"
    ii. Add one button in that ui file and go to that button slot and adding following code in it:-
    // For getting system date and time for video name
    time_t now = time(0);
    struct tm tstruct;
    char buf[80];
    tstruct = *localtime(&now);

    strftime(buf, sizeof(buf), "%d_%m_%y_%H_%M", &tstruct); qDebug() << "Date and Time: "<<buf;

    // For getting static path where video will be stored
    QString a = "/home/Working_QT/BackupErrorWorking/DeviceTestVersion1/video/";
    a.append(buf);
    a.append(".avi");
    qDebug() << "a: "<<a;

    // For giving comlete command as it is accepted as a QString and converted into char(Because konsole command is accepted only char it shows error so we convert it)
    QString command = "ffmpeg -f video4linux2 -i /dev/video0 -vcodec mpeg4 -b 500k -r 25 -t 00:01:30 ";
    command.append(a);
    qDebug() << "Command: "<<command;
    char x[200];
    strcpy( x, command.toStdString().c_str());

    // Commaand to sysytem
    system(x);
    qDebug() << "Command given to system to capture video and name it according to that particular date and time: "<<x;

    // For playing video through Phonon VideoPlayer
    qDebug("Before video recording display");
    ui->VideoPlayer->play(Phonon::MediaSource(a));
    qDebug("After video recording display");

    iii. Included #include <time.h> // Required for giving video file name according to date and time
    and #include <qdebug.h>
    iv. Make changes in .pro file

    QT += phonon