42 #define STREAM_DURATION 5.0
43 #define STREAM_FRAME_RATE 25
44 #define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE))
45 #define STREAM_PIX_FMT AV_PIX_FMT_YUV420P
68 fprintf(stderr,
"codec not found\n");
74 fprintf(stderr,
"Could not alloc stream\n");
101 fprintf(stderr,
"could not open codec\n");
129 v = (int)(sin(
t) * 10000);
163 fprintf(stderr,
"Error while writing audio frame\n");
192 fprintf(stderr,
"codec not found\n");
198 fprintf(stderr,
"Could not alloc stream\n");
250 pix_fmt, width, height);
262 fprintf(stderr,
"could not open codec\n");
269 fprintf(stderr,
"Could not allocate picture\n");
280 fprintf(stderr,
"Could not allocate temporary picture\n");
295 for (y = 0; y <
height; y++)
296 for (x = 0; x <
width; x++)
297 pict->
data[0][y * pict->
linesize[0] + x] = x + y + i * 3;
300 for (y = 0; y < height / 2; y++) {
301 for (x = 0; x < width / 2; x++) {
302 pict->
data[1][y * pict->
linesize[1] + x] = 128 + y + i * 2;
303 pict->
data[2][y * pict->
linesize[2] + x] = 64 + x + i * 5;
324 if (img_convert_ctx ==
NULL) {
330 if (img_convert_ctx ==
NULL) {
332 "Cannot initialize the conversion context\n");
364 if (!ret && got_packet && pkt.
size) {
382 fprintf(stderr,
"Error while writing video frame\n");
402 int main(
int argc,
char **argv)
404 const char *filename;
408 double audio_pts, video_pts;
415 printf(
"usage: %s output_file\n"
416 "API example program to output a media file with libavformat.\n"
417 "The output format is automatically guessed according to the file extension.\n"
418 "Raw images can also be output by using '%%d' in the filename\n"
428 printf(
"Could not deduce output format from file extension: using MPEG.\n");
432 fprintf(stderr,
"Could not find suitable output format\n");
439 fprintf(stderr,
"Memory error\n");
468 fprintf(stderr,
"Could not open '%s'\n", filename);
494 if (!video_st || (video_st && audio_st && audio_pts < video_pts)) {