Re-use h264 keyframes
This commit is contained in:
parent
1352df220b
commit
3a8574de66
@ -55,6 +55,7 @@ bool http_h264_needs_buffer();
|
|||||||
void http_h264_capture(buffer_t *buf);
|
void http_h264_capture(buffer_t *buf);
|
||||||
void http_h264_lowres_capture(buffer_t *buf);
|
void http_h264_lowres_capture(buffer_t *buf);
|
||||||
void http_h264_video(http_worker_t *worker, FILE *stream);
|
void http_h264_video(http_worker_t *worker, FILE *stream);
|
||||||
|
bool h264_is_key_frame(buffer_t *buf);
|
||||||
void http_mkv_video(http_worker_t *worker, FILE *stream);
|
void http_mkv_video(http_worker_t *worker, FILE *stream);
|
||||||
void http_mp4_video(http_worker_t *worker, FILE *stream);
|
void http_mp4_video(http_worker_t *worker, FILE *stream);
|
||||||
void http_mov_video(http_worker_t *worker, FILE *stream);
|
void http_mov_video(http_worker_t *worker, FILE *stream);
|
||||||
|
@ -255,14 +255,8 @@ static int http_ffmpeg_copy_packets(http_ffmpeg_status_t *status)
|
|||||||
|
|
||||||
static int http_ffmpeg_video_buf_part(buffer_lock_t *buf_lock, buffer_t *buf, int frame, http_ffmpeg_status_t *status)
|
static int http_ffmpeg_video_buf_part(buffer_lock_t *buf_lock, buffer_t *buf, int frame, http_ffmpeg_status_t *status)
|
||||||
{
|
{
|
||||||
unsigned char *data = buf->start;
|
if (!status->had_key_frame) {
|
||||||
|
status->had_key_frame = h264_is_key_frame(buf);
|
||||||
if (buf->v4l2_buffer.flags & V4L2_BUF_FLAG_KEYFRAME) {
|
|
||||||
status->had_key_frame = true;
|
|
||||||
E_LOG_DEBUG(buf, "Got key frame (from V4L2)!");
|
|
||||||
} else if (buf->used >= 5 && (data[4] & 0x1F) == 0x07) {
|
|
||||||
status->had_key_frame = true;
|
|
||||||
E_LOG_DEBUG(buf, "Got key frame (from buffer)!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!status->had_key_frame) {
|
if (!status->had_key_frame) {
|
||||||
|
@ -47,16 +47,28 @@ typedef struct {
|
|||||||
bool requested_key_frame;
|
bool requested_key_frame;
|
||||||
} http_video_status_t;
|
} http_video_status_t;
|
||||||
|
|
||||||
|
bool h264_is_key_frame(buffer_t *buf)
|
||||||
|
{
|
||||||
|
unsigned char *data = buf->start;
|
||||||
|
device_t *camera = buf->buf_list->device;
|
||||||
|
|
||||||
|
if (buf->v4l2_buffer.flags & V4L2_BUF_FLAG_KEYFRAME) {
|
||||||
|
E_LOG_DEBUG(buf, "Got key frame (from V4L2)!");
|
||||||
|
return true;
|
||||||
|
} else if (buf->used >= 5 && (data[4] & 0x1F) == 0x07) {
|
||||||
|
E_LOG_DEBUG(buf, "Got key frame (from buffer)!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int http_video_buf_part(buffer_lock_t *buf_lock, buffer_t *buf, int frame, http_video_status_t *status)
|
int http_video_buf_part(buffer_lock_t *buf_lock, buffer_t *buf, int frame, http_video_status_t *status)
|
||||||
{
|
{
|
||||||
unsigned char *data = buf->start;
|
unsigned char *data = buf->start;
|
||||||
|
|
||||||
if (buf->v4l2_buffer.flags & V4L2_BUF_FLAG_KEYFRAME) {
|
if (!status->had_key_frame) {
|
||||||
status->had_key_frame = true;
|
status->had_key_frame = h264_is_key_frame(buf);
|
||||||
E_LOG_DEBUG(buf, "Got key frame (from V4L2)!");
|
|
||||||
} else if (buf->used >= 5 && (data[4] & 0x1F) == 0x07) {
|
|
||||||
status->had_key_frame = true;
|
|
||||||
E_LOG_DEBUG(buf, "Got key frame (from buffer)!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!status->had_key_frame) {
|
if (!status->had_key_frame) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user