[Ffmpeg-devel] Re: Q: hot to encode avi to DVVideo?
Zinetz Victor
mail
Fri Dec 2 15:58:17 CET 2005
"M?ns Rullg?rd" <mru at mru.ath.cx> wrote in message
news:12585.194.202.59.51.1133532912.squirrel at 194.202.59.51...
Zinetz Victor said:
> Stream #0.1: Audio: pcm_s16le, 44100 Hz, stereo, 1411 kb/s
>> ^^^^^^^^
> [dv @ 00696CD4]Can't initialize DV format!
> Make sure that you supply exactly two streams:
> video: 25fps or 29.97fps, audio: 2ch/48Khz/PCM
>> ^^^^^
>>Try adding -ar 48000 before the output file.
Actually, i'm trying to do following:
[code]
var
encoder: PAVCodec;
encoder_context: PAVCodecContext;
RGBFrame,
YUVFrame: PAVFrame;
RGB_buf,
YUV_buf,
encoded_buf: pointer;
begin
...
encoder := avcodec_find_encoder (CODEC_ID_DVVIDEO);
encoder_context := avcodec_alloc_context ();
encoder_context^.bit_rate := 300000;
encoder_context^.time_base.num := 1;
encoder_context^.time_base.den := 12;
encoder_context^.width := bmp.Width;
encoder_context^.height := bmp.Height;
encoder_context^.gop_size := 12;
encoder_context^.max_b_frames := 1;
encoder_context^.pix_fmt := PIX_FMT_YUV420P;
encoder_context^.codec_type := CODEC_TYPE_VIDEO;
encoder_context^.codec_id := CODEC_ID_DVVIDEO;
ret_code := avcodec_open (encoder_context, encoder);
// here all ok, ret_code = 0
YUVFrame := avcodec_alloc_frame ();
YUV_buf := AllocMem (avpicture_get_size (PIX_FMT_YUV420P, bmp.Width,
bmp.Height));
avpicture_fill (PAVPicture (YUVFrame), YUV_buf, PIX_FMT_YUV420P,
bmp.Width, bmp.Height);
RGBFrame := avcodec_alloc_frame ();
RGB_buf := AllocMem (avpicture_get_size (PIX_FMT_RGBA32, bmp.Width,
bmp.Height));
avpicture_fill (PAVPicture (RGBFrame), RGB_buf, PIX_FMT_RGBA32,
bmp.Width, bmp.Height);
// here i create some bmp
bmp := fill_my_picture();
// and now i try to encode picture
for y := 0 to bmp.Height - 1 do
begin
data := pchar (RGBFrame.data [0]) + y * bmp.width * 4;
CopyMemory (data, bmp.ScanLine [y], bmp.Width * 4);
end;
img_convert (PAVPicture (YUVFrame), PIX_FMT_YUV420P,
PAVPicture (RGBFrame), PIX_FMT_RGBA32,
encoder_context^.width, encoder_context^.height);
out_size := avcodec_encode_video (encoder_context, encoded_buf, 100000,
YUVFrame);
// o-ops! here out_size always = -1
[/code]
from avcodec/utils.c:
[code]
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
const AVFrame *pict)
{
if(buf_size < FF_MIN_BUFFER_SIZE){
av_log(avctx, AV_LOG_ERROR, "buffer smaller then minimum size\n");
return -1;
}
if(avcodec_check_dimensions(avctx,avctx->width,avctx->height))
return -1;
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
int ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict);
avctx->frame_number++;
emms_c(); //needed to avoid an emms_c() call before every return;
return ret;
}else
return 0;
}
[/code]
As i can see function return "-1" if 1) buffer is too small, 2) wrong
picture dimension & 3) avctx->codec->encode = -1
If i try to encode in CODEC_ID_MSMPEG4V3 - all ok & imho my code is ok
May be exists some limitation for DVVideo?
wbr, Victor
p.s. sorry for my simple english
More information about the ffmpeg-devel
mailing list