Ticket #7251: ffmpeg-ticket-7251.c

File ffmpeg-ticket-7251.c, 818 bytes (added by Jose Santiago, 8 years ago)

Program that demonstrates the problem

Line 
1#include <libavcodec/avcodec.h>
2#include <libavutil/avassert.h>
3
4int main(void)
5{
6 AVCodec * codec;
7 AVCodecContext * avctx;
8
9 codec = avcodec_find_encoder(AV_CODEC_ID_MPEG2VIDEO);
10 av_assert0(codec != NULL);
11 avctx = avcodec_alloc_context3(codec);
12 av_assert0(avctx != NULL);
13
14 // Basic configuration
15 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
16 avctx->width = 640;
17 avctx->height = 480;
18 // Set some ffps that is not supported by MPEG2 Video
19 avctx->time_base.num = 91;
20 avctx->time_base.den = 2201;
21 avctx->ticks_per_frame = 1;
22 // Enable slice thread encoding
23 avctx->thread_count = 10;
24 avctx->thread_type = 2;
25 avctx->active_thread_type = 2;
26
27 // Open the Codec for encoding
28 avcodec_open2(avctx, codec, NULL);
29
30 // close and free the Codec
31 avcodec_free_context(&avctx);
32}