-
Hey, I was wondering how should I set the codec for a FFmpegFrameRecorder to get hardware accelerated encoding with va-api on Linux: recorder = new FFmpegFrameRecorder("rtp://127.0.0.1:1234", videoGrabber.getImageWidth(),
videoGrabber.getImageHeight(), audioGrabber.getAudioChannels());
recorder.setFormat("rtp_mpegts");
recorder.setOption("hwaccel", "vaapi");
recorder.setOption("hwaccel_device", "/dev/dri/renderD128");
recorder.setOption("hwaccel_output_format", "vaapi");
recorder.setOption("vf", "scale_vaapi=format=nv12"); // ???
//recorder.setVideoCodec(avcodec.AV_CODEC_ID_H265);
recorder.setVideoCodecName("hevc_vaapi");
recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC);
recorder.setSampleRate(audioGrabber.getSampleRate());
recorder.setVideoBitrate(1 * 1000 * 1000);
recorder.setAudioBitrate(48 * 1000);
recorder.setFrameRate(30); Now, I couldn't find any codec id definitions in javacv with vaapi (Maybe I'm just missing it.) so I went with setting the codec name. However, I am not sure if this is the correct way to do this. Anyhow, the error I am facing right now is: However despite trying multiple different pixel formats with For the record here is the same thing in cli working: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
It looks like the only pixel format that hevc_vaapi supports is AV_PIX_FMT_VAAPI: |
Beta Was this translation helpful? Give feedback.
It looks like the only pixel format that hevc_vaapi supports is AV_PIX_FMT_VAAPI:
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/vaapi_encode_h265.c#L1463
So try to call setPixelFormat(AV_PIX_FMT_VAAPI) and see what that gives.