Must set keyframe and codec_type of zm_packet

This commit is contained in:
Isaac Connor 2021-01-27 12:50:17 -05:00
parent 1ca93c4211
commit 518270a9ac
1 changed files with 18 additions and 1 deletions

View File

@ -1081,7 +1081,13 @@ int RemoteCameraHttp::Capture(ZMPacket &packet) {
return -1; return -1;
} }
if ( !packet.image ) {
Debug(1, "Allocating image");
packet.image = new Image(width, height, colours, subpixelorder);
}
Image *image = packet.image; Image *image = packet.image;
packet.keyframe = 1;
packet.codec_type = AVMEDIA_TYPE_VIDEO;
switch ( format ) { switch ( format ) {
case JPEG : case JPEG :
@ -1122,12 +1128,23 @@ int RemoteCameraHttp::PostCapture() {
AVStream *RemoteCameraHttp::get_VideoStream() { AVStream *RemoteCameraHttp::get_VideoStream() {
if ( video_stream ) { if ( video_stream ) {
AVFormatContext *oc = avformat_alloc_context(); oc = avformat_alloc_context();
video_stream = avformat_new_stream(oc, nullptr); video_stream = avformat_new_stream(oc, nullptr);
if ( video_stream ) { if ( video_stream ) {
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
video_stream->codecpar->width = width;
video_stream->codecpar->height = height;
video_stream->codecpar->format = GetFFMPEGPixelFormat(colours,subpixelorder);
video_stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
video_stream->codecpar->codec_id = AV_CODEC_ID_NONE;
#else
video_stream->codec->width = width; video_stream->codec->width = width;
video_stream->codec->height = height; video_stream->codec->height = height;
video_stream->codec->pix_fmt = GetFFMPEGPixelFormat(colours,subpixelorder); video_stream->codec->pix_fmt = GetFFMPEGPixelFormat(colours,subpixelorder);
video_stream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
video_stream->codec->codec_id = AV_CODEC_ID_NONE;
#endif
mVideoStreamId = video_stream->index;
} }
} }
return video_stream; return video_stream;