| 37 | #include <libavutil/imgutils.h> |
| 38 | |
| 39 | static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt, |
| 40 | FILE *outfile) |
| 41 | { |
| 42 | int ret; |
| 43 | |
| 44 | /* send the frame to the encoder */ |
| 45 | if (frame) |
| 46 | printf("Send frame %3"PRId64"\n", frame->pts); |
| 47 | |
| 48 | ret = avcodec_send_frame(enc_ctx, frame); |
| 49 | if (ret < 0) { |
| 50 | fprintf(stderr, "Error sending a frame for encoding\n"); |
| 51 | exit(1); |
| 52 | } |
| 53 | |
| 54 | while (ret >= 0) { |
| 55 | ret = avcodec_receive_packet(enc_ctx, pkt); |
| 56 | if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) |
| 57 | return; |
| 58 | else if (ret < 0) { |
| 59 | fprintf(stderr, "Error during encoding\n"); |
| 60 | exit(1); |
| 61 | } |
| 62 | |
| 63 | printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size); |
| 64 | fwrite(pkt->data, 1, pkt->size, outfile); |
| 65 | av_packet_unref(pkt); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | int main(int argc, char **argv) |
| 70 | { |
no test coverage detected