MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / encode

Function encode

doc/examples/encode_audio.c:94–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt,
95 FILE *output)
96{
97 int ret;
98
99 /* send the frame for encoding */
100 ret = avcodec_send_frame(ctx, frame);
101 if (ret < 0) {
102 fprintf(stderr, "Error sending the frame to the encoder\n");
103 exit(1);
104 }
105
106 /* read all the available output packets (in general there may be any
107 * number of them */
108 while (ret >= 0) {
109 ret = avcodec_receive_packet(ctx, pkt);
110 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
111 return;
112 else if (ret < 0) {
113 fprintf(stderr, "Error encoding audio frame\n");
114 exit(1);
115 }
116
117 fwrite(pkt->data, 1, pkt->size, output);
118 av_packet_unref(pkt);
119 }
120}
121
122int main(int argc, char **argv)
123{

Callers 1

mainFunction · 0.70

Calls 3

avcodec_send_frameFunction · 0.85
avcodec_receive_packetFunction · 0.85
av_packet_unrefFunction · 0.85

Tested by

no test coverage detected