Skip to content

Commit

Permalink
obs-ffmpeg: Set audio stream title for FFmpeg record output
Browse files Browse the repository at this point in the history
  • Loading branch information
tuduweb authored and RytoEX committed Jan 27, 2024
1 parent b287231 commit b8155cd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions plugins/obs-ffmpeg/obs-ffmpeg-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ static bool create_audio_stream(struct ffmpeg_data *data, int idx)
data->audio_infos[idx].stream = stream;
data->audio_infos[idx].ctx = context;

if (data->config.audio_stream_names[idx] &&
*data->config.audio_stream_names[idx] != '\0')
av_dict_set(&stream->metadata, "title",
data->config.audio_stream_names[idx], 0);

return open_audio_codec(data, idx);
}

Expand Down Expand Up @@ -1169,6 +1174,27 @@ static bool try_connect(struct ffmpeg_output *output)
if (!config.scale_height)
config.scale_height = config.height;

obs_data_array_t *audioNames =
obs_data_get_array(settings, "audio_names");
if (audioNames) {
for (size_t i = 0, idx = 0; i < MAX_AUDIO_MIXES; i++) {
if ((config.audio_tracks & (1 << i)) == 0)
continue;

obs_data_t *item_data =
obs_data_array_item(audioNames, i);
config.audio_stream_names[idx] =
obs_data_get_string(item_data, "name");
obs_data_release(item_data);

idx++;
}
obs_data_array_release(audioNames);
} else {
for (int idx = 0; idx < config.audio_mix_count; idx++)
config.audio_stream_names[idx] = NULL;
}

success = ffmpeg_data_init(&output->ff_data, &config);
obs_data_release(settings);

Expand Down
1 change: 1 addition & 0 deletions plugins/obs-ffmpeg/obs-ffmpeg-output.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct ffmpeg_cfg {
const char *audio_settings;
int audio_mix_count;
int audio_tracks;
const char *audio_stream_names[MAX_AUDIO_MIXES];
enum AVPixelFormat format;
enum AVColorRange color_range;
enum AVColorPrimaries color_primaries;
Expand Down

0 comments on commit b8155cd

Please sign in to comment.