Ejemplo n.º 1
1
status_t MediaPlayer::initFFmpegEngine()
{
    //FFMPEG INIT code 

    avcodec_register_all(); 
    avfilter_register_all(); 
    av_register_all(); 
    avformat_network_init();

    ffmpegEngineInitialized = true; 

    return NO_ERROR; 
}
Ejemplo n.º 2
0
static void InitAVCodec()
{
  static bool first_run = true;
  if (first_run)
  {
    av_register_all();
    avformat_network_init();
    first_run = false;
  }
}
Ejemplo n.º 3
0
AV::AV()
	:src_w(0)
	,src_h(0)
	,can_add_frames(false)
	,use_audio(false)
	
{
	av_register_all();
	avformat_network_init();
}
Ejemplo n.º 4
0
Archivo: av_log.c Proyecto: kax4/mpv
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
}
Ejemplo n.º 5
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();
}
Ejemplo n.º 6
0
AVDemuxer::AVDemuxer(const QString& fileName, QObject *parent)
    :QObject(parent),started_(false),eof(false),pkt(new Packet())
    ,ipts(0),stream_idx(-1),audio_stream(-2),video_stream(-2)
    ,subtitle_stream(-2),_is_input(true),format_context(0)
	,a_codec_context(0),v_codec_context(0),_file_name(fileName),master_clock(0)
{
    av_register_all();
    avformat_network_init();
    if (!_file_name.isEmpty())
        loadFile(_file_name);
}
Ejemplo n.º 7
0
int main(int argc, char **argv)
{
    int ret;
    uint8_t *buffer = av_malloc(AVP_BUFFSIZE);

    if (!buffer)
        exit(1);

    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_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(1);
    }

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

    probe_header();
    ret = probe_file(input_filename);
    probe_footer();
    avio_flush(probe_out);
    avio_close(probe_out);

    avformat_network_deinit();

    return ret;
}
Ejemplo n.º 8
0
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
    /* Register all formats. */
    av_register_all();

    /* No-op on Linux I think, but ffmpeg bitches if I don't call this. */
    avformat_network_init();

    /* Capture ffmpeg logging. */
    av_log_set_callback(dalvik_log_callback);

    return JNI_VERSION_1_4;
}
Ejemplo n.º 9
0
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;
}
Ejemplo n.º 10
0
int main(int argc, char **argv)
{
	av_log_set_flags(AV_LOG_SKIP_REPEATED);
	av_register_all();
	avformat_network_init();

	const char *filename = argv[1];
	demuxer dmux;
	dmux.open_input(filename);
	frame_loop(dmux);
	return 0;
}
Ejemplo n.º 11
0
int main(int argc, char *argv[])
{
	const char *op = NULL;
	int ret;

	av_log_set_level(AV_LOG_DEBUG);

	if (argc < 2) {
		usage(argv[0]);
		return 1;
	}

	/* register codecs and formats and other lavf/lavc components*/
	av_register_all();
	avformat_network_init();

	op = argv[1];
	if (strcmp(op, "list") == 0) {
		if (argc < 3) {
			av_log(NULL, AV_LOG_INFO, "Missing argument for list operation.\n");
			ret = AVERROR(EINVAL);
		}
		else {
			ret = list_op(argv[2]);
		}
	}
	else if (strcmp(op, "del") == 0) {
		if (argc < 3) {
			av_log(NULL, AV_LOG_INFO, "Missing argument for del operation.\n");
			ret = AVERROR(EINVAL);
		}
		else {
			ret = del_op(argv[2]);
		}
	}
	else if (strcmp(op, "move") == 0) {
		if (argc < 4) {
			av_log(NULL, AV_LOG_INFO, "Missing argument for move operation.\n");
			ret = AVERROR(EINVAL);
		}
		else {
			ret = move_op(argv[2], argv[3]);
		}
	}
	else {
		av_log(NULL, AV_LOG_INFO, "Invalid operation %s\n", op);
		ret = AVERROR(EINVAL);
	}

	avformat_network_deinit();

	return ret < 0 ? 1 : 0;
}
Ejemplo n.º 12
0
HRESULT CTMReceiverSrc::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt)
{
	//TODO: Open the file using ffmpeg;
	USES_CONVERSION;
	AVCodecContext *pVideoCodecCtx = NULL;
	AVCodec *pVideoCodec = NULL;
	avcodec_register_all();
	av_register_all();
	avformat_network_init();

	int cch = lstrlenW(pszFileName) + 1;
	m_pFileName = new WCHAR[cch];
	if(m_pFileName != NULL)
	{
		CopyMemory(m_pFileName, pszFileName, cch*sizeof(WCHAR));
	}

	m_pFormatContext = avformat_alloc_context();
	int err = avformat_open_input(&m_pFormatContext, W2A(m_pFileName), NULL, NULL);
	if(err != 0)
	{
		return E_FAIL;
	}
	m_pFormatContext->flags |= AVFMT_FLAG_GENPTS;
	m_pFormatContext->flags |= AVFMT_GENERIC_INDEX;
	m_pFormatContext->max_index_size = 99;
	m_pFormatContext->probesize /= 3;
	m_pFormatContext->max_analyze_duration /= 3;

	if(av_find_stream_info(m_pFormatContext) < 0)
	{
		return E_FAIL;
	}

	av_dump_format(m_pFormatContext, 0, W2A(m_pFileName), false);

	for(int i=0; i<m_pFormatContext->nb_streams; i++)
	{
		if(m_pFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
		{
			m_videoStreamIndex = i;
			pVideoCodecCtx = m_pFormatContext->streams[i]->codec;
			m_resolution.width = pVideoCodecCtx->width;
			m_resolution.height = pVideoCodecCtx->height;
		}
	}

	//TODO: Start a thread to read the packet.
	m_bReadStream = TRUE;
	DWORD dwThreadId = 0;
	m_readerThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ReaderProc, (LPVOID*)this, 0, &dwThreadId);
	return S_OK;
}
Ejemplo n.º 13
0
	VideoFile::VideoFile(const char* fFileName)
	{
		if(!inited )
		{
			avcodec_register_all();
			av_register_all();
			avformat_network_init();
			inited = 1;
		}
		direction = READ;
		//Open file format, auto detect format
		s = NULL;
		int ret = avformat_open_input(&s, fFileName, NULL, NULL);
		if (ret < 0)
			printf("failed to open input\n");
			
		//Find stream info
		ret = avformat_find_stream_info(s, NULL);
		if(ret < 0)
			printf("failed to find stream info\n");
			
		//Search for first video stream through all streams in file
		videoStream = -1;
		for(int i = 0; i < s->nb_streams; i++)
		{
			if(s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
			{
				videoStream = i;
				break;
			}
		}
		if(videoStream == -1)
		  printf("did not find a video stream\n");

		c = s->streams[videoStream]->codec;//Get a pointer to the codec context for the video stream
		
		//Find an actual codec to decode video
		codec = avcodec_find_decoder(c->codec_id);
		if(codec == NULL) 
			printf("found no codec\n");
			
		ret = avcodec_open2(c, codec, NULL);
		if(ret < 0)
			printf("could not open codec\n");
			
		//Create frame to store data and do RGB conversion and create buffer to handle frame data
		frame = av_frame_alloc();
		frameRGB = av_frame_alloc();
		bufferSize = avpicture_get_size(AV_PIX_FMT_RGB24, c->width, c->height);
		buffer = (unsigned char*) av_malloc(bufferSize * sizeof(unsigned char));
		avpicture_fill((AVPicture*)frameRGB, buffer, AV_PIX_FMT_RGB24, c->width, c->height);	
	}
Ejemplo n.º 14
0
void VideoStream::Initialise( )
{
	if ( logDebugging() )
        av_log_set_level( AV_LOG_DEBUG ); 
    else
        av_log_set_level( AV_LOG_QUIET ); 
	
	av_register_all( );
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 13, 0)
	avformat_network_init();
#endif
	initialised = true;
}
Ejemplo n.º 15
0
void FfmpegResources::registerAll()
{
	if(!m_registered)
	{
		av_register_all();
		avformat_network_init()	;
	}


#ifndef DEBUG
	av_log_set_callback(avLogCallback);
#endif //DEBUG
}
Ejemplo n.º 16
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();
}
Ejemplo n.º 17
0
// @todo - add a rx_shutdown_libav() to deinitialize e.g. the network (see libav/tools/aviocat.c)
void rx_init_libav() {
  if(!rx_did_register_all) {

    av_log_set_level(AV_LOG_DEBUG);

    av_register_all();
    avcodec_register_all();
    avformat_network_init();
    avfilter_register_all();

    rx_did_register_all = true;
  }
}
Ejemplo n.º 18
0
Decoder::Decoder(char* fileName) {
    pFormatCtx = NULL;
    pCodecCtx = NULL;
    pCodec = NULL;
    pFrame = NULL;
    pFrameRGB = NULL;
    buffer = NULL;
    sws_ctx = NULL;
    avformat_network_init();
    this->fileName = new char[strlen(fileName) + 1];
    strcpy(this->fileName, fileName);
    isPlay = false;
}
Ejemplo n.º 19
0
void InitSDL(){
	// Register all formats and codecs
	av_register_all();
	//network init 이걸 적지 않으면 워링이 나서 일단 적었다. (왜 적는지 잘 모르겠슴)
	avformat_network_init();

	//SDL 초기화 
	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER))
	{
		fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
		exit(1);
	}
}
Ejemplo n.º 20
0
void LiveStream::init()
{
    av_lockmgr_register(bc_av_lockmgr);
    av_register_all();
    avformat_network_init();

    m_renderTimer = new AutoTimer;
    m_renderTimer->setInterval(1000 / renderTimerFps);
    m_renderTimer->setSingleShot(false);

    m_stateTimer = new AutoTimer;
    m_stateTimer->setInterval(15000);
    m_stateTimer->setSingleShot(false);
}
Ejemplo n.º 21
0
int InitFFmpeg(Context *pContext)
{
    AVFormatContext *pFormatCtx = NULL;
    AVCodecContext *pCodecCtx = NULL;
    int videoStream;
    int i;
    AVCodec *pCodec;
    av_log_set_level(AV_LOG_DEBUG);
    avformat_network_init();
    av_register_all();
    if (avformat_open_input(&pFormatCtx, pContext->videoName, NULL, NULL) != 0)
    {
        fprintf(stderr, "Couldn't open file\n");
        return 1;
    }
    if (avformat_find_stream_info(pFormatCtx, NULL) < 0)
    {
        fprintf(stderr, "Couldn't find stream information\n");
        return 1;
    }
    videoStream = -1;
    for (i = 0; i < pFormatCtx->nb_streams; i++)
    {
        if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
        {
            videoStream = i;
            break;
        }
    }
    if (videoStream < 0)
    {
        fprintf(stderr, "Didn't find a video stream\n");
        return 1;
    }
    pCodecCtx = pFormatCtx->streams[videoStream]->codec;
    pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
    if(pCodec == NULL)
    {
        fprintf(stderr, "Unsupported codec!\n");
        return 1;
    }
    if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0)
    {
        fprintf(stderr, "Could not open codec\n");
        return 1;
    }
    pContext->pFormatCtx = pFormatCtx;
    pContext->pCodecCtx = pCodecCtx;
    return 0;
}
Ejemplo n.º 22
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();
}
Ejemplo n.º 23
0
int CamReadThread::EncodeInit()
{
	c= NULL;
	int yuv420_bytes = 0;
	m_pRGBFrame =  new AVFrame[1];  //RGB帧数据
	m_pYUVFrame =  new AVFrame[1];  //YUV帧数据

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

	fmtctx = avformat_alloc_context();

  codec = avcodec_find_encoder(AV_CODEC_ID_H264);
  if (!codec) {
      dbgprint("%s(%d),%d CAM Codec not found!\n",DEBUGARGS,CameraID);
  		return -1;
  }

	video_st = avformat_new_stream(fmtctx, codec);
	c = video_st->codec;
	avcodec_get_context_defaults3(c, codec);
  if (!c) {
    dbgprint("%s(%d),%d CAM Could not allocate video codec context!\n",DEBUGARGS,CameraID);
    return -1;
  }
	c->codec_id = AV_CODEC_ID_H264;
	c->width  = m_cols;
	c->height = m_rows;
	c->time_base = (AVRational){1,m_fps};
	c->gop_size = 10;
	c->max_b_frames = 1;
	c->pix_fmt = AV_PIX_FMT_YUV420P;

	if (avcodec_open2(c, codec, NULL) < 0) {
      dbgprint("%s(%d),%d CAM Could not open codec!\n",DEBUGARGS,CameraID);
      return -1;
	}

	m_pYUVFrame = av_frame_alloc();
	yuv420_bytes = avpicture_get_size( AV_PIX_FMT_YUV420P, m_cols, m_rows);
	pYUV_buffer = (uint8_t *)av_malloc(yuv420_bytes*sizeof(uint8_t));
	m_pYUVFrame->format = c->pix_fmt;
	m_pYUVFrame->width  = c->width;
	m_pYUVFrame->height = c->height;
	avpicture_fill((AVPicture*)m_pYUVFrame, pYUV_buffer, AV_PIX_FMT_YUV420P, m_cols, m_rows);
	scxt = sws_getContext(m_cols, m_rows,AV_PIX_FMT_RGB24, m_cols, m_rows,AV_PIX_FMT_YUV420P, 0, 0, 0, 0);
	return 0;
}
Ejemplo n.º 24
0
EC_U32 FFmpegReader::Init()
{
    av_register_all();
    avformat_network_init();
    m_pFormatCtx = avformat_alloc_context();
    if (avformat_open_input(&m_pFormatCtx, m_strMediaPath.ToCStr(), NULL, NULL)!=0)
    {
        return Source_Err_OpenFaild;
    }
    if (avformat_find_stream_info(m_pFormatCtx,NULL)<0)
    {
        return Source_Err_NoStreamInfo;
    }
    if (m_nVideoIndex == -1)
    {
        for (EC_S32 i = 0; i < m_pFormatCtx->nb_streams; i++)
        {
            if (m_pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
            {
                m_nVideoIndex = i;
                break;
            }
        }
        if (m_nVideoIndex == -1)
        {
            secLogE("Can not find video stream.");
        }
    }
    if (m_nAudioIndex == -1)
    {
        for (EC_S32 i = 0; i < m_pFormatCtx->nb_streams; i++)
        {
            if (m_pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
            {
                m_nAudioIndex = i;
                break;
            }
        }
        if (m_nAudioIndex == -1)
        {
            secLogE("Can not find video stream.");
        }
    }

    if ((m_nAudioIndex == -1) && (m_nVideoIndex == -1))
        return Source_Err_NoMediaSource;

    return Source_Err_None;
}
Ejemplo n.º 25
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);
}
Ejemplo n.º 26
0
/**
 * 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;
}
Ejemplo n.º 27
0
// --------------------------------------------------------------------------
// ARDrone::open(IP address of AR.Drone)
// Description  : Initialize the AR.Drone.
// Return value : SUCCESS: 1  FAILURE: 0
// --------------------------------------------------------------------------
int ARDrone::open(const char *ardrone_addr)
{
    // Initialize FFmpeg
    av_register_all();
    avformat_network_init();
    av_log_set_level(AV_LOG_QUIET);

    // Save IP address
    strncpy(ip, ardrone_addr, 16);

    // Get version information
    if (!getVersionInfo()) return 0;
    printf("AR.Drone Ver. %d.%d.%d\n", version.major, version.minor, version.revision);

	//// getVersionInfo() takes too long before realising the drone is not connected
	//// it call tcp open, which makes a socket and tries to connect to it
	//// using the connect method, which has too big of a timeout.
	//// making a smaller, 5 sec timeout before checking the verison to see if drone connected.
	//// if not, return 0
	//if (!version.major) {
	//	// create timeout and wait 5 sec
	//	printf("Waiting for drone to connect...\n");
	//	msleep(5000);
	//	// check again
	//	if (!version.major) return 0;
	//}

    // Initialize AT command
    if (!initCommand()) return 0;

    // Initialize Navdata
    if (!initNavdata()) return 0;

    // Initialize Video
    if (!initVideo()) return 0;

    // Wait for updating state
    //msleep(500);

    // Get configurations
    if (!getConfig()) return 0;

    // Reset emergency
    resetWatchDog();
    resetEmergency();

    return 1;
}
Ejemplo n.º 28
0
int initavdata(struct avdata *av, const char *filepath)
{
	av_register_all();
	avformat_network_init();

	if (openinput(&(av->s), filepath, &(av->vstreamid)) < 0)
		return (-1);

	if (openvideocodec(av->s, &(av->vcodecc),
		av->vstreamid) < 0)
		return (-1);

	av->frame = av_frame_alloc();

	return 0;
}
Ejemplo n.º 29
0
int groove_init(void) {
    av_lockmgr_register(&my_lockmgr_cb);

    srand(time(NULL));

    // register all codecs, demux and protocols
    avcodec_register_all();
    av_register_all();
    avformat_network_init();
    avfilter_register_all();

    should_deinit_network = 1;

    av_log_set_level(AV_LOG_QUIET);
    return 0;
}
Ejemplo n.º 30
0
AVDemuxer::AVDemuxer(const QString& fileName, QObject *parent)
    :QObject(parent),started_(false),eof(false),pkt(new Packet())
    ,ipts(0),stream_idx(-1),audio_stream(-2),video_stream(-2)
    ,subtitle_stream(-2),_is_input(true),format_context(0)
	,a_codec_context(0),v_codec_context(0),_file_name(fileName),master_clock(0)
    ,__interrupt_status(0)
{
    av_register_all();
    avformat_network_init();
    if (!_file_name.isEmpty())
        loadFile(_file_name);

    //default network timeout
    __interrupt_timeout = QTAV_DEFAULT_NETWORK_TIMEOUT;

}