sannies / mp4parser

A Java API to read, write and create MP4 files
Apache License 2.0
2.74k stars 563 forks source link

pic_order_cnt_type with value 2 cause NullPointerException #418

Open ashraf-revo opened 4 years ago

ashraf-revo commented 4 years ago

iam getting an NullPointerException when reading my h264 file using H264AnnexBTrack

public static void main(String[] args) throws Exception {
    String file = "video.h264";
    H264AnnexBTrack h264 = new H264AnnexBTrack(new FileInputStream(file));
    AtomicInteger atomicInteger = new AtomicInteger();
    h264.setSampleSink(new SampleSink() {
        @Override
        public void close() {

        }

        @Override
        public void acceptSample(StreamingSample streamingSample, StreamingTrack streamingTrack) {
            System.out.println(atomicInteger.incrementAndGet());
        }
    });

    h264.call();
}

this breakpoints show what is the problem

Screenshot from 2020-05-23 17-49-51 Screenshot from 2020-05-23 17-51-56

How ever i tried using another interface H264TrackImpl for reading the file and it works for me

public static void main(String[] args) throws IOException {
    String file = "video.h264";
    H264TrackImpl h264Track = new H264TrackImpl(new FileDataSourceImpl(file));
    System.out.println(h264Track.getSamples().size());
}