bytedeco/javacv

png image stream synthesis webm video transparent channel lost

Aperta

#2150 aperta il 20 dic 2023

 (6 commenti) (0 reazioni) (0 assegnatari)Java (1583 fork)batch import
help wantedquestion

Metriche repository

Star
 (6985 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

I have a png pipeline stream, similar to the one below

PipeInputStream pis = new PipeInputStream()
grabber = new FFmpegFrameGrabber(pis, 0);
grabber.setImageWidth(1920);
grabber.setImageHeight(1080);
grabber.setFrameRate(25);
grabber.setImageMode(FrameGrabber.ImageMode.RAW);
grabber.setFormat("png_pipe");
//Why `PixelFormat` is bgra, because I turn Mat
grabber.setPixelFormat(avutil.AV_PIX_FMT_BGRA);
grabber.start();

FFmpegFrameRecorder

recorder = new FFmpegFrameRecorder("output.webm", 1920, 1080);
recorder.setAudioCodec(avcodec.AV_CODEC_ID_OPUS);
recorder.setVideoCodec(avcodec.AV_CODEC_ID_VP9);
recorder.setFormat("webm");
recorder.start();
Frame frame = null;
while((frame = grabber.grabImage()) != null) {
    recorder.record(frame)
}
recorder.close();
grabber.close();

Description: Images saved as local png files before being written to the pipeline have a transparent channel, but the transparent channel in the generated webm video is lost.webm video generated directly from the FFmpeg command line also has transparent channels

FFmpeg command:

ffmpeg -i %6d.png -c:v libvpx-vp9 -y output.webm

Guida contributor