bytedeco/javacv

GetTimestamp always return 0 when I set video codec name to h264_cuvid

Open

#1,035 opened on Jul 18, 2018

View on GitHub
 (1 comment) (0 reactions) (1 assignee)Java (1,583 forks)batch import
bughelp wanted

Repository metrics

Stars
 (6,985 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

I'm using JavaCV 1.4.2

I want to decode video with HWAcceleration. However, I notice that getTimestamp always return 0 when I set video codec name to h264_cuvid.

    public static void main(String[] args) {
        try {
            FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("input.mp4");
            grabber.setVideoCodecName("h264_cuvid");
            grabber.start();

            while (grabber.grabImage() != null) {
                System.out.println(grabber.getTimestamp());
            }
            
            grabber.stop();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

This program print only zero. But frame decoding works fine. When I set video codec something, for example h264 or h264_qsv , you can see increasing timestamp.

https://github.com/bytedeco/javacv/blob/af8214569daf4df683f131a53e96650d377ce6dd/src/main/java/org/bytedeco/javacv/FFmpegFrameGrabber.java#L1159-L1161

On debugging, I found pts value is always -9223372036854775808. I don't know FFmpeg's api, but it looks like bug on FFmpeg. Is this possible to fix in JavaCV?. Thank you.

Contributor guide