|
i think your problem is the url you are passing to "avformat_open_input", RTSP runs on top of TCP, i doubt it works without a valid hostname/ip address.
Mihai,
From: Libav-user <[email protected]> on behalf of Carlos Esponda <[email protected]>
Sent: Friday, July 31, 2020 2:25 AM To: [email protected] Subject: [NEWSLETTER] [Libav-user] help 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; } |
_______________________________________________ Libav-user mailing list [email protected] https://ffmpeg.org/mailman/listinfo/libav-user
To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
