Exemple #1
0
int main(int argc, char **argv)
{
    int ret;

    parse_loglevel(argc, argv, options);
    av_register_all();
    avformat_network_init();
    init_opts();
#if CONFIG_AVDEVICE
    avdevice_register_all();
#endif

    show_banner();
    parse_options(NULL, argc, argv, options, opt_input_file);

    if (!input_filename) {
        show_usage();
        fprintf(stderr, "You have to specify one input file.\n");
        fprintf(stderr,
                "Use -h to get full help or, even better, run 'man %s'.\n",
                program_name);
        exit(1);
    }

    ret = probe_file(input_filename);

    uninit_opts();
    av_dict_free(&fmt_entries_to_show);

    avformat_network_deinit();

    return ret;
}
Exemple #2
0
int main(int argc, char* argv[])
{
	AVFormatContext *pFormatCtx;
	AVDeviceInfoList*pDeviceList;
	AVInputFormat *ifmt;
	AVDictionary* options = NULL;
	AVOutputFormat *ofmt;

	av_register_all();
	avdevice_register_all();

	pFormatCtx = avformat_alloc_context();
	av_dict_set(&options, "list_devices", "true", 0);
	ifmt = av_find_input_format("gdigrab");
	if (avformat_open_input(&pFormatCtx, "title=D:\\project\\fftest\\fftest\\bin\\list_devices.exe", ifmt, &options) != 0) {
		printf("open dshow error\n");
		//return -1;
	}
	//pFormatCtx->iformat = ifmt;
	avdevice_list_devices(pFormatCtx, &pDeviceList);
	avdevice_list_input_sources(ifmt, "desktop", options, &pDeviceList);

	ofmt = av_guess_format("dshow", NULL, NULL);
	avdevice_list_output_sinks(ofmt, NULL, NULL, &pDeviceList);
	return 0;
}
Exemple #3
0
CameraSource::CameraSource()
    : deviceThread{new QThread}
    , deviceName{"none"}
    , device{nullptr}
    , mode(VideoMode())
    // clang-format off
    , cctx{nullptr}
#if LIBAVCODEC_VERSION_INT < 3747941
    , cctxOrig{nullptr}
#endif
    , videoStreamIndex{-1}
    , _isNone{true}
    , subscriptions{0}
{
    qRegisterMetaType<VideoMode>("VideoMode");
    deviceThread->setObjectName("Device thread");
    deviceThread->start();
    moveToThread(deviceThread);

    subscriptions = 0;

// TODO(sudden6): remove code when minimum ffmpeg version >= 4.0
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
    av_register_all();
#endif
    avdevice_register_all();
}
Exemple #4
0
int main(int argc, char **argv)
{
    int ret;

    av_register_all();
    init_opts();
#if CONFIG_AVDEVICE
    avdevice_register_all();
#endif

    show_banner();
    parse_options(argc, argv, options, opt_input_file);

    if (!input_filename) {
        show_usage();
        fprintf(stderr, "You have to specify one input file.\n");
        fprintf(stderr, "Use -h to get full help or, even better, run 'man ffprobe'.\n");
        exit(1);
    }

    ret = probe_file(input_filename);

    av_free(avformat_opts);

    return ret;
}
Exemple #5
0
void VideoPlayer::initAvcodec()
{
    av_register_all();
    avcodec_init();
    avcodec_register_all();
    avdevice_register_all();
}
void ff_init()
{
	av_register_all();
	avdevice_register_all();
	avcodec_register_all();
	avformat_network_init();
}
Exemple #7
0
int main(int argc, char **argv)
{
    int ret;
    uint8_t *buffer = av_malloc(AVP_BUFFSIZE);

    if (!buffer)
        exit(1);

    register_exit(avprobe_cleanup);

    options = real_options;
    parse_loglevel(argc, argv, options);
    av_register_all();
    avformat_network_init();
    init_opts();
#if CONFIG_AVDEVICE
    avdevice_register_all();
#endif

    show_banner();

    octx.print_header = ini_print_header;
    octx.print_footer = ini_print_footer;

    octx.print_array_header = ini_print_array_header;
    octx.print_array_footer = ini_print_array_footer;
    octx.print_object_header = ini_print_object_header;

    octx.print_integer = ini_print_integer;
    octx.print_string = ini_print_string;

    parse_options(NULL, argc, argv, options, opt_input_file);

    if (!input_filename) {
        show_usage();
        fprintf(stderr, "You have to specify one input file.\n");
        fprintf(stderr,
                "Use -h to get full help or, even better, run 'man %s'.\n",
                program_name);
        exit_program(1);
    }

    probe_out = avio_alloc_context(buffer, AVP_BUFFSIZE, 1, NULL, NULL,
                                 probe_buf_write, NULL);
    if (!probe_out)
        exit_program(1);

    probe_header();
    ret = probe_file(input_filename);
    probe_footer();
    avio_flush(probe_out);
    av_freep(&probe_out);
    av_freep(&buffer);
    uninit_opts();
    avformat_network_deinit();

    return ret;
}
Exemple #8
0
static int module_init(void)
{
	/* register all codecs, demux and protocols */
	avcodec_register_all();
	avdevice_register_all();
	av_register_all();

	return vidsrc_register(&mod_avf, "avformat", alloc, NULL);
}
Exemple #9
0
int init_decoder(codec_state *cs)
{
    avdevice_register_all();
    avcodec_register_all();
    avdevice_register_all();
    av_register_all();

    cs->receive_video = 0;
    cs->receive_audio = 0;

    cs->support_receive_video = init_receive_video(cs);
    cs->support_receive_audio = init_receive_audio(cs);

    cs->receive_audio = 1;
    cs->receive_video = 1;

    return 1;
}
Exemple #10
0
int init_encoder(codec_state *cs)
{
    avdevice_register_all();
    avcodec_register_all();
    avdevice_register_all();
    av_register_all();

    pthread_mutex_init(&cs->rtp_msg_mutex_lock, NULL);
    pthread_mutex_init(&cs->avcodec_mutex_lock, NULL);

    cs->support_send_video = init_send_video(cs);
    cs->support_send_audio = init_send_audio(cs);

    cs->send_audio = 1;
    cs->send_video = 1;

    return 1;
}
Exemple #11
0
WindDecoder::WindDecoder () : msUrl(""), mbQuit(false), mOperationLock("WindDecoder"), mpFormatCtx(NULL),
                              miVideoStream(-1), miAudioStream(-1), mAudioQueue(2*1024*1024), mVideoQueue(2*1024*1024) {
    //PacketQueue     mAudioQueue;
    //PacketQueue     mVideoQueue;

    // Register all formats and codecs
    av_register_all();
    avdevice_register_all();

}
Exemple #12
0
void dc_register_libav() {

	av_register_all();
	avcodec_register_all();
	avdevice_register_all();
	avformat_network_init();

	av_lockmgr_register(&lock_call_back);

}
Exemple #13
0
jint Java_org_libsdl_app_SDLActivity_ffInit(JNIEnv* env, jobject thiz )
{
#if CONFIG_AVDEVICE
    avdevice_register_all();
#endif
#if CONFIG_AVFILTER
    avfilter_register_all();
#endif
    av_register_all();
    avformat_network_init();
}
Exemple #14
0
void Capture::initFFmpeg()
{
	//set log level
	//av_log_set_level(AV_LOG_INFO);
	av_log_set_level(AV_LOG_QUIET);

	/* register all formats and mCodecs */
	av_register_all();
	avdevice_register_all();
	//avformat_network_init();
}
Exemple #15
0
void init_libav(void)
{
    av_log_set_callback(mp_msg_av_log_callback);
    avcodec_register_all();
    av_register_all();
    avformat_network_init();

#ifdef CONFIG_LIBAVDEVICE
    avdevice_register_all();
#endif
}
FFmpegVideo::FFmpegVideo(QObject *parent) :
    QObject(parent)
{
    av_register_all();
    avdevice_register_all();
    avformat_network_init();
    m_videodata = NULL;
    m_timer = new QTimer;

    rgb = new unsigned char[320 * 240 * 3];
    rgb_sws_ctx = 0;
}
void init_ffmpeg(void)
{
	// register all common ffmpeg things
	av_register_all();
	// register all the codec
	avcodec_register_all();
	// register all the devices
	avdevice_register_all();
	// register all filters
	avfilter_register_all();
	//register network
	avformat_network_init();
}
Exemple #18
0
void IMB_ffmpeg_init(void)
{
	av_register_all();
	avdevice_register_all();

	ffmpeg_last_error[0] = '\0';

	if (G.debug & G_DEBUG_FFMPEG)
		av_log_set_level(AV_LOG_DEBUG);

	/* set own callback which could store last error to report to UI */
	av_log_set_callback(ffmpeg_log_callback);
}
Exemple #19
0
void FFmpegParameters::parse(const std::string& name, const std::string& value)
{
    if (value.empty())
    {
        return;
    }
    else if (name == "format")
    {
        avdevice_register_all();
        m_format = av_find_input_format(value.c_str());
        if (!m_format)
            OSG_NOTICE<<"Failed to apply input video format: "<<value.c_str()<<std::endl;
    }
    else if (name == "pixel_format")
    {
        m_parameters.pix_fmt = osg_av_get_pix_fmt(value.c_str());
    }
    else if (name == "frame_size")
    {
        int frame_width = 0, frame_height = 0;
        if (av_parse_video_frame_size(&frame_width, &frame_height, value.c_str()) < 0)
        {
            OSG_NOTICE<<"Failed to apply frame size: "<<value.c_str()<<std::endl;
            return;
        }
        if ((frame_width % 2) != 0 || (frame_height % 2) != 0)
        {
            OSG_NOTICE<<"Frame size must be a multiple of 2: "<<frame_width<<"x"<<frame_height<<std::endl;
            return;
        }
        m_parameters.width = frame_width;
        m_parameters.height = frame_height;
    }
    else if (name == "frame_rate")
    {
        AVRational frame_rate;
        if (av_parse_video_frame_rate(&frame_rate, value.c_str()) < 0)
        {
            OSG_NOTICE<<"Failed to apply frame rate: "<<value.c_str()<<std::endl;
            return;
        }
        m_parameters.time_base.den = frame_rate.num;
        m_parameters.time_base.num = frame_rate.den;
    }
    else if (name == "audio_sample_rate")
    {
        int audio_sample_rate = 44100;
        std::stringstream ss(value); ss >> audio_sample_rate;
        m_parameters.sample_rate = audio_sample_rate;
    }
Exemple #20
0
static void
init_once()
{
    av_register_all();
    avdevice_register_all();
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 13, 0)
    avformat_network_init();
#endif

    av_lockmgr_register(avcodecManageMutex);

    if (getDebugMode())
        setAvLogLevel();
}
Exemple #21
0
void do_init_ffmpeg(void)
{
    static int ffmpeg_init = 0;
    if (!ffmpeg_init) {
        ffmpeg_init = 1;
        av_register_all();
        avdevice_register_all();

        if ((G.f & G_DEBUG) == 0)
        {
            silence_log_ffmpeg(1);
        }
    }
}
Exemple #22
0
static int module_init(void)
{
	/* register all codecs, demux and protocols */
	avcodec_register_all();
	avdevice_register_all();

#if LIBAVFORMAT_VERSION_INT >= ((53<<16) + (13<<8) + 0)
	avformat_network_init();
#endif

	av_register_all();

	return vidsrc_register(&mod_avf, baresip_vidsrcl(),
			       "avformat", alloc, NULL);
}
Exemple #23
0
CameraSource::CameraSource()
    : deviceName{"none"}
    , device{nullptr}
    , mode(VideoMode())
    , cctx{nullptr}
    , cctxOrig{nullptr}
    , videoStreamIndex{-1}
    , _isOpen{false}
    , streamBlocker{false}
    , subscriptions{0}
{
    subscriptions = 0;
    av_register_all();
    avdevice_register_all();
}
/**
 * To debug ffmpeg", type this command on the console before starting playback:
 *     setprop debug.nam.ffmpeg 1
 * To disable the debug, type:
 *     setprop debug.nam.ffmpge 0
*/
status_t initFFmpeg() 
{
    status_t ret = OK;
    bool debug_enabled = false;
    char value[PROPERTY_VALUE_MAX];

    pthread_mutex_lock(&init_mutex);

    if (property_get("debug.nam.ffmpeg", value, NULL)
        && (!strcmp(value, "1") || !av_strcasecmp(value, "true"))) {
        LOGI("set ffmpeg debug level to AV_LOG_DEBUG");
        debug_enabled = true;
    }
    if (debug_enabled)
        av_log_set_level(AV_LOG_DEBUG);
    else
        av_log_set_level(AV_LOG_INFO);

    if(ref_count == 0) {
        nam_av_log_set_flags(AV_LOG_SKIP_REPEATED);
        av_log_set_callback(nam_av_log_callback);

        /* register all codecs, demux and protocols */
        avcodec_register_all();
#if CONFIG_AVDEVICE
        avdevice_register_all();
#endif
        av_register_all();
        avformat_network_init();

        /* register android source */
        ffmpeg_register_android_source();

        init_opts();

        if (av_lockmgr_register(lockmgr)) {
            LOGE("could not initialize lock manager!");
            ret = NO_INIT;
        }
    }

    // update counter
    ref_count++;

    pthread_mutex_unlock(&init_mutex);

    return ret;
}
Exemple #25
0
ScreenGrabber::ScreenGrabber(int inputWidth, int inputHeight)
{
  avcodec_register_all();
  avdevice_register_all();
#if CONFIG_AVFILTER
  avfilter_register_all();
#endif
  av_register_all();

  webcamCapture.resize(WebcamWidth * WebcamHeight * 4);
  auto fileName = ":0.0+65,126";
  if (inputHeight == 1080)
    fileName = ":0.0+0,74";
  auto format = "x11grab";
  auto inputFormat = av_find_input_format(format);
  if (!inputFormat)
  {
    std::cerr << "Unknown input format: '" << format << "'" << std::endl;
    exit(1);
  }

  AVDictionary *format_opts = NULL;
  av_dict_set(&format_opts, "framerate", std::to_string(OutputFrameRate).c_str(), 0);
  std::string resolution = std::to_string(inputWidth) + "x" + std::to_string(inputHeight);
  av_dict_set(&format_opts, "video_size", resolution.c_str(), 0);
  int len = avformat_open_input(&formatContext, fileName, inputFormat, &format_opts);
  if (len != 0)
  {
    std::cerr << "Could not open input " << fileName << std::endl;
    throw - 0x10;
  }
  if (avformat_find_stream_info(formatContext, NULL) < 0)
  {
    std::cerr << "Could not read stream information from " << fileName << std::endl;
    throw - 0x11;
  }
  av_dump_format(formatContext, 0, fileName, 0);
  av_dict_free(&format_opts);

  width = formatContext->streams[0]->codecpar->width;
  height = formatContext->streams[0]->codecpar->height;
  std::cout << "YUV4MPEG2 W" << width << " H" << height << " F" << OutputFrameRate
            << ":1 Ip A0:0 C420jpeg XYSCSS=420JPEG\n";
  yuv.resize(width * height * 3 / 2);
  memset(&packet, 0, sizeof(packet));
  webcamThread =
    std::make_unique<std::thread>(webcamGrabber, std::ref(webcamCapture), std::ref(done));
}
Exemple #26
0
/*
 * Init ffmpeg_ video driver.
 */
pjmedia_vid_dev_factory* pjmedia_ffmpeg_factory(pj_pool_factory *pf)
{
    ffmpeg_factory *f;
    pj_pool_t *pool;

    pool = pj_pool_create(pf, "ffmpeg_cap_dev", 1000, 1000, NULL);
    f = PJ_POOL_ZALLOC_T(pool, ffmpeg_factory);

    f->pool = pool;
    f->pf = pf;
    f->base.op = &factory_op;

    avdevice_register_all();

    return &f->base;
}
Exemple #27
0
    TFFmpegReaderImp(const char* fname, TParams* params) {
	FormatCtx = NULL;
	Packet = NULL;
	
	av_log_set_level(AV_LOG_QUIET);
	av_register_all();
	avdevice_register_all();

	AVDictionary *av_options = NULL;
	if(params)
	    for(auto i = params->begin(); i != params->end(); ++i)
		av_dict_set(&av_options, i->first.c_str(), i->second.c_str(), 0);
	
	if(avformat_open_input(&FormatCtx, fname, NULL, &av_options) != 0)
	    throw TFFmpegException("Couldn't open file");
	if(avformat_find_stream_info(FormatCtx, NULL) < 0)
	    throw TFFmpegException("Stream info not found");

	// Init streams
	Streams.resize(FormatCtx->nb_streams);
	for(size_t i = 0; i < Streams.size(); ++i) {
	    TFFmpegStream& Stream = Streams[i];
	    AVCodecContext *CodecCtxTmp = FormatCtx->streams[i]->codec;
	    if(CodecCtxTmp->codec_type == AVMEDIA_TYPE_AUDIO)
		Stream.Type = EFF_AUDIO_STREAM;
	    else if(CodecCtxTmp->codec_type == AVMEDIA_TYPE_VIDEO) {
		Stream.Type = EFF_VIDEO_STREAM;
	    } else {
		Stream.Type = EFF_UNK_STREAM;
		continue;
	    }
	    AVCodec *Codec = avcodec_find_decoder(CodecCtxTmp->codec_id);
	    if(Codec == NULL)
		throw TFFmpegException("Codec not found");
	    Stream.CodecCtx = avcodec_alloc_context3(Codec);
	    if(avcodec_copy_context(Stream.CodecCtx, CodecCtxTmp) != 0) 
		throw TFFmpegException("Couldn't copy codec context");
	    if(avcodec_open2(Stream.CodecCtx, Codec, NULL) < 0)
		throw TFFmpegException("Couldn't open codec");
	    avcodec_close(CodecCtxTmp);

	    Stream.Init();
	}

	Packet = new AVPacket();
	av_init_packet(Packet);
    }
Exemple #28
0
/// INIT GLOBALS
void InitGlobals()
{
	avcodec_register_all();
	avdevice_register_all();
	av_register_all();
    //char* dbg = "GLOBAL INIT DBG";
	
    gIsWindowsVistaOrNewer = IsWindowsVistaOrNewer();

	//startup settings default
    memset(&gStartupSettings, 0, sizeof(gStartupSettings));

	srand((int)time(NULL));

	// Get compatible handle for screen
	ghMemDC = CreateCompatibleDC(NULL);

	BITMAPINFO bmi;
	memset(&bmi, 0, sizeof(BITMAPINFO));
	bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	bmi.bmiHeader.biWidth = 800;
	bmi.bmiHeader.biHeight = -600;
	bmi.bmiHeader.biPlanes = 1;
	bmi.bmiHeader.biBitCount = 32;
	bmi.bmiHeader.biCompression = BI_RGB;
	gpScreenBits = 0;

	ghGeneralDIB = CreateDIBSection(ghMemDC, &bmi, DIB_RGB_COLORS, (void**)&gpScreenBits, 0, 0);

	// Try to activate death counter, and disable it if there's some problem
	gDeathCounter.TryLoadStats();
	if(gDeathCounter.mStatFileOK == false)
		gDeathCounter.mEnabled = false;

	/// Init autocode manager	

	gAutoMan.Clear(true);
	gAutoMan.ReadGlobals(getModulePath());
	gAutoMan.m_GlobalEnabled = true;

    // Be sure that the config folder exist
    if (GetFileAttributesW(L"config") & INVALID_FILE_ATTRIBUTES) {
        CreateDirectoryW(L"config", NULL);
    }

}
Exemple #29
0
static void avformat_init( )
{
	// Initialise avformat if necessary
	if ( avformat_initialised == 0 )
	{
		avformat_initialised = 1;
		av_lockmgr_register( &avformat_lockmgr );
		av_register_all( );
#ifdef AVDEVICE
		avdevice_register_all();
#endif
#if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(13<<8))
		avformat_network_init();
#endif
		av_log_set_level( mlt_log_get_level() );
	}
}
Exemple #30
0
VideoReader::VideoReader(string name) {
  
  this->name = name;
  pFormatCtx = 0;
  pCodecCtx = 0;
  optionsDict = 0;
  vstream_idx = -1;
  input_format = "";
  video_format = "";
  framerate = "";
  
  // Register all formats and codecs
  av_register_all();
  avcodec_register_all();
  avdevice_register_all();
  avformat_network_init();
}