obs-ffmpeg: Add codec-tag support to ffmpeg-mux

By default, ffmpeg-mux is guessing at the codec format of submitted data.
This change allows encoders to suggest a particular codec.
This commit is contained in:
Developer-Ecosystem-Engineering
2022-11-02 22:44:20 +01:00
committed by Patrick Heyer
parent e461ec4be1
commit 641ec29a00
2 changed files with 15 additions and 2 deletions
@@ -102,6 +102,7 @@ struct main_params {
int max_luminance;
char *acodec;
char *muxer_settings;
int codec_tag;
};
struct audio_params {
@@ -375,6 +376,9 @@ static bool init_params(int *argc, char ***argv, struct main_params *params,
return false;
if (!get_opt_int(argc, argv, &params->fps_den, "video fps den"))
return false;
if (!get_opt_int(argc, argv, &params->codec_tag,
"video codec tag"))
params->codec_tag = 0;
}
if (params->tracks) {
@@ -445,6 +449,7 @@ static void create_video_stream(struct ffmpeg_mux *ffm)
context = avcodec_alloc_context3(NULL);
context->codec_type = codec->type;
context->codec_id = codec->id;
context->codec_tag = ffm->params.codec_tag;
context->bit_rate = (int64_t)ffm->params.vbitrate * 1000;
context->width = ffm->params.width;
context->height = ffm->params.height;
+10 -2
View File
@@ -142,6 +142,14 @@ static void add_video_encoder_params(struct ffmpeg_muxer *stream,
video_t *video = obs_get_video();
const struct video_output_info *info = video_output_get_info(video);
int codec_tag = (int)obs_data_get_int(settings, "codec_type");
#if __BYTE_ORDER == __LITTLE_ENDIAN
codec_tag = ((codec_tag >> 24) & 0x000000FF) |
((codec_tag << 8) & 0x00FF0000) |
((codec_tag >> 8) & 0x0000FF00) |
((codec_tag << 24) & 0xFF000000);
#endif
obs_data_release(settings);
enum AVColorPrimaries pri = AVCOL_PRI_UNSPECIFIED;
@@ -184,12 +192,12 @@ static void add_video_encoder_params(struct ffmpeg_muxer *stream,
? (int)obs_get_video_hdr_nominal_peak_level()
: ((trc == AVCOL_TRC_ARIB_STD_B67) ? 1000 : 0);
dstr_catf(cmd, "%s %d %d %d %d %d %d %d %d %d %d ",
dstr_catf(cmd, "%s %d %d %d %d %d %d %d %d %d %d %d ",
obs_encoder_get_codec(vencoder), bitrate,
obs_output_get_width(stream->output),
obs_output_get_height(stream->output), (int)pri, (int)trc,
(int)spc, (int)range, max_luminance, (int)info->fps_num,
(int)info->fps_den);
(int)info->fps_den, (int)codec_tag);
}
static void add_audio_encoder_params(struct dstr *cmd, obs_encoder_t *aencoder)