浏览代码

obs-ffmpeg: Fix broken mpegts output

This recent commit [1] broke SRT & RIST streaming because
obs_output_video now returns a NULL pointer for encoded outputs.
This fixes it by retrieving the pointer from the encoder.

[1] https://github.com/obsproject/obs-studio/commit/fb57eff212fbe5e777cf559288bc70bf67d9c428

Co-authored-by: tt2468 <[email protected]>
Signed-off-by: pkv <[email protected]>
pkv 2 年之前
父节点
当前提交
78a33c7771
共有 1 个文件被更改,包括 18 次插入18 次删除
  1. 18 18
      plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c

+ 18 - 18
plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c

@@ -885,8 +885,23 @@ static bool set_config(struct ffmpeg_output *stream)
 	config.format_mime_type = "video/M2PT";
 	config.format_mime_type = "video/M2PT";
 
 
 	/* 2. video settings */
 	/* 2. video settings */
-	// 2.a) set video format from obs to FFmpeg
-	video_t *video = obs_output_video(stream->output);
+
+	// 2.a) set width & height
+	config.width = (int)obs_output_get_width(stream->output);
+	config.height = (int)obs_output_get_height(stream->output);
+	config.scale_width = config.width;
+	config.scale_height = config.height;
+
+	// 2.b) set video codec & ID from video encoder
+	obs_encoder_t *vencoder = obs_output_get_video_encoder(stream->output);
+	config.video_encoder = obs_encoder_get_codec(vencoder);
+	if (strcmp(config.video_encoder, "h264") == 0)
+		config.video_encoder_id = AV_CODEC_ID_H264;
+	else
+		config.video_encoder_id = AV_CODEC_ID_AV1;
+
+	// 2.c) set video format from OBS to FFmpeg
+	video_t *video = obs_encoder_video(vencoder);
 	config.format =
 	config.format =
 		obs_to_ffmpeg_video_format(video_output_get_format(video));
 		obs_to_ffmpeg_video_format(video_output_get_format(video));
 
 
@@ -896,7 +911,7 @@ static bool set_config(struct ffmpeg_output *stream)
 		return false;
 		return false;
 	}
 	}
 
 
-	// 2.b) set colorspace, color_range & transfer characteristic (from voi)
+	// 2.d) set colorspace, color_range & transfer characteristic (from voi)
 	const struct video_output_info *voi = video_output_get_info(video);
 	const struct video_output_info *voi = video_output_get_info(video);
 	config.color_range = voi->range == VIDEO_RANGE_FULL ? AVCOL_RANGE_JPEG
 	config.color_range = voi->range == VIDEO_RANGE_FULL ? AVCOL_RANGE_JPEG
 							    : AVCOL_RANGE_MPEG;
 							    : AVCOL_RANGE_MPEG;
@@ -929,21 +944,6 @@ static bool set_config(struct ffmpeg_output *stream)
 		config.color_trc = AVCOL_TRC_ARIB_STD_B67;
 		config.color_trc = AVCOL_TRC_ARIB_STD_B67;
 		config.colorspace = AVCOL_SPC_BT2020_NCL;
 		config.colorspace = AVCOL_SPC_BT2020_NCL;
 	}
 	}
-
-	// 2.c) set width & height
-	config.width = (int)obs_output_get_width(stream->output);
-	config.height = (int)obs_output_get_height(stream->output);
-	config.scale_width = config.width;
-	config.scale_height = config.height;
-
-	// 2.d) set video codec & id from video encoder
-	obs_encoder_t *vencoder = obs_output_get_video_encoder(stream->output);
-	config.video_encoder = obs_encoder_get_codec(vencoder);
-	if (strcmp(config.video_encoder, "h264") == 0)
-		config.video_encoder_id = AV_CODEC_ID_H264;
-	else
-		config.video_encoder_id = AV_CODEC_ID_AV1;
-
 	// 2.e)  set video bitrate & gop through video encoder settings
 	// 2.e)  set video bitrate & gop through video encoder settings
 	obs_data_t *settings = obs_encoder_get_settings(vencoder);
 	obs_data_t *settings = obs_encoder_get_settings(vencoder);
 	config.video_bitrate = (int)obs_data_get_int(settings, "bitrate");
 	config.video_bitrate = (int)obs_data_get_int(settings, "bitrate");