#include <stdio.h>
#include <stdlib.h>
#include <string.h>
{
int ret;
if (frame)
printf(
"Send frame %3"PRId64
"\n", frame->
pts);
if (ret < 0) {
fprintf(stderr, "Error sending a frame for encoding\n");
exit(1);
}
while (ret >= 0) {
return;
else if (ret < 0) {
fprintf(stderr, "Error during encoding\n");
exit(1);
}
printf(
"Write packet %3"PRId64
" (size=%5d)\n", pkt->
pts, pkt->
size);
fwrite(pkt->
data, 1, pkt->
size, outfile);
}
}
int main(
int argc,
char **argv)
{
const char *filename, *codec_name;
int i, ret, x, y;
FILE *f;
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
if (argc <= 2) {
fprintf(stderr, "Usage: %s <output file> <codec name>\n", argv[0]);
exit(0);
}
filename = argv[1];
codec_name = argv[2];
if (!codec) {
fprintf(stderr, "Codec '%s' not found\n", codec_name);
exit(1);
}
if (!c) {
fprintf(stderr, "Could not allocate video codec context\n");
exit(1);
}
if (!pkt)
exit(1);
if (ret < 0) {
fprintf(stderr,
"Could not open codec: %s\n",
av_err2str(ret));
exit(1);
}
f = fopen(filename, "wb");
if (!f) {
fprintf(stderr, "Could not open %s\n", filename);
exit(1);
}
if (!frame) {
fprintf(stderr, "Could not allocate video frame\n");
exit(1);
}
if (ret < 0) {
fprintf(stderr, "Could not allocate the video frame data\n");
exit(1);
}
for (i = 0; i < 25; i++) {
fflush(stdout);
if (ret < 0)
exit(1);
for (y = 0; y < c->
height; y++) {
for (x = 0; x < c->
width; x++) {
}
}
for (y = 0; y < c->
height/2; y++) {
for (x = 0; x < c->
width/2; x++) {
frame->
data[1][y * frame->
linesize[1] + x] = 128 + y + i * 2;
frame->
data[2][y * frame->
linesize[2] + x] = 64 + x + i * 5;
}
}
}
fwrite(endcode, 1, sizeof(endcode), f);
fclose(f);
return 0;
}