obs-ffmpeg: Fix m3u8 recording in AMF

This commit is contained in:
shinji3
2022-09-29 15:47:26 -07:00
committed by Jim
parent 6fb83abaeb
commit 9d7a6e7e8c
2 changed files with 36 additions and 7 deletions
+31 -7
View File
@@ -375,18 +375,33 @@ inline static void ts_offset_update(struct ffmpeg_muxer *stream,
stream->found_audio[packet->track_idx] = true;
}
static bool ffmpeg_mux_start(void *data)
static inline void update_encoder_settings(struct ffmpeg_muxer *stream,
const char *path)
{
struct ffmpeg_muxer *stream = data;
obs_data_t *settings;
const char *path;
obs_encoder_t *vencoder = obs_output_get_video_encoder(stream->output);
const char *ext = strrchr(path, '.');
/* if using m3u8, repeat headers */
if (ext && strcmp(ext, ".m3u8") == 0) {
obs_data_t *settings = obs_encoder_get_settings(vencoder);
obs_data_set_bool(settings, "repeat_headers", true);
obs_encoder_update(vencoder, settings);
obs_data_release(settings);
}
}
static inline bool ffmpeg_mux_start_internal(struct ffmpeg_muxer *stream,
obs_data_t *settings)
{
const char *path = obs_data_get_string(settings, "path");
update_encoder_settings(stream, path);
if (!obs_output_can_begin_data_capture(stream->output, 0))
return false;
if (!obs_output_initialize_encoders(stream->output, 0))
return false;
settings = obs_output_get_settings(stream->output);
if (stream->is_network) {
obs_service_t *service;
service = obs_output_get_service(stream->output);
@@ -395,7 +410,6 @@ static bool ffmpeg_mux_start(void *data)
path = obs_service_get_url(service);
stream->split_file = false;
} else {
path = obs_data_get_string(settings, "path");
stream->max_time =
obs_data_get_int(settings, "max_time_sec") * 1000000LL;
@@ -427,7 +441,6 @@ static bool ffmpeg_mux_start(void *data)
}
start_pipe(stream, path);
obs_data_release(settings);
if (!stream->pipe) {
obs_output_set_last_error(
@@ -446,6 +459,17 @@ static bool ffmpeg_mux_start(void *data)
return true;
}
static bool ffmpeg_mux_start(void *data)
{
struct ffmpeg_muxer *stream = data;
obs_data_t *settings = obs_output_get_settings(stream->output);
bool success = ffmpeg_mux_start_internal(stream, settings);
obs_data_release(settings);
return success;
}
int deactivate(struct ffmpeg_muxer *stream, int code)
{
int ret = -1;
+5
View File
@@ -1158,6 +1158,11 @@ static bool amf_avc_init(void *data, obs_data_t *settings)
: 250;
set_avc_property(enc, IDR_PERIOD, gop_size);
bool repeat_headers = obs_data_get_bool(settings, "repeat_headers");
if (repeat_headers)
set_avc_property(enc, HEADER_INSERTION_SPACING, gop_size);
set_avc_property(enc, DE_BLOCKING_FILTER, true);
const char *ffmpeg_opts = obs_data_get_string(settings, "ffmpeg_opts");