<font color='black' size='2' face='arial'>
<div style="font-size: 10pt; color: black;"><font face="arial, helvetica">-----Original Message-----</font><br>
<font face="arial, helvetica">From: khoahung <hungnt@hiworld.com.vn></font><br>
<font face="arial, helvetica">To: libav-user <libav-user@ffmpeg.org></font><br>
<font face="arial, helvetica">Sent: Sun, Dec 15, 2013 1:18 pm</font><br>
<font face="arial, helvetica">Subject: [Libav-user] please support about IO-Context reading customer Raw buffer data</font><br>
<br>
<div id="AOLMsgPart_0_e7b005d3-2003-478f-94b4-b353176067eb" style="margin: 0px; font-size: 12px; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<pre style="font-size: 9pt;"><tt><font face="Tahoma, Verdana, Arial, sans-serif">why i'm can't call avformat_open_input(&pFormatCtx,"", NULL, NULL).my
program alway crash when call this function for Open Custom buff.my Buffer
is Raw Data video input here
-(id)initWithBuffer:(void*)buff size:(int)buff_size{
AVCodec *pCodec;
avcodec_register_all();
// Register all formats and codecs
av_register_all();
// av_init_packet(&packet);
if(avformat_network_init()!=0){
goto initError; // Couldn't init new work
}
uint8_t* pBuffer=av_malloc(buff_size*sizeof(uint8_t));
pFormatCtx = avformat_alloc_context();
AVIOContext* pIOCtx = avio_alloc_context(pBuffer,buff_size +
FF_INPUT_BUFFER_PADDING_SIZE,0,buff,&read_packet, NULL, NULL);
pIOCtx->seekable = 0;
pFormatCtx->iformat=av_find_input_format("h264");
pFormatCtx->flags = AVFMT_FLAG_CUSTOM_IO;
pFormatCtx->iformat->flags=AVFMT_NOFILE;
pFormatCtx->pb=pIOCtx;
/**
* Return the LIBAVFORMAT_VERSION_INT constant.
*/
printf("======>FFmpeg Version:%d \n ", avformat_version());
/**
* Return the libavformat build-time configuration.
*/
printf("========>FFmpeg libavformat Configuration:%s \n
",avformat_configuration());
/**
* Return the libavformat license.
*/
printf("=========>FFmpeg libavformat license:%s \n",avformat_license());
// Retrieve stream information
if(avformat_open_input(&pFormatCtx,"", NULL, NULL)<0)
goto initError;
if(avformat_find_stream_info(pFormatCtx,NULL)<0){
goto initError; // Couldn't find stream information
}
streamNo=-1;
// Find the first video stream
if ((streamNo = av_find_best_stream(pFormatCtx,AVMEDIA_TYPE_VIDEO, -1,
-1, &pCodec, 0)) < 0)
{
av_log(NULL, AV_LOG_ERROR, "Cannot find a video stream in the input
file %d\n",streamNo);
goto initError;
}
// Get a pointer to the codec context for the video stream
pCodecCtx=pFormatCtx->streams[streamNo]->codec;
// Find the decoder for the video stream
pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
// pCodec=avcodec_find_decoder(AV_CODEC_ID_FLV1);
if(pCodec==NULL)
goto initError; // Codec not found
// Open codec
if(avcodec_open2(pCodecCtx, pCodec, NULL)<0)
goto initError; // Could not open codec
// Allocate video frame
pFrame = avcodec_alloc_frame();
if(pFrame==NULL)
goto initError; // Not Found Frame
uint8_t *buffer;
int numBytes;
// Determine required buffer size and allocate buffer
//numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,
// pCodecCtx->height);
numBytes=avpicture_get_size(PIX_FMT_YUYV422, pCodecCtx->width,
pCodecCtx->height);
buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
outputWidth = pCodecCtx->width;
outputHeight = pCodecCtx->height;
avformat_free_context(pFormatCtx);
return self;
initError:
av_log(NULL, AV_LOG_ERROR,"====>Error %d \n", pFormatCtx->pb->error);
NSLog(@"initError in VideoFrameExtractor");
avformat_free_context(pFormatCtx);
return nil;
}
</font><font face="Arial, Helvetica, sans-serif">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>></font></tt></pre><pre style="font-size: 9pt;"><font face="Arial, Helvetica, sans-serif">Do not use this:</font></pre><pre style="font-size: 9pt;"><font face="Arial, Helvetica, sans-serif"> </font><span style="font-family: Tahoma, Verdana, Arial, sans-serif; font-size: 9pt;">pFormatCtx->iformat->flags=AVFMT_NOFILE; </span></pre><pre style="font-size: 9pt;"><span style="font-family: Tahoma, Verdana, Arial, sans-serif; font-size: 9pt;">w</span><span style="font-family: Tahoma, Verdana, Arial, sans-serif; font-size: 9pt;">ith custom I/0.</span></pre><pre style="font-size: 9pt;"><tt><font face="Arial, Helvetica, sans-serif">-F</font></tt><span style="font-family: Arial, Helvetica, sans-serif; font-size: 9pt;">elix</span></pre><pre style="font-size: 9pt;"><tt>--
View this message in context: <a href="http://libav-users.943685.n4.nabble.com/please-support-about-IO-Context-reading-customer-Raw-buffer-data-tp4659026.html" target="_blank" style="font-family: Tahoma, Verdana, Arial, sans-serif;">http://libav-users.943685.n4.nabble.com/please-support-about-IO-Context-reading-customer-Raw-buffer-data-tp4659026.html</a><font face="Tahoma, Verdana, Arial, sans-serif">
Sent from the libav-users mailing list archive at Nabble.com.
_______________________________________________
Libav-user mailing list
</font><a href="mailto:Libav-user@ffmpeg.org" style="font-family: Tahoma, Verdana, Arial, sans-serif;">Libav-user@ffmpeg.org</a><font face="Tahoma, Verdana, Arial, sans-serif">
</font><a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank" style="font-family: Tahoma, Verdana, Arial, sans-serif;">http://ffmpeg.org/mailman/listinfo/libav-user</a><font face="Tahoma, Verdana, Arial, sans-serif">
</font></tt></pre>
</div>
<!-- end of AOLMsgPart_0_e7b005d3-2003-478f-94b4-b353176067eb -->
</div>
</font>