[Libav-user] help
Carlos Esponda
esponda.carlos9 at gmail.com
Fri Jul 31 02:25:17 EEST 2020
I am currently trying to read an RTSP stream with FFMPEG and can't get past
avformat_open_input.
Any help would be appreciated!
thank you.
#include <iostream>
extern "C"
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavcodec/codec.h>
#include "libswscale/swscale.h"
#include "libavutil/avutil.h"
#include "libavutil/frame.h"
#include "libavcodec/codec_id.h"
#include "libavutil/pixfmt.h"
#include "libavutil/imgutils.h"
}
int decode_interrupt(void*);
int main()
{
AVFrame* frame = NULL;
AVFormatContext* formatc = NULL;
const AVIOInterruptCB int_cb = { decode_interrupt, NULL };
AVCodec* codec = NULL;
AVCodecContext* codecc = NULL;
char* error = new char[255];
if (!(frame = av_frame_alloc())) {
std::cout << " failed to alloc frame";
return -1;
}
formatc = avformat_alloc_context();
formatc->interrupt_callback = int_cb;
codec = avcodec_find_decoder(AV_CODEC_ID_H264);
codecc = avcodec_alloc_context3(codec);
int result = avcodec_open2(codecc, codec, NULL);
if (result != 0) {
std::cout << "failed to open codec";
}
result = avformat_open_input(&formatc, "rtsp://:8554/testStream", NULL,
NULL);
if (result != 0) {
av_strerror(result, error, 255);
std::cout << "couldnt open input " << error<< std::endl;
avformat_close_input(&formatc);
return -1;
}
result = avformat_find_stream_info(formatc, NULL);
if (result != 0) {
std::cout << "could not find stream information\n";
return -1;
}
return 0;
}
int decode_interrupt(void * ctx) {
std::cout << "interupted\n";
return -1;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200730/99697deb/attachment.html>
More information about the Libav-user
mailing list