Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- extern "C" {
- #include <libavcodec/avcodec.h>
- #include <libavformat/avformat.h>
- #include <libavutil/avutil.h>
- }
- #include <mutex>
- int main(int argc, char *argv[]) {
- // initialize av decoders
- static std::once_flag initFlag;
- std::call_once(initFlag, []() { av_register_all(); });
- // shared_ptr make it exception-safe
- std::shared_ptr<AVFormatContext> avFormat(avformat_alloc_context(),
- &avformat_free_context);
- // open and parse header information
- auto avFormatPtr = avFormat.get();
- avformat_network_init();
- // if (avformat_open_input( &avFormatPtr, "rtp://localhost:5000",
- if (avformat_open_input( &avFormatPtr, "rpi.sdp",
- nullptr, nullptr) != 0)
- throw std::runtime_error("Error while calling avformat_open_input (probably invalid file format)" );
- fprintf(stderr, "past\n");
- fprintf(stderr, "version: %d.%d.%d\n", LIBAVFORMAT_VERSION_MAJOR,
- LIBAVFORMAT_VERSION_MINOR,
- LIBAVFORMAT_VERSION_MICRO);
- if (avformat_find_stream_info(avFormat.get(), nullptr) < 0)
- throw std::runtime_error("Error while calling avformat_find_stream_info");
- fprintf(stderr, "past\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement