| 552 | } |
| 553 | |
| 554 | int main(int argc, char **argv) |
| 555 | { |
| 556 | int ret; |
| 557 | AVPacket *packet = NULL; |
| 558 | unsigned int stream_index; |
| 559 | unsigned int i; |
| 560 | |
| 561 | if (argc != 3) { |
| 562 | av_log(NULL, AV_LOG_ERROR, "Usage: %s <input file> <output file>\n", argv[0]); |
| 563 | return 1; |
| 564 | } |
| 565 | |
| 566 | if ((ret = open_input_file(argv[1])) < 0) |
| 567 | goto end; |
| 568 | if ((ret = open_output_file(argv[2])) < 0) |
| 569 | goto end; |
| 570 | if ((ret = init_filters()) < 0) |
| 571 | goto end; |
| 572 | if (!(packet = av_packet_alloc())) |
| 573 | goto end; |
| 574 | |
| 575 | /* read all packets */ |
| 576 | while (1) { |
| 577 | if ((ret = av_read_frame(ifmt_ctx, packet)) < 0) |
| 578 | break; |
| 579 | stream_index = packet->stream_index; |
| 580 | av_log(NULL, AV_LOG_DEBUG, "Demuxer gave frame of stream_index %u\n", |
| 581 | stream_index); |
| 582 | |
| 583 | if (filter_ctx[stream_index].filter_graph) { |
| 584 | StreamContext *stream = &stream_ctx[stream_index]; |
| 585 | |
| 586 | av_log(NULL, AV_LOG_DEBUG, "Going to reencode&filter the frame\n"); |
| 587 | |
| 588 | ret = avcodec_send_packet(stream->dec_ctx, packet); |
| 589 | if (ret < 0) { |
| 590 | av_log(NULL, AV_LOG_ERROR, "Decoding failed\n"); |
| 591 | break; |
| 592 | } |
| 593 | |
| 594 | while (ret >= 0) { |
| 595 | ret = avcodec_receive_frame(stream->dec_ctx, stream->dec_frame); |
| 596 | if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN)) |
| 597 | break; |
| 598 | else if (ret < 0) |
| 599 | goto end; |
| 600 | |
| 601 | stream->dec_frame->pts = stream->dec_frame->best_effort_timestamp; |
| 602 | ret = filter_encode_write_frame(stream->dec_frame, stream_index); |
| 603 | if (ret < 0) |
| 604 | goto end; |
| 605 | } |
| 606 | } else { |
| 607 | /* remux this frame without reencoding */ |
| 608 | av_packet_rescale_ts(packet, |
| 609 | ifmt_ctx->streams[stream_index]->time_base, |
| 610 | ofmt_ctx->streams[stream_index]->time_base); |
| 611 |
nothing calls this directly
no test coverage detected