[Libav-user] MPEG2 4:2:2 encoding in 4:3 sample_aspect_ratio
francesco at bltitalia.com
francesco at bltitalia.com
Thu Mar 15 11:32:58 CET 2012
Hi to all
have anyone attempted to encode in 4:3 format ? I can't do. If I
set:
AVRational vform;
codec = avcodec_find_encoder(CODEC_ID_MPEG2VIDEO);
if (!codec) { Memo1->Lines->Add("Unable to find codec "); goto
_Encod1Frame_err;}
pCodecCtx = avcodec_alloc_context3(codec);
if(pCodecCtx==NULL) { Memo1->Lines->Add("Unable to alloc codec
context");goto _Encod1Frame_err;}
pFrame = avcodec_alloc_frame();
if(pFrame==NULL) { Memo1->Lines->Add("Unable to alloc frame");goto
_Encod1Frame_err;}
vform.num = 4;
vform.den = 3;
pCodecCtx->sample_aspect_ratio = vform;
pCodecCtx->bit_rate = 50000000;
pCodecCtx->rc_max_rate = pCodecCtx->rc_min_rate =pCodecCtx->bit_rate;
pCodecCtx->flags = CODEC_FLAG_LOW_DELAY | CODEC_FLAG_INTERLACED_DCT;
pCodecCtx->flags2 =CODEC_FLAG2_INTRA_VLC | CODEC_FLAG2_NON_LINEAR_QUANT;
pCodecCtx->qmin = 1;
pCodecCtx->qmax = 4;
pCodecCtx->rtp_payload_size = 1;
pCodecCtx->rc_buffer_size = 2000000;
pCodecCtx->rc_initial_buffer_occupancy = 2000000;
The result is a compressed 50Mbit frame with 16:9 sample_aspect_ratio. In
fact the header is:
00 00 01 B3 2D 02 60 33 7A 12 23 D8
^^
that is 25fps at 16:9. If I set the sample_aspect_ratio to 16:9 that is
vform.num = 16;
vform.den = 9;
the result is
00 00 01 B3 2D 02 60 43 7A 12 23 D8
^^
in this case the format seems to be 2.21:1. If i make a conversion with
sample_aspect_ratio 1:1 then the output is correct.
Anyone have an idea ?
More information about the Libav-user
mailing list