Lines Matching refs:ost

1489 static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost)
1491 enum AVMediaType type = ost->st->codecpar->codec_type;
1495 MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st);
1497 ost->st->codecpar->codec_id = av_guess_codec(s->oformat, NULL, s->url,
1498 NULL, ost->st->codecpar->codec_type);
1499 ost->enc = avcodec_find_encoder(ost->st->codecpar->codec_id);
1500 if (!ost->enc) {
1504 ost->file_index, ost->index, s->oformat->name,
1505 avcodec_get_name(ost->st->codecpar->codec_id));
1509 ost->stream_copy = 1;
1511 ost->enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1);
1512 ost->st->codecpar->codec_id = ost->enc->id;
1514 ost->encoding_needed = !ost->stream_copy;
1517 ost->stream_copy = 1;
1518 ost->encoding_needed = 0;
1526 OutputStream *ost;
1542 ost = ALLOC_ARRAY_ELEM(output_streams, nb_output_streams);
1544 ost->file_index = nb_output_files - 1;
1545 ost->index = idx;
1546 ost->st = st;
1547 ost->forced_kf_ref_pts = AV_NOPTS_VALUE;
1550 ret = choose_encoder(o, oc, ost);
1553 "%d:%d\n", ost->file_index, ost->index);
1557 ost->enc_ctx = avcodec_alloc_context3(ost->enc);
1558 if (!ost->enc_ctx) {
1562 ost->enc_ctx->codec_type = type;
1564 ost->ref_par = avcodec_parameters_alloc();
1565 if (!ost->ref_par) {
1570 ost->filtered_frame = av_frame_alloc();
1571 if (!ost->filtered_frame)
1574 ost->pkt = av_packet_alloc();
1575 if (!ost->pkt)
1578 if (ost->enc) {
1582 ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc);
1585 ost->autoscale = 1;
1586 MATCH_PER_STREAM_OPT(autoscale, i, ost->autoscale, oc, st);
1587 if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
1600 av_dict_set(&ost->encoder_opts, buf, arg, AV_DICT_DONT_OVERWRITE);
1608 preset, ost->file_index, ost->index);
1612 ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL);
1617 ost->enc_ctx->flags |= AV_CODEC_FLAG_BITEXACT;
1638 ost->enc_timebase = q;
1641 ost->max_frames = INT64_MAX;
1642 MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
1651 ost->copy_prior_start = -1;
1652 MATCH_PER_STREAM_OPT(copy_prior_start, i, ost->copy_prior_start, oc ,st);
1656 ret = av_bsf_list_parse_str(bsfs, &ost->bsf_ctx);
1671 ost->st->codecpar->codec_tag =
1672 ost->enc_ctx->codec_tag = tag;
1677 ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE;
1678 ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale;
1681 MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st);
1682 ost->disposition = av_strdup(ost->disposition);
1684 ost->max_muxing_queue_size = 128;
1685 MATCH_PER_STREAM_OPT(max_muxing_queue_size, i, ost->max_muxing_queue_size, oc, st);
1687 ost->muxing_queue_data_size = 0;
1689 ost->muxing_queue_data_threshold = 50*1024*1024;
1690 MATCH_PER_STREAM_OPT(muxing_queue_data_threshold, i, ost->muxing_queue_data_threshold, oc, st);
1692 MATCH_PER_STREAM_OPT(bits_per_raw_sample, i, ost->bits_per_raw_sample,
1696 ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
1698 av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0);
1700 av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0);
1701 if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24)
1702 av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0);
1704 ost->source_index = source_index;
1706 ost->sync_ist = input_streams[source_index];
1710 ost->last_mux_dts = AV_NOPTS_VALUE;
1712 ost->muxing_queue = av_fifo_alloc2(8, sizeof(AVPacket*), 0);
1713 if (!ost->muxing_queue)
1717 ost->copy_initial_nonkeyframes, oc, st);
1719 return ost;
1766 OutputStream *ost)
1768 AVStream *st = ost->st;
1770 if (ost->filters_script && ost->filters) {
1776 if (ost->filters_script)
1777 return read_file(ost->filters_script);
1778 else if (ost->filters)
1779 return av_strdup(ost->filters);
1786 const OutputStream *ost, enum AVMediaType type)
1788 if (ost->filters_script || ost->filters) {
1792 ost->filters ? "Filtergraph" : "Filtergraph script",
1793 ost->filters ? ost->filters : ost->filters_script,
1794 av_get_media_type_string(type), ost->file_index, ost->index);
1802 OutputStream *ost;
1806 ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index);
1807 st = ost->st;
1808 video_enc = ost->enc_ctx;
1811 if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) {
1817 if (max_frame_rate && av_parse_video_rate(&ost->max_frame_rate, max_frame_rate) < 0) {
1839 ost->frame_aspect_ratio = q;
1842 MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st);
1843 MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st);
1845 if (!ost->stream_copy) {
1862 ost->keep_pix_fmt = 1;
1937 av_dict_set(&ost->encoder_opts, "flags", "+pass1", AV_DICT_APPEND);
1941 av_dict_set(&ost->encoder_opts, "flags", "+pass2", AV_DICT_APPEND);
1945 MATCH_PER_STREAM_OPT(passlogfiles, str, ost->logfile_prefix, oc, st);
1946 if (ost->logfile_prefix &&
1947 !(ost->logfile_prefix = av_strdup(ost->logfile_prefix)))
1955 ost->logfile_prefix ? ost->logfile_prefix :
1958 if (!strcmp(ost->enc->name, "libx264")) {
1959 av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
1979 ost->logfile = f;
1984 MATCH_PER_STREAM_OPT(forced_key_frames, str, ost->forced_keyframes, oc, st);
1985 if (ost->forced_keyframes)
1986 ost->forced_keyframes = av_strdup(ost->forced_keyframes);
1988 MATCH_PER_STREAM_OPT(force_fps, i, ost->force_fps, oc, st);
1990 ost->top_field_first = -1;
1991 MATCH_PER_STREAM_OPT(top_field_first, i, ost->top_field_first, oc, st);
1993 ost->vsync_method = video_sync_method;
1994 MATCH_PER_STREAM_OPT(fps_mode, str, ost->fps_mode, oc, st);
1995 if (ost->fps_mode)
1996 parse_and_set_vsync(ost->fps_mode, &ost->vsync_method, ost->file_index, ost->index, 0);
1998 if (ost->vsync_method == VSYNC_AUTO) {
2000 ost->vsync_method = VSYNC_VFR;
2002 ost->vsync_method = (oc->oformat->flags & AVFMT_VARIABLE_FPS) ?
2008 if (ost->source_index >= 0 && ost->vsync_method == VSYNC_CFR) {
2009 const InputStream *ist = input_streams[ost->source_index];
2013 ost->vsync_method = VSYNC_VSCFR;
2016 if (ost->vsync_method == VSYNC_CFR && copy_ts) {
2017 ost->vsync_method = VSYNC_VSCFR;
2020 ost->is_cfr = (ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR);
2022 ost->avfilter = get_ost_filters(o, oc, ost);
2023 if (!ost->avfilter)
2026 ost->last_frame = av_frame_alloc();
2027 if (!ost->last_frame)
2031 if (ost->stream_copy)
2032 check_streamcopy_filters(o, oc, ost, AVMEDIA_TYPE_VIDEO);
2034 return ost;
2041 OutputStream *ost;
2044 ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index);
2045 st = ost->st;
2047 audio_enc = ost->enc_ctx;
2050 MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st);
2051 MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st);
2053 if (!ost->stream_copy) {
2094 MATCH_PER_STREAM_OPT(apad, str, ost->apad, oc, st);
2095 ost->apad = av_strdup(ost->apad);
2097 ost->avfilter = get_ost_filters(o, oc, ost);
2098 if (!ost->avfilter)
2104 if ((map->ofile_idx == -1 || ost->file_index == map->ofile_idx) &&
2105 (map->ostream_idx == -1 || ost->st->index == map->ostream_idx)) {
2110 } else if (ost->source_index < 0) {
2112 ost->file_index, ost->st->index);
2115 ist = input_streams[ost->source_index];
2119 if (av_reallocp_array(&ost->audio_channels_map,
2120 ost->audio_channels_mapped + 1,
2121 sizeof(*ost->audio_channels_map)
2125 ost->audio_channels_map[ost->audio_channels_mapped++] = map->channel_idx;
2131 if (ost->stream_copy)
2132 check_streamcopy_filters(o, oc, ost, AVMEDIA_TYPE_AUDIO);
2134 return ost;
2139 OutputStream *ost;
2141 ost = new_output_stream(o, oc, AVMEDIA_TYPE_DATA, source_index);
2142 if (!ost->stream_copy) {
2147 return ost;
2152 OutputStream *ost;
2154 ost = new_output_stream(o, oc, AVMEDIA_TYPE_UNKNOWN, source_index);
2155 if (!ost->stream_copy) {
2160 return ost;
2165 OutputStream *ost = new_output_stream(o, oc, AVMEDIA_TYPE_ATTACHMENT, source_index);
2166 ost->stream_copy = 1;
2167 ost->finished = 1;
2168 return ost;
2174 OutputStream *ost;
2177 ost = new_output_stream(o, oc, AVMEDIA_TYPE_SUBTITLE, source_index);
2178 st = ost->st;
2179 subtitle_enc = ost->enc_ctx;
2183 if (!ost->stream_copy) {
2193 return ost;
2270 OutputStream *ost = output_streams[of->ost_index + i];
2272 nb_streams[ost->st->codecpar->codec_type]++;
2274 have_manual |= !!ost->disposition;
2276 if (ost->source_index >= 0) {
2277 ost->st->disposition = input_streams[ost->source_index]->st->disposition;
2279 if (ost->st->disposition & AV_DISPOSITION_DEFAULT)
2280 have_default[ost->st->codecpar->codec_type] = 1;
2287 OutputStream *ost = output_streams[of->ost_index + i];
2290 if (!ost->disposition)
2294 ret = av_opt_set(ost->st, "disposition", ost->disposition, 0);
2301 ret = av_opt_eval_flags(&class, o, ost->disposition, &ost->st->disposition);
2313 OutputStream *ost = output_streams[of->ost_index + i];
2314 enum AVMediaType type = ost->st->codecpar->codec_type;
2317 ost->st->disposition & AV_DISPOSITION_ATTACHED_PIC)
2320 ost->st->disposition |= AV_DISPOSITION_DEFAULT;
2331 OutputStream *ost;
2334 case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc, -1); break;
2335 case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc, -1); break;
2342 ost->filter = ofilter;
2344 ofilter->ost = ost;
2347 if (ost->stream_copy) {
2350 "cannot be used together.\n", ost->file_index, ost->index);
2354 if (ost->avfilter && (ost->filters || ost->filters_script)) {
2355 const char *opt = ost->filters ? "-vf/-af/-filter" : "-filter_script";
2360 ost->filters ? "Filtergraph" : "Filtergraph script",
2361 ost->filters ? ost->filters : ost->filters_script,
2362 opt, ost->file_index, ost->index, opt);
2381 static void set_channel_layout(OutputFilter *f, OutputStream *ost)
2385 if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
2387 err = av_channel_layout_copy(&f->ch_layout, &ost->enc_ctx->ch_layout);
2394 if (!ost->enc->ch_layouts) {
2397 av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
2402 for (i = 0; ost->enc->ch_layouts[i].nb_channels; i++) {
2403 if (ost->enc->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels)
2406 if (ost->enc->ch_layouts[i].nb_channels) {
2408 err = av_channel_layout_copy(&f->ch_layout, &ost->enc->ch_layouts[i]);
2415 av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
2423 OutputStream *ost;
2653 ost = NULL;
2655 case AVMEDIA_TYPE_VIDEO: ost = new_video_stream (o, oc, src_idx); break;
2656 case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream (o, oc, src_idx); break;
2657 case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream (o, oc, src_idx); break;
2658 case AVMEDIA_TYPE_DATA: ost = new_data_stream (o, oc, src_idx); break;
2659 case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc, src_idx); break;
2662 ost = new_unknown_stream (o, oc, src_idx);
2677 if (ost)
2678 ost->sync_ist = input_streams[ input_files[map->sync_file_index]->ist_index
2710 ost = new_attachment_stream(o, oc, -1);
2711 ost->stream_copy = 0;
2712 ost->attachment_filename = o->attachments[i];
2713 ost->st->codecpar->extradata = attachment;
2714 ost->st->codecpar->extradata_size = len;
2717 av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE);
2771 OutputStream *ost = output_streams[i];
2773 if (ost->encoding_needed && ost->source_index >= 0) {
2774 InputStream *ist = input_streams[ost->source_index];
2778 if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
2779 ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
2780 err = init_simple_filtergraph(ist, ost);
2784 "%d:%d->%d:%d\n", ist->file_index, ost->source_index,
2785 nb_output_files - 1, ost->st->index);
2789 } else if (ost->stream_copy && ost->source_index >= 0) {
2790 InputStream *ist = input_streams[ost->source_index];
2795 if (ost->filter) {
2796 OutputFilter *f = ost->filter;
2797 switch (ost->enc_ctx->codec_type) {
2799 f->frame_rate = ost->frame_rate;
2800 f->width = ost->enc_ctx->width;
2801 f->height = ost->enc_ctx->height;
2802 if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
2803 f->format = ost->enc_ctx->pix_fmt;
2805 f->formats = ost->enc->pix_fmts;
2809 if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) {
2810 f->format = ost->enc_ctx->sample_fmt;
2812 f->formats = ost->enc->sample_fmts;
2814 if (ost->enc_ctx->sample_rate) {
2815 f->sample_rate = ost->enc_ctx->sample_rate;
2817 f->sample_rates = ost->enc->supported_samplerates;
2819 if (ost->enc_ctx->ch_layout.nb_channels) {
2820 set_channel_layout(f, ost);
2821 } else if (ost->enc->ch_layouts) {
2822 f->ch_layouts = ost->enc->ch_layouts;
3003 ost = output_streams[nb_output_streams - oc->nb_streams + j];
3009 ost->rotate_overridden = 1;
3010 ost->rotate_override_value = theta;