artclarke / humble-video

Humble Video: Demuxing, Decoding, Filtering, Encoding and Muxing of 100's of video and audio formats and Codecs from the JVM
GNU Affero General Public License v3.0
551 stars 113 forks source link

Cannot encode frames #154

Open detsikas opened 11 months ago

detsikas commented 11 months ago

Hi,

thank you for making this great framework available. I have been using the demuxer easily without any issues, but recently I had trouble using the muxer. I basically copy the reasoning of the RecordAndEncodeVideo demo. My flow is complicated but when it comes to muxing frames the "screen" BufferedImage in the code below is fine (I store it in a file and view it to verify it). In addition to that the picture.isComplete() is true. However the packet is never complete. Size and position are always 0 and -1 and the muxer write call is never executed. If I force execution I get an exception for writing an incomplete packet.

        if (converter == null)
            converter = MediaPictureConverterFactory.createConverter(screen, picture);
        converter.toPicture(picture, screen, i);

        do {
            encoder.encode(packet, picture);
            if (packet.isComplete())
                muxer.write(packet, false);
        } while (packet.isComplete());

I am not sure how to tackle this. I would most grateful if you could lend a hand.

It is also not clear to me the reasoning of the do-while loop.

Best regards, Nikos