- /* find the decoder for the video stream */
- input_codec = avcodec_find_decoder(input_codec_ctx->codec_id);
- if (input_codec == NULL) {
- fprintf(stderr, "input_codec is NULL!\n");
- ret = -ENOTSUP;
- goto cleanup;
+ input_codec_params = input_format_ctx->streams[video_index]->codecpar;
+ ret = avcodec_parameters_to_context(input_codec_ctx, input_codec_params);
+ if (ret < 0) {
+ fprintf(stderr, "cannot copy parameters to input codec context\n");
+ goto cleanup_ctx;