Skip to content

How to burn a Qt type to video? #560

@Megubit

Description

@Megubit

Hello,

I'm using the library for a simple project in Qt and I'm wondering it's possible to burn a QML type (for example a Rectangle) to the video.

Using this simple example:

// Create a reader for a video
openshot::FFmpegReader r("MyAwesomeVideo.webm");
r.Open(); // Open the target reader
// Create a writer (which will create a WebM video)
openshot::FFmpegWriter w("/home/jonathan/NewVideo.webm");
// Set options
// Sample Rate: 44100, Channels: 2, Bitrate: 128000
w.SetAudioOptions(true, "libvorbis", 44100, 2, openshot::ChannelLayout::LAYOUT_STEREO, 128000);
// FPS: 24, Size: 720x480, Pixel Ratio: 1/1, Bitrate: 300000
w.SetVideoOptions(true, "libvpx", openshot::Fraction(24,1), 720, 480, openshot::Fraction(1,1), false, false, 300000);
// Open the writer
w.Open();
// Write all frames from the reader
w.WriteFrame(&r, 1, r.info.video_length);
// Close the reader & writer
w.Close();
r.Close();

If I understand right, I can use the WriteFrame() function to write a openshot::Frame and add a QImage to it.
In theory that should work, but I'm stuck at the part of creating a QImage of a Rectangle.

Maybe I have the wrong way of thoughts about how to accomplish this, or if it's even possible to do it this way, but I decided to ask if anyone has some kind of hints of how to do it.

I'm sure I need a custom component so it can be displayed to the user and referenced to the writer, I just can't think of one that would accomplish this, maybe a subclass of QQuickPaintedItem would suffice or a QPixmap Class?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Readers: generativeIssues with readers that generate their own content (text / html frames, etc.)enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions