[Libav-user] no frame error
Hommel, Sebastian
Sebastian.Hommel at hs-ruhrwest.de
Thu Aug 16 11:42:15 CEST 2012
Hello,
I try to grab images from a H.264 video stream of an Axis camera with Visual Studio 2010 for a x64 machine.
I use the latest Version of ffmpeg.
If I use ffplay.exe the stream is well shown, but in my implementation I get the Error: "no frame!" from avcodec_decode_video2().
My code and the full error is shown below.
Your<http://www.dict.cc/englisch-deutsch/Your.html> help<http://www.dict.cc/englisch-deutsch/help.html> is<http://www.dict.cc/englisch-deutsch/is.html> greatly<http://www.dict.cc/englisch-deutsch/greatly.html> appreciated.<http://www.dict.cc/englisch-deutsch/appreciated..html>
#include "stdafx.h"
extern "C"
{
#include <libavformat\avformat.h>
#include <libavcodec\avcodec.h>
}
int _tmain(int argc, _TCHAR* argv[])
{
AVFormatContext* ic = avformat_alloc_context();
avcodec_register_all();
avformat_network_init();
av_register_all();
AVPacket pkt1, *pkt = &pkt1;
avformat_open_input(&ic, "rtsp://root:hallo2010@10.2.114.57/axis-media/media.amp", NULL, NULL);
av_find_stream_info(ic);
av_dump_format(ic, 0, ic->filename, false);
AVCodecContext* enc = ic->streams[0]->codec;
int video_index = -1;
for(int i = 0; i < ic->nb_streams; i++)
{
enc = ic->streams[i]->codec;
if(enc->codec_type == AVMEDIA_TYPE_VIDEO)
{
video_index = i;
}
}
int picture = 0;
AVCodec* codec = avcodec_find_decoder(ic->streams[video_index]->codec->codec_id);
enc = avcodec_alloc_context();
if(codec->capabilities & CODEC_CAP_TRUNCATED)
ic->streams[video_index]->codec->flags|=CODEC_FLAG_TRUNCATED;
if (!codec ||
avcodec_open(enc, codec) < 0)
return -1;
av_read_play(ic);
AVFrame* frame;
frame = avcodec_alloc_frame();
av_init_packet(pkt);
avcodec_flush_buffers(enc);
uint8_t *buffer;
int numBytes;
enc->width = 1920;
enc->height = 1080;
// Determine required buffer size and allocate buffer
numBytes=avpicture_get_size(PIX_FMT_RGB24, enc->width,
enc->height);
buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
avpicture_fill((AVPicture *)frame, buffer, PIX_FMT_RGB24,
enc->width, enc->height);
int i = 10;
while(i>0)
{
i--;
if(av_read_packet(ic, pkt)<0) break;
if(pkt->stream_index==video_index)
{
avcodec_decode_video2(enc, frame, &picture, pkt);
}
av_free_packet(pkt);
}
avcodec_close(enc);
av_close_input_file(ic);
return 0;
}
OUTPUT:
[udp @ 0000000000588fe0] 'circular_buffer_size' option was set but it is not sup
ported on this build (pthread support is required)
[udp @ 000000000058fbc0] 'circular_buffer_size' option was set but it is not sup
ported on this build (pthread support is required)
[rtsp @ 0000000000586fc0] Estimating duration from bitrate, this may be inaccura
te
Input #0, rtsp, from 'rtsp://root:hallo2010@10.2.114.57/axis-media/media.amp':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.120000, bitrate: N/A
Stream #0:0: Video: h264 (Baseline), yuvj420p, 1920x1080 [SAR 1:1 DAR 16:9],
25 tbr, 90k tbn, 180k tbc
[h264 @ 00000000004a29a0] no frame!
[h264 @ 00000000004a29a0] no frame!
[h264 @ 00000000004a29a0] no frame!
[h264 @ 00000000004a29a0] no frame!
[h264 @ 00000000004a29a0] no frame!
[h264 @ 00000000004a29a0] no frame!
[h264 @ 00000000004a29a0] no frame!
[h264 @ 00000000004a29a0] no frame!
[h264 @ 00000000004a29a0] no frame!
[h264 @ 00000000004a29a0] no frame!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120816/3386dff6/attachment.html>
More information about the Libav-user
mailing list