| 609 | } |
| 610 | |
| 611 | int of_stream_init(OutputFile *of, OutputStream *ost, |
| 612 | const AVCodecContext *enc_ctx) |
| 613 | { |
| 614 | Muxer *mux = mux_from_of(of); |
| 615 | MuxStream *ms = ms_from_ost(ost); |
| 616 | int ret; |
| 617 | |
| 618 | if (enc_ctx) { |
| 619 | // use upstream time base unless it has been overridden previously |
| 620 | if (ost->st->time_base.num <= 0 || ost->st->time_base.den <= 0) |
| 621 | ost->st->time_base = av_add_q(enc_ctx->time_base, (AVRational){0, 1}); |
| 622 | |
| 623 | ost->st->avg_frame_rate = enc_ctx->framerate; |
| 624 | ost->st->sample_aspect_ratio = enc_ctx->sample_aspect_ratio; |
| 625 | |
| 626 | ret = avcodec_parameters_from_context(ms->par_in, enc_ctx); |
| 627 | if (ret < 0) { |
| 628 | av_log(ost, AV_LOG_FATAL, |
| 629 | "Error initializing the output stream codec parameters.\n"); |
| 630 | return ret; |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | /* initialize bitstream filters for the output stream |
| 635 | * needs to be done here, because the codec id for streamcopy is not |
| 636 | * known until now */ |
| 637 | ret = bsf_init(ms); |
| 638 | if (ret < 0) |
| 639 | return ret; |
| 640 | |
| 641 | if (ms->stream_duration) { |
| 642 | ost->st->duration = av_rescale_q(ms->stream_duration, ms->stream_duration_tb, |
| 643 | ost->st->time_base); |
| 644 | } |
| 645 | |
| 646 | if (ms->sch_idx >= 0) |
| 647 | return sch_mux_stream_ready(mux->sch, of->index, ms->sch_idx); |
| 648 | |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | static int check_written(OutputFile *of) |
| 653 | { |
no test coverage detected