| 230 | } |
| 231 | |
| 232 | static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) |
| 233 | { |
| 234 | int err, i; |
| 235 | AVFormatContext *fmt_ctx; |
| 236 | |
| 237 | fmt_ctx = avformat_alloc_context(); |
| 238 | |
| 239 | if ((err = av_open_input_file(&fmt_ctx, filename, iformat, 0, NULL)) < 0) { |
| 240 | print_error(filename, err); |
| 241 | return err; |
| 242 | } |
| 243 | |
| 244 | /* fill the streams in the format context */ |
| 245 | if ((err = av_find_stream_info(fmt_ctx)) < 0) { |
| 246 | print_error(filename, err); |
| 247 | return err; |
| 248 | } |
| 249 | |
| 250 | dump_format(fmt_ctx, 0, filename, 0); |
| 251 | |
| 252 | /* bind a decoder to each input stream */ |
| 253 | for (i = 0; i < fmt_ctx->nb_streams; i++) { |
| 254 | AVStream *stream = fmt_ctx->streams[i]; |
| 255 | AVCodec *codec; |
| 256 | |
| 257 | if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) { |
| 258 | fprintf(stderr, "Unsupported codec (id=%d) for input stream %d\n", |
| 259 | stream->codec->codec_id, stream->index); |
| 260 | } else if (avcodec_open(stream->codec, codec) < 0) { |
| 261 | fprintf(stderr, "Error while opening codec for input stream %d\n", |
| 262 | stream->index); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | *fmt_ctx_ptr = fmt_ctx; |
| 267 | return 0; |
| 268 | } |
| 269 | |
| 270 | static int probe_file(const char *filename) |
| 271 | { |
no test coverage detected