obs-ffmpeg: Add proc handler for manual file splitting
This commit is contained in:
parent
cb8bc3413a
commit
ae3c9b3628
@ -79,6 +79,17 @@ static void ffmpeg_mux_destroy(void *data)
|
|||||||
bfree(stream);
|
bfree(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void split_file_proc(void *data, calldata_t *cd)
|
||||||
|
{
|
||||||
|
struct ffmpeg_muxer *stream = data;
|
||||||
|
|
||||||
|
calldata_set_bool(cd, "split_file_enabled", stream->split_file);
|
||||||
|
if (!stream->split_file)
|
||||||
|
return;
|
||||||
|
|
||||||
|
os_atomic_set_bool(&stream->manual_split, true);
|
||||||
|
}
|
||||||
|
|
||||||
static void *ffmpeg_mux_create(obs_data_t *settings, obs_output_t *output)
|
static void *ffmpeg_mux_create(obs_data_t *settings, obs_output_t *output)
|
||||||
{
|
{
|
||||||
struct ffmpeg_muxer *stream = bzalloc(sizeof(*stream));
|
struct ffmpeg_muxer *stream = bzalloc(sizeof(*stream));
|
||||||
@ -90,6 +101,10 @@ static void *ffmpeg_mux_create(obs_data_t *settings, obs_output_t *output)
|
|||||||
signal_handler_t *sh = obs_output_get_signal_handler(output);
|
signal_handler_t *sh = obs_output_get_signal_handler(output);
|
||||||
signal_handler_add(sh, "void file_changed(string next_file)");
|
signal_handler_add(sh, "void file_changed(string next_file)");
|
||||||
|
|
||||||
|
proc_handler_t *ph = obs_output_get_proc_handler(output);
|
||||||
|
proc_handler_add(ph, "void split_file(out bool split_file_enabled)",
|
||||||
|
split_file_proc, stream);
|
||||||
|
|
||||||
UNUSED_PARAMETER(settings);
|
UNUSED_PARAMETER(settings);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
@ -687,6 +702,9 @@ static inline bool should_split(struct ffmpeg_muxer *stream,
|
|||||||
if (!packet->keyframe)
|
if (!packet->keyframe)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (os_atomic_load_bool(&stream->manual_split))
|
||||||
|
return true;
|
||||||
|
|
||||||
/* reached maximum file size */
|
/* reached maximum file size */
|
||||||
if (stream->max_size > 0 &&
|
if (stream->max_size > 0 &&
|
||||||
stream->cur_size + (int64_t)packet->size >= stream->max_size)
|
stream->cur_size + (int64_t)packet->size >= stream->max_size)
|
||||||
@ -834,6 +852,7 @@ static void ffmpeg_mux_data(void *data, struct encoder_packet *packet)
|
|||||||
}
|
}
|
||||||
da_free(stream->mux_packets);
|
da_free(stream->mux_packets);
|
||||||
stream->split_file_ready = false;
|
stream->split_file_ready = false;
|
||||||
|
os_atomic_set_bool(&stream->manual_split, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream->split_file && stream->reset_timestamps)
|
if (stream->split_file && stream->reset_timestamps)
|
||||||
|
@ -43,6 +43,7 @@ struct ffmpeg_muxer {
|
|||||||
int64_t video_pts_offset;
|
int64_t video_pts_offset;
|
||||||
int64_t audio_dts_offsets[MAX_AUDIO_MIXES];
|
int64_t audio_dts_offsets[MAX_AUDIO_MIXES];
|
||||||
bool split_file_ready;
|
bool split_file_ready;
|
||||||
|
volatile bool manual_split;
|
||||||
|
|
||||||
/* these are accessed both by replay buffer and by HLS */
|
/* these are accessed both by replay buffer and by HLS */
|
||||||
pthread_t mux_thread;
|
pthread_t mux_thread;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user