<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<span style="color: rgb(51, 51, 51); font-family: 'Lucida Grande',
'Trebuchet MS', Verdana, Helvetica, Arial, sans-serif; font-size:
13px; font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; line-height: 18.1875px; orphans:
auto; text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px; background-color: rgb(225, 235,
242); display: inline !important; float: none;">I use to compile
the 32-bit version of ffmpeg visual studio 2012. I used the latter
for now build from 5/29/13.</span><br style="margin: 0px; padding:
0px; color: rgb(51, 51, 51); font-family: 'Lucida Grande',
'Trebuchet MS', Verdana, Helvetica, Arial, sans-serif; font-size:
13px; font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; line-height: 18.1875px; orphans:
auto; text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px; background-color: rgb(225, 235,
242);">
<span style="color: rgb(51, 51, 51); font-family: 'Lucida Grande',
'Trebuchet MS', Verdana, Helvetica, Arial, sans-serif; font-size:
13px; font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; line-height: 18.1875px; orphans:
auto; text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px; background-color: rgb(225, 235,
242); display: inline !important; float: none;">This is my test
code that reproduces the problem:<br>
<br>
avcodec_register_all();<br>
<br>
int width = 764, height = 480;<br>
int got_output;<br>
AVFrame *frame;<br>
AVPacket pkt;<br>
AVCodec *codec;<br>
AVCodecContext *c = NULL;<br>
<br>
while(1)<br>
{<br>
frame = avcodec_alloc_frame();<br>
if (!frame) {<br>
fprintf(stderr, "Could not allocate video frame\n");<br>
return -1;<br>
}<br>
frame->format = AV_PIX_FMT_YUV420P;<br>
frame->width = width;<br>
frame->height = height;<br>
<br>
/* the image can be allocated by any means and
av_image_alloc() is<br>
* just the most convenient way if av_malloc() is to be
used */<br>
int ret = av_image_alloc(frame->data,
frame->linesize, width, height,<br>
AV_PIX_FMT_YUV420P, 1);<br>
if (ret < 0) {<br>
fprintf(stderr, "Could not allocate raw picture
buffer\n");<br>
av_freep(&frame->data[0]);<br>
avcodec_free_frame(&frame);<br>
return -1;<br>
}<br>
<br>
/* find the mpeg4 video encoder */<br>
codec = avcodec_find_encoder(AV_CODEC_ID_MPEG4);<br>
if (!codec) {<br>
fprintf(stderr, "Codec not found\n");<br>
return -1;<br>
}<br>
<br>
c = avcodec_alloc_context3(codec);<br>
if (!c) {<br>
fprintf(stderr, "Could not allocate video codec
context\n");<br>
return -1;<br>
}<br>
<br>
/* put sample parameters */<br>
c->profile = FF_PROFILE_MPEG4_SIMPLE;<br>
/* resolution must be a multiple of two */<br>
c->width = width;<br>
c->height = height;<br>
/* frames per second */<br>
c->time_base.den = 25;<br>
c->time_base.num = 1;<br>
c->gop_size = 25; /* emit one intra frame every 25
frames */<br>
c->pix_fmt = AV_PIX_FMT_YUV420P;<br>
c->qmax = 4;<br>
c->qmin = 4;<br>
<br>
/* open it */<br>
if (avcodec_open2(c, codec, NULL) < 0) {<br>
fprintf(stderr, "Could not open codec\n");<br>
avcodec_close(c);<br>
av_free(c);<br>
return -1;<br>
}<br>
<br>
for(int k = 0; k < 30; k++)<br>
{<br>
av_init_packet(&pkt);<br>
pkt.data = NULL; // packet data will be allocated
by the encoder<br>
pkt.size = 0;<br>
<br>
frame->pts = c->frame_number;<br>
<br>
/* encode the image */<br>
if (avcodec_encode_video2(c, &pkt, frame,
&got_output) < 0) {<br>
fprintf(stderr, "Error encoding frame\n");<br>
return -1;<br>
}<br>
<br>
if (got_output) {<br>
av_free_packet(&pkt);<br>
}<br>
}<br>
<br>
if(c)<br>
{<br>
avcodec_close(c);<br>
av_free(c);<br>
}<br>
if(frame)<br>
{<br>
av_freep(&frame->data[0]);<br>
avcodec_free_frame(&frame);<br>
}<br>
}<br>
<br>
</span><span style="color: rgb(51, 51, 51); font-family: 'Lucida
Grande', 'Trebuchet MS', Verdana, Helvetica, Arial, sans-serif;
font-size: 13px; font-style: normal; font-variant: normal;
font-weight: normal; letter-spacing: normal; line-height:
18.1875px; orphans: auto; text-align: start; text-indent: 0px;
text-transform: none; white-space: normal; widows: auto;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
background-color: rgb(225, 235, 242); display: inline !important;
float: none;">When you call function avcodec_close () throws an
exception. Such an error is detected on the MPEG4 codec with a
frame width in the range 754-767 at an altitude of 480. Perhaps at
other resolutions, too. Help solve the problem.</span><br
style="margin: 0px; padding: 0px; color: rgb(51, 51, 51);
font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Helvetica,
Arial, sans-serif; font-size: 13px; font-style: normal;
font-variant: normal; font-weight: normal; letter-spacing: normal;
line-height: 18.1875px; orphans: auto; text-align: start;
text-indent: 0px; text-transform: none; white-space: normal;
widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;
background-color: rgb(225, 235, 242);">
<span style="color: rgb(51, 51, 51); font-family: 'Lucida Grande',
'Trebuchet MS', Verdana, Helvetica, Arial, sans-serif; font-size:
13px; font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; line-height: 18.1875px; orphans:
auto; text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px; background-color: rgb(225, 235,
242); display: inline !important; float: none;">...sorry for bad
english</span><br>
</body>
</html>