<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>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.
</p>
<p><br>
</p>
<p>Mihai,<br>
</p>
<p><br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Libav-user <libav-user-bounces@ffmpeg.org> on behalf of Carlos Esponda <esponda.carlos9@gmail.com><br>
<b>Sent:</b> Friday, July 31, 2020 2:25 AM<br>
<b>To:</b> libav-user@ffmpeg.org<br>
<b>Subject:</b> [NEWSLETTER] [Libav-user] help</font>
<div> </div>
</div>
<div>
<div dir="ltr">I am currently trying to read an RTSP stream with FFMPEG and can't get past avformat_open_input. <br>
<br>
Any help would be appreciated!
<div><br>
</div>
<div>thank you.<br>
<br>
  #include <iostream><br>
<br>
extern "C"<br>
{<br>
#include <libavformat/avformat.h><br>
#include <libavcodec/avcodec.h><br>
#include <libavcodec/codec.h><br>
#include "libswscale/swscale.h"<br>
#include "libavutil/avutil.h"<br>
#include "libavutil/frame.h"<br>
#include "libavcodec/codec_id.h"<br>
#include "libavutil/pixfmt.h"<br>
#include "libavutil/imgutils.h"<br>
}<br>
<br>
<br>
int decode_interrupt(void*);<br>
<br>
int main()<br>
{<br>
    AVFrame* frame = NULL;<br>
    AVFormatContext* formatc = NULL;<br>
    const AVIOInterruptCB int_cb = { decode_interrupt, NULL };<br>
    AVCodec* codec = NULL;<br>
    AVCodecContext* codecc = NULL;<br>
    char* error = new char[255];<br>
<br>
    if (!(frame = av_frame_alloc())) {<br>
        std::cout << " failed to alloc frame";<br>
        return -1;<br>
    }<br>
    formatc = avformat_alloc_context();<br>
    formatc->interrupt_callback = int_cb;<br>
<br>
    codec = avcodec_find_decoder(AV_CODEC_ID_H264);<br>
    codecc = avcodec_alloc_context3(codec);<br>
    int result = avcodec_open2(codecc, codec, NULL);<br>
    if (result != 0) {<br>
        std::cout << "failed to open codec";<br>
    }<br>
<br>
    result = avformat_open_input(&formatc, "rtsp://:8554/testStream", NULL, NULL);<br>
    if (result != 0) {<br>
        av_strerror(result, error, 255);<br>
        std::cout << "couldnt open input " << error<< std::endl;<br>
        avformat_close_input(&formatc);<br>
        return -1;<br>
    }<br>
<br>
    result = avformat_find_stream_info(formatc, NULL);<br>
    if (result != 0) {<br>
        std::cout << "could not find stream information\n";<br>
        return -1;<br>
    }<br>
<br>
    return 0;<br>
}<br>
<br>
int decode_interrupt(void * ctx) {<br>
    std::cout << "interupted\n";<br>
    return -1;<br>
}
<div class="gmail-yj6qo"></div>
<div class="gmail-adL"><br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>