Hi,
I have to transcode a short FLV movie (570k; 480*360; without audio) to
MJPEG but I didnt find any tutorials to do that :s
My problem is for the decoding of the FLV movie.
Its the first time I use ffmpeg to decode :s
(Libavcodec Version 51.7.0)
Could you check the code below please, from the next following few remarks ?
- Did I initialize the codec correctly ?
- Is the AvCodecContext filled correctly for FLV ?
- avcodec_find_decoder(CODEC_ID_FLV1)returns a good value but
avcodec_decode_video() returns -1
- if I replace CODEC_ID_FLV1 by CODEC_ID_H263 (because FLV = Sorenson
H263), avcodec_decode_video returns a good value but got_picture = 0
- Is PIX_FMT_YUVJ420P the good PixelFormat ?
Sorry for my french english.
Thank you in advance.
The following code is a sample of the complete code but should be
sufficient.
avcodec_init();
av_register_all();
m_pCodecCtx = avcodec_alloc_context();
avcodec_get_context_defaults(m_pCodecCtx);
m_pCodecCtx->width=m_iWidth; // Width of the input FLV video: 480
m_pCodecCtx->height=m_iHeight; // Heigth of the input FLV video: 360
// RGB24 Context Init
m_pRGB24CodecCtx = avcodec_alloc_context();
m_pRGB24CodecCtx->width=m_iWidth;
m_pRGB24CodecCtx->height=m_iHeight;
m_pRGB24CodecCtx->pix_fmt = (PixelFormat)PIX_FMT_BGR24;
m_pRGB24Frame = avcodec_alloc_frame();
switch(m_iCodecID)
{
case CODEC_ID_FLV1 :
m_pCodec = avcodec_find_decoder(CODEC_ID_FLV1);
//CODEC_ID_H263);
if (!m_pCodec)
{
return false; // !!! !!! !!!
}
m_pCodecCtx->thread_count = 1;
m_pCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
m_pCodecCtx->error_resilience = FF_ER_COMPLIANT;
m_pCodecCtx->error_concealment = 3;
m_pCodecCtx->idct_algo = FF_IDCT_AUTO;
m_pCodecCtx->debug = 0;
m_pCodecCtx->debug_mv = 0;
//m_pCodecCtx->codec_tag = 2;
// Inform the codec that we can handle truncated bitstreams --
i.e.,
// bitstreams where frame boundaries can fall in the middle of
packets
if(m_pCodec->capabilities & CODEC_CAP_TRUNCATED)
m_pCodecCtx->flags|=CODEC_FLAG_TRUNCATED;
if (avcodec_open(m_pCodecCtx, m_pCodec) < 0)
{
return false; // !!! !!! !!!
}
m_pCodecCtx->pix_fmt = (PixelFormat) PIX_FMT_YUVJ420P; // or
PIX_FMT_RGB24 ?
break;
default:
CString sMsg;
sMsg.Format(_T("[CVideoCodec::%d] ERROR not
implemented"),int(this));
m_pSession->WriteLog(sMsg,1);
break;
}
m_iPixFmt = m_pCodecCtx->pix_fmt;
} else
{
m_pCodecCtx->pix_fmt = (PixelFormat) m_iPixFmt;
}
m_pInputFrame = avcodec_alloc_frame();
int numBytes=avpicture_get_size(m_iPixFmt, m_pCodecCtx->width,
m_pCodecCtx->height);
m_buffer=new unsigned char[numBytes];
avpicture_fill((AVPicture *)m_pInputFrame, m_buffer, m_iPixFmt,
m_pCodecCtx->width, m_pCodecCtx->height);
m_pOutputFrame= avcodec_alloc_frame();
}
int got_picture = 0;
int iDecodedBytesCount = 0;
iDecodedBytesCount = avcodec_decode_video ( m_pCodecCtx,
m_pInputFrame,
//m_pOutputFrame,
&got_picture,
Buffer,
uiBufferUsed );
_____
Ce message et toutes les pièces attachées sont établis et expédiés à
l'intention exclusive de son ou de ses destinataires, leur contenu en est
confidentiel. Si vous recevez par erreur ce message, soyez aimable de le
détruire et d'avertir l'expéditeur de lerreur de routage. Toute utilisation
de ce message non conforme à sa destination, toute diffusion ainsi que toute
publication même partielle, est interdite, sauf autorisation expresse de
lexpéditeur. Le mode de transport ne permettant pas d'assurer l'intégrité
de ce message, ESI décline toute responsabilité au titre de ce message, dans
l'hypothèse où il aurait été modifié.
This message and all attached elements are established and sent to its or
their addressees with an exclusive intention, their content is confidential.
If you receive by mistake this message, please destroy it and warn the
sender of the routings error. Any use of this message not in conformity
with its destination, any distribution as well as any publication even
partial, is forbidden, except with the express authorization of the sender.
The way of transporting not allowing to ensure the integrity of this
message, ESI declines any responsibility in conformance with this message,
with the hypothesis where it would have been modified.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user