bytedeco/javacv

why FFmpegFrameRecorder.record() No data was retrieved?

Open

#2,182 opened on Feb 1, 2024

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Java (1,583 forks)batch import
help wantedquestion

Repository metrics

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

Description

javacv version is 1.5.9

private ByteArrayOutputStream stream;

...
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(stream, grabber.getImageWidth(), grabber.getImageHeight(),grabber.getAudioChannels());
recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
recorder.setAudioCodec(avcodec.AV_CODEC_ID_AAC);
// ... Omit other parameters
recorder.record(frame);
log.info("byte size:{}", stream.size());
...

When my RTSP stream exists in audio, the total interval between my first frame data and the second frame is about 10 seconds (the subsequent frame interval is normal), and the data of the second frame is larger than other frames, which causes my front end to not work properly. Play. Frame spacing is normal when audio is not present.

2024-02-01 16:14:00.112INF012740---[1706775240085]byte size:401
2024-02-01 16:14:00.139INF012740---[1706775240085]byte size:0
2024-02-01 16:14:00.149INF012740---[1706775240085]byte size:0
2024-02-01 16:14:00.159INF012740---[1706775240085]byte size:0
...
2024-02-01 16:14:09.854INF012740---[1706775240085]byte size:321000
2024-02-01 16:14:09.889INF012740---[1706775240085]byte size:542

The front -end Chrome browser's WebSocket message data interface image

This is the media information of the rtsp video stream seen on the VLC software image

Hope a solution can be given!

Contributor guide