@@ -203,25 +203,29 @@ ftl_status_t attempt_ftl_connection(struct ffmpeg_output *output, struct ffmpeg_
203
203
static bool new_stream (struct ffmpeg_data * data , AVStream * * stream ,
204
204
AVCodec * * codec , enum AVCodecID id , int audio )
205
205
{
206
- if (audio == 1 ) {
207
- * codec = avcodec_find_encoder (AV_CODEC_ID_OPUS );
208
- * stream = avformat_new_stream (data -> output_audio , * codec );
209
- } else {
210
- * codec = avcodec_find_encoder (AV_CODEC_ID_VP8 );
211
- * stream = avformat_new_stream (data -> output_video , * codec );
206
+ * stream = NULL ;
207
+
208
+ if ((* codec = avcodec_find_encoder (id )) != NULL ) {
209
+ if (audio ) {
210
+ * stream = avformat_new_stream (data -> output_audio , * codec );
211
+ }
212
+ else {
213
+ * stream = avformat_new_stream (data -> output_video , * codec );
214
+ }
212
215
}
216
+
213
217
if (!* stream ) {
214
218
blog (LOG_WARNING , "Couldn't create stream for encoder '%s'" ,
215
219
avcodec_get_name (id ));
216
220
return false;
217
221
}
218
-
219
-
222
+
220
223
if (audio == 1 ) {
221
224
(* stream )-> id = 0 ;
222
225
} else {
223
226
(* stream )-> id = 1 ;
224
227
}
228
+
225
229
return true;
226
230
}
227
231
@@ -253,7 +257,7 @@ static bool open_video_codec(struct ffmpeg_data *data)
253
257
AVCodecContext * context = data -> video -> codec ;
254
258
255
259
/* Hardcode in quality=realtime */
256
- // char **opts = strlist_split(data->config.video_settings, ' ', false);
260
+ // char **opts = strlist_split(data->config.video_settings, ' ', false);
257
261
char * * opts = strlist_split ("quality=realtime" , ' ' , false);
258
262
int ret ;
259
263
@@ -337,7 +341,7 @@ static bool create_video_stream(struct ffmpeg_data *data)
337
341
* source codec
338
342
*/
339
343
340
- closest_format = AV_PIX_FMT_YUV420P ;
344
+ closest_format = AV_PIX_FMT_YUV420P ;
341
345
context = data -> video -> codec ;
342
346
context -> bit_rate = data -> config .video_bitrate * 1000 ;
343
347
context -> width = data -> config .scale_width ;
@@ -374,7 +378,8 @@ static bool create_video_stream(struct ffmpeg_data *data)
374
378
static bool open_audio_codec (struct ffmpeg_data * data )
375
379
{
376
380
AVCodecContext * context = data -> audio -> codec ;
377
- char * * opts = strlist_split (data -> config .video_settings , ' ' , false);
381
+ //char **opts = strlist_split(data->config.video_settings, ' ', false);
382
+ char * * opts = strlist_split (data -> config .audio_settings , ' ' , false);
378
383
int ret ;
379
384
380
385
if (opts ) {
@@ -567,11 +572,13 @@ static void close_video(struct ffmpeg_data *data)
567
572
avcodec_close (data -> video -> codec );
568
573
avpicture_free (& data -> dst_picture );
569
574
570
- // This format for some reason derefs video frame
571
- // too many times
572
- if (data -> vcodec -> id == AV_CODEC_ID_A64_MULTI ||
573
- data -> vcodec -> id == AV_CODEC_ID_A64_MULTI5 )
574
- return ;
575
+ if (data -> vcodec ) {
576
+ // This format for some reason derefs video frame
577
+ // too many times
578
+ if (data -> vcodec -> id == AV_CODEC_ID_A64_MULTI ||
579
+ data -> vcodec -> id == AV_CODEC_ID_A64_MULTI5 )
580
+ return ;
581
+ }
575
582
576
583
av_frame_free (& data -> vframe );
577
584
}
@@ -670,6 +677,15 @@ static bool ffmpeg_data_init(struct ffmpeg_data *data,
670
677
return false;
671
678
672
679
av_register_all ();
680
+
681
+ int version = avcodec_version ();
682
+
683
+ blog (LOG_WARNING , "FFMPEG Version: %d.%d.%d\n" , (0xFF0000 & version ) >> 16 , (0xFF00 & version ) >> 8 , version & 0xFF );
684
+
685
+ char * s = avcodec_configuration ();
686
+
687
+ blog (LOG_WARNING , "AV Codec configurations %s\n" , s );
688
+
673
689
avformat_network_init ();
674
690
675
691
is_rtmp = (astrcmpi_n (config -> url , "rtmp://" , 7 ) == 0 );
@@ -696,9 +712,9 @@ static bool ffmpeg_data_init(struct ffmpeg_data *data,
696
712
avformat_alloc_output_context2 (& data -> output_video , output_format2 ,
697
713
NULL , NULL );
698
714
699
- if (data -> config .format_name ) {
715
+ // if (data->config.format_name) {
700
716
set_encoder_ids (data );
701
- }
717
+ // }
702
718
703
719
if (!data -> output_audio ) {
704
720
blog (LOG_WARNING , "Couldn't create audio avformat context" );
@@ -1117,6 +1133,7 @@ static int try_connect(struct ffmpeg_output *output)
1117
1133
const char * full_streamkey ;
1118
1134
1119
1135
settings = obs_output_get_settings (output -> output );
1136
+ memset (& config , 0 , sizeof (config ));
1120
1137
config .ingest_location = get_string_or_null (settings , "url" );
1121
1138
config .format_name = get_string_or_null (settings , "format_name" );
1122
1139
config .format_mime_type = get_string_or_null (settings ,
0 commit comments