0

Hello,

My goal is to extract frames from an .ts video file using Jcodec.

Actually, I am only able to extract the first frame, and then for left frames I receive warnings. (note that after the warning message my pic variable is null)

Here is the warning message: ([WARN] . (:0): Skipping frame as no SPS/PPS have been seen so far...) the message is sent for each other frame.

I have seen this thread Java BufferedImages from .ts File but sill have the same problem.

Here is what I tried:

                for(DemuxerTrack demuxerTrack : JCodecUtil.createM2TSDemuxer(videoFile, TrackType.VIDEO).v1.getTracks()) {
                
                Packet packet;
                
                while((packet = demuxerTrack.nextFrame()) != null) {
                                            
                    Picture tmp = Picture.create(1920, 1088, ColorSpace.YUV420);
                    
                    VideoDecoder vd = JCodecUtil.createVideoDecoder(JCodecUtil.detectDecoder(packet.data.duplicate()), packet.data.duplicate());
                    Picture pic = vd.decodeFrame(packet.data, tmp.getData());
                    
                    if(pic != null) {
                        BufferedImage buf = AWTUtil.toBufferedImage(pic);
                        ImageIO.write(buf, "jpg", new File(sequencesFolder, sequencesFolder.listFiles().length + ".jpg"));
                    }
                }
            }

Thanks You.

4

0 回答 0