return float_pts;
}
-static int init_output_stream(OutputStream *ost, char *error, int error_len);
+static int init_output_stream(OutputStream *ost, AVFrame *frame,
+ char *error, int error_len);
-static int init_output_stream_wrapper(OutputStream *ost, unsigned int fatal)
+static int init_output_stream_wrapper(OutputStream *ost, AVFrame *frame,
+ unsigned int fatal)
{
int ret = AVERROR_BUG;
char error[1024] = {0};
if (ost->initialized)
return 0;
- ret = init_output_stream(ost, error, sizeof(error));
+ ret = init_output_stream(ost, frame, error, sizeof(error));
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n",
ost->file_index, ost->index, error);
InputStream *ist = NULL;
AVFilterContext *filter = ost->filter->filter;
- init_output_stream_wrapper(ost, 1);
+ init_output_stream_wrapper(ost, next_picture, 1);
sync_ipts = adjust_frame_pts_to_encoder_tb(of, ost, next_picture);
if (ost->source_index >= 0)
* the encoder earlier than receiving the first AVFrame.
*/
if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_AUDIO)
- init_output_stream_wrapper(ost, 1);
+ init_output_stream_wrapper(ost, NULL, 1);
if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) {
return AVERROR(ENOMEM);
finish_output_stream(ost);
}
- init_output_stream_wrapper(ost, 1);
+ init_output_stream_wrapper(ost, NULL, 1);
}
if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO)
enc_ctx->time_base = default_time_base;
}
-static int init_output_stream_encode(OutputStream *ost)
+static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
{
InputStream *ist = get_input_stream(ost);
AVCodecContext *enc_ctx = ost->enc_ctx;
enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample,
av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
+ if (frame) {
+ enc_ctx->color_range = frame->color_range;
+ enc_ctx->color_primaries = frame->color_primaries;
+ enc_ctx->color_trc = frame->color_trc;
+ enc_ctx->colorspace = frame->colorspace;
+ enc_ctx->chroma_sample_location = frame->chroma_location;
+ }
+
enc_ctx->framerate = ost->frame_rate;
ost->st->avg_frame_rate = ost->frame_rate;
return 0;
}
-static int init_output_stream(OutputStream *ost, char *error, int error_len)
+static int init_output_stream(OutputStream *ost, AVFrame *frame,
+ char *error, int error_len)
{
int ret = 0;
AVCodecContext *dec = NULL;
InputStream *ist;
- ret = init_output_stream_encode(ost);
+ ret = init_output_stream_encode(ost, frame);
if (ret < 0)
return ret;
output_streams[i]->enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO))
continue;
- ret = init_output_stream_wrapper(output_streams[i], 0);
+ ret = init_output_stream_wrapper(output_streams[i], NULL, 0);
if (ret < 0)
goto dump_format;
}
* early encoder initialization.
*/
if (av_buffersink_get_type(ost->filter->filter) == AVMEDIA_TYPE_AUDIO)
- init_output_stream_wrapper(ost, 1);
+ init_output_stream_wrapper(ost, NULL, 1);
if ((ret = transcode_from_filter(ost->filter->graph, &ist)) < 0)
return ret;