Advertisement
Guest User

fftest.cpp

a guest
Sep 24th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. extern "C" {
  4.   #include <libavcodec/avcodec.h>
  5.   #include <libavformat/avformat.h>
  6.   #include <libavutil/avutil.h>
  7. }
  8. #include <mutex>
  9.  
  10. int main(int argc, char *argv[]) {
  11.   // initialize av decoders
  12.   static std::once_flag initFlag;
  13.   std::call_once(initFlag, []() { av_register_all(); });
  14.  
  15.   // shared_ptr make it exception-safe
  16.   std::shared_ptr<AVFormatContext> avFormat(avformat_alloc_context(),
  17.             &avformat_free_context);
  18.  
  19.   // open and parse header information
  20.   auto avFormatPtr = avFormat.get();
  21.   avformat_network_init();
  22.   // if (avformat_open_input( &avFormatPtr, "rtp://localhost:5000",
  23.   if (avformat_open_input( &avFormatPtr, "rpi.sdp",
  24.               nullptr, nullptr) != 0)
  25.     throw std::runtime_error("Error while calling avformat_open_input (probably invalid file format)" );
  26.  
  27.  
  28.   fprintf(stderr, "past\n");
  29.   fprintf(stderr, "version: %d.%d.%d\n", LIBAVFORMAT_VERSION_MAJOR,
  30.                                          LIBAVFORMAT_VERSION_MINOR,
  31.                                          LIBAVFORMAT_VERSION_MICRO);
  32.  
  33.   if (avformat_find_stream_info(avFormat.get(), nullptr) < 0)
  34.     throw std::runtime_error("Error while calling avformat_find_stream_info");
  35.  
  36.   fprintf(stderr, "past\n");
  37.  
  38.   return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement