| 3607 | } |
| 3608 | |
| 3609 | static int transcode_init(void) |
| 3610 | { |
| 3611 | int ret = 0, i, j, k; |
| 3612 | AVFormatContext *oc; |
| 3613 | OutputStream *ost; |
| 3614 | InputStream *ist; |
| 3615 | char error[1024] = {0}; |
| 3616 | |
| 3617 | for (i = 0; i < nb_filtergraphs; i++) { |
| 3618 | FilterGraph *fg = filtergraphs[i]; |
| 3619 | for (j = 0; j < fg->nb_outputs; j++) { |
| 3620 | OutputFilter *ofilter = fg->outputs[j]; |
| 3621 | if (!ofilter->ost || ofilter->ost->source_index >= 0) |
| 3622 | continue; |
| 3623 | if (fg->nb_inputs != 1) |
| 3624 | continue; |
| 3625 | for (k = nb_input_streams-1; k >= 0 ; k--) |
| 3626 | if (fg->inputs[0]->ist == input_streams[k]) |
| 3627 | break; |
| 3628 | ofilter->ost->source_index = k; |
| 3629 | } |
| 3630 | } |
| 3631 | |
| 3632 | /* init framerate emulation */ |
| 3633 | for (i = 0; i < nb_input_files; i++) { |
| 3634 | InputFile *ifile = input_files[i]; |
| 3635 | if (ifile->rate_emu) |
| 3636 | for (j = 0; j < ifile->nb_streams; j++) |
| 3637 | input_streams[j + ifile->ist_index]->start = av_gettime_relative(); |
| 3638 | } |
| 3639 | |
| 3640 | /* init input streams */ |
| 3641 | for (i = 0; i < nb_input_streams; i++) |
| 3642 | if ((ret = init_input_stream(i, error, sizeof(error))) < 0) { |
| 3643 | for (i = 0; i < nb_output_streams; i++) { |
| 3644 | ost = output_streams[i]; |
| 3645 | avcodec_close(ost->enc_ctx); |
| 3646 | } |
| 3647 | goto dump_format; |
| 3648 | } |
| 3649 | |
| 3650 | /* open each encoder */ |
| 3651 | for (i = 0; i < nb_output_streams; i++) { |
| 3652 | // skip streams fed from filtergraphs until we have a frame for them |
| 3653 | if (output_streams[i]->filter) |
| 3654 | continue; |
| 3655 | |
| 3656 | ret = init_output_stream(output_streams[i], error, sizeof(error)); |
| 3657 | if (ret < 0) |
| 3658 | goto dump_format; |
| 3659 | } |
| 3660 | |
| 3661 | /* discard unused programs */ |
| 3662 | for (i = 0; i < nb_input_files; i++) { |
| 3663 | InputFile *ifile = input_files[i]; |
| 3664 | for (j = 0; j < ifile->ctx->nb_programs; j++) { |
| 3665 | AVProgram *p = ifile->ctx->programs[j]; |
| 3666 | int discard = AVDISCARD_ALL; |
no test coverage detected