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");
193 fprintf(stderr,
"codec not found\n");
199 fprintf(stderr,
"Could not alloc stream\n");
251 pix_fmt, width, height);
263 fprintf(stderr,
"could not open codec\n");
282 fprintf(stderr,
"Could not allocate picture\n");
293 fprintf(stderr,
"Could not allocate temporary picture\n");
308 for (y = 0; y <
height; y++)
309 for (x = 0; x <
width; x++)
310 pict->
data[0][y * pict->
linesize[0] + x] = x + y + i * 3;
313 for (y = 0; y < height / 2; y++) {
314 for (x = 0; x < width / 2; x++) {
315 pict->
data[1][y * pict->
linesize[1] + x] = 128 + y + i * 2;
316 pict->
data[2][y * pict->
linesize[2] + x] = 64 + x + i * 5;
337 if (img_convert_ctx ==
NULL) {
343 if (img_convert_ctx ==
NULL) {
345 "Cannot initialize the conversion context\n");
394 fprintf(stderr,
"Error while writing video frame\n");
415 int main(
int argc,
char **argv)
417 const char *filename;
421 double audio_pts, video_pts;
428 printf(
"usage: %s output_file\n"
429 "API example program to output a media file with libavformat.\n"
430 "The output format is automatically guessed according to the file extension.\n"
431 "Raw images can also be output by using '%%d' in the filename\n"
441 printf(
"Could not deduce output format from file extension: using MPEG.\n");
445 fprintf(stderr,
"Could not find suitable output format\n");
452 fprintf(stderr,
"Memory error\n");
481 fprintf(stderr,
"Could not open '%s'\n", filename);
507 if (!video_st || (video_st && audio_st && audio_pts < video_pts)) {