当前位置: 首页>>代码示例>>C++>>正文


C++ dump_format函数代码示例

本文整理汇总了C++中dump_format函数的典型用法代码示例。如果您正苦于以下问题:C++ dump_format函数的具体用法?C++ dump_format怎么用?C++ dump_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dump_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: av_vid_init

int	 av_vid_init(char *file)
{
	int i;

	if (av_open_input_file(&pFormatCtx, file, NULL, 0, NULL)!=0)
		return -1;

	if (av_find_stream_info(pFormatCtx)<0)
		return -1;

	dump_format(pFormatCtx, 0, file, 0);
	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==-1)
		return -1;

	pCodecCtx=pFormatCtx->streams[videoStream]->codec;

	pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
	if (pCodec==NULL)
		return -1;

	if (avcodec_open(pCodecCtx, pCodec)<0)
		return -1;

	pFrame=avcodec_alloc_frame();

	return 0;
}
开发者ID:UIKit0,项目名称:openlase-1,代码行数:34,代码来源:playvid.c

示例2: dump_format

int Encoder::dumpStreamInformation(void) {
  if (! avFormatContext || ! videoFileName) {
    systemLog->sysLog(ERROR, "avcodec context format or videoFileName not initialized. call openVideoFile first !");
    return -1;
  }
  dump_format(avFormatContext, 0, videoFileName, false);

  return 0;
}
开发者ID:spebsd,项目名称:numb,代码行数:9,代码来源:encoder.cpp

示例3: fprintf

//return value
//true : success
//false : fail
bool VideoIO::openInputCodec(void)
{
	//open video file
	///TODO : 20byte lost
	if(av_open_input_file(&pFormatCtx, inputFilename, NULL, 0, NULL) != 0)
	{
		fprintf(stderr, "couldn't open file : %s\n", inputFilename);
		return false;	//couldn't open file
	}

	//retrieve stream information
	if(av_find_stream_info(pFormatCtx) < 0)
	{
		fprintf(stderr, "couldn't find stream information\n");
		return false;
	}

	//dump information about file onto standard error
	dump_format(pFormatCtx, 0, inputFilename, 0);

	//find the first video stream
	videoStream = -1;
	for(unsigned int i = 0 ; i < pFormatCtx->nb_streams ; i++)
	{
		if(pFormatCtx->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO)
		{
			videoStream = i;
			break;
		}
	}
	if(videoStream == -1)
	{
		fprintf(stderr, "didn't find a video stream");
		return false;
	}

	//get a pointer to the reading codec context for the video stream
	pInputCodecCtx = pFormatCtx->streams[videoStream]->codec;

	//find the decoder for the video stream(reaing video)
	pInputCodec = avcodec_find_decoder(pInputCodecCtx->codec_id);
	if(pInputCodec == NULL)
	{
		fprintf(stderr, "Unsupported coded!\n");
		return false;	//codec not found
	}

	//open codec
	if(avcodec_open(pInputCodecCtx, pInputCodec) < 0)
	{
		fprintf(stderr, "could not open codec\n");
		return false;
	}

	//success
	return true;
}
开发者ID:if1live,项目名称:gotoamc,代码行数:60,代码来源:videoIO.cpp

示例4: LOG

void
FFmpegMeta::print(bool isOutFormat)
{
    LOG(ffmpeg, trace, "ffmpeg::dump_format() ...");
    if (isOutFormat) {
        dump_format(_pFormatContext, 0, _pFormatContext->filename, 1);
    }
    else {
        dump_format(_pFormatContext, 0, _pFormatContext->filename, 0);

        AVMetadataTag* tag = 0;
        LOG(ffmpeg, trace, "ffmpeg::av_metadata_get() ...");
        while ((tag = av_metadata_get(_pFormatContext->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
            std::clog << tag->key << ", " << tag->value << std::endl;
//             addTag(tag->key, tag->value);
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:openmm,代码行数:18,代码来源:AvStreamFFmpeg.cpp

示例5: get_file_info

int get_file_info(FileState *file)
{
    if(av_open_input_file(&file->pFormatCtx, file->fileName, NULL, 0, NULL) != 0)
	return -1;
    if(av_find_stream_info(file->pFormatCtx) < 0)
	return -1;
    dump_format(file->pFormatCtx, 0, file->fileName, 0);
    return 0;
}
开发者ID:pkuembedded,项目名称:player,代码行数:9,代码来源:player4.c

示例6: TRACE

status_t
AVFormatReader::Sniff(int32* _streamCount)
{
	TRACE("AVFormatReader::Sniff\n");

	BPositionIO* source = dynamic_cast<BPositionIO*>(Source());
	if (source == NULL) {
		TRACE("  not a BPositionIO, but we need it to be one.\n");
		return B_NOT_SUPPORTED;
	}

	Stream* stream = new(std::nothrow) Stream(source,
		&fSourceLock);
	if (stream == NULL) {
		ERROR("AVFormatReader::Sniff() - failed to allocate Stream\n");
		return B_NO_MEMORY;
	}

	ObjectDeleter<Stream> streamDeleter(stream);

	status_t ret = stream->Open();
	if (ret != B_OK) {
		TRACE("  failed to detect stream: %s\n", strerror(ret));
		return ret;
	}

	delete[] fStreams;
	fStreams = NULL;

	int32 streamCount = stream->CountStreams();
	if (streamCount == 0) {
		TRACE("  failed to detect any streams: %s\n", strerror(ret));
		return B_ERROR;
	}

	fStreams = new(std::nothrow) Stream*[streamCount];
	if (fStreams == NULL) {
		ERROR("AVFormatReader::Sniff() - failed to allocate streams\n");
		return B_NO_MEMORY;
	}

	memset(fStreams, 0, sizeof(Stream*) * streamCount);
	fStreams[0] = stream;
	streamDeleter.Detach();

	#ifdef TRACE_AVFORMAT_READER
	dump_format(const_cast<AVFormatContext*>(stream->Context()), 0, "", 0);
	#endif

	if (_streamCount != NULL)
		*_streamCount = streamCount;

	return B_OK;
}
开发者ID:RAZVOR,项目名称:haiku,代码行数:54,代码来源:AVFormatReader.cpp

示例7: main

int main(int argc, char *argv[])
{
  av_register_all();  
  AVFormatContext *pFormatCtx;
  AVCodecContext *pCodecCtx;
  AVCodec *pCodec;
  int audioStream = -1;
  
  // Open file
  if (av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL) != 0)
    return -1; // Couldn't open file
  printf("opened %s\n", argv[1]);
  
  // Get stream information
  if (av_find_stream_info(pFormatCtx) < 0)
    return -1; // No stream information found
  
  // Debugging function
  dump_format(pFormatCtx, 0, argv[1], 0);
  
  // Find the first audio stream
  for (int i = 0; i < pFormatCtx->nb_streams; i++)
  {
    if (pFormatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO)
    {
      audioStream = i;
      break;
    }
  }
  if (audioStream == -1)
    return -1; // No audio stream found
  
  // Return a pointer to the codec context for the video stream
  pCodecCtx = pFormatCtx->streams[audioStream]->codec;
  
  // Find the correct decoder
  pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
  if (pCodec == NULL)
  {
    printf("Unsupported codec!\n");
    return -1; // Codec not found
  }
  printf("found codec %d\n", pCodecCtx->codec_id);
  
  // Open correct codec
  if (avcodec_open(pCodecCtx, pCodec) < 0)
    return -1; // Couldn't open codec
  printf("opened codec %d\n", pCodecCtx->codec_id);
  
}
开发者ID:Bocom,项目名称:prismriver,代码行数:50,代码来源:main.cpp

示例8: av_register_all

int FFMpegEncoder::init(FFMpegEncodeProfile *myProfile)
{
	av_register_all();
	profile = *myProfile;
	
	videoEncodeBufSize = 1024000;
	videoEncodeBuf = (unsigned char*)malloc(videoEncodeBufSize);
	if (videoEncodeBuf == NULL)
		return ERR_ALLOC_VIDEO_BUF;

	audioEncodeBufSize = 4*128*1024;
	audioEncodeBuf = (unsigned char*)malloc(audioEncodeBufSize);
	if (audioEncodeBuf == NULL)
		return ERR_ALLOC_AUDIO_BUF;
	    
	pFormatCtx = avformat_alloc_context();
	
	int ret = -1;
	ret = configOutput();
	if (ret) 
	{
		printf("error configuring output!\n");
		return ret;
	}
	
	videoStream = NULL;
	ret = configVideoStream();
	if (ret) 
	{
		printf("error configuring video!\n");
		return ret;
	}
	
	audioStream = NULL;
	ret = configAudioStream();
	if (ret) 
	{
		printf("error configuring audio!\n");
		return ret;
	}

	av_set_parameters(pFormatCtx, NULL);
	dump_format(pFormatCtx, 0, (char*)profile.outputFilename, 1);
    
	av_write_header(pFormatCtx);
	audioClock = 0;
	videoClock = 0;
	return 0;
	//
}
开发者ID:jdzyzh,项目名称:ffmpeg-wrapper,代码行数:50,代码来源:FFMpegEncoder.cpp

示例9: guess_format

bool CFFMPEGLoader::CreateMovie(const char *filename, const AVOutputFormat *format, const AVCodecContext *VideoCon, const AVCodecContext *AudioCon) {
    if(!filename)
        return false;

    AVOutputFormat *fmt;
    //*fmt=*format;
    fmt = guess_format(NULL, filename, NULL);

    pFormatCon = av_alloc_format_context();
    if(!pFormatCon) {
        cout<<"Error while allocating format context\n";
        return false;
    }
    bOutput=true;
    strcpy(pFormatCon->filename,filename);

    pFormatCon->oformat=fmt;
    pAudioStream=pVideoStream=NULL;

    if (fmt->video_codec != CODEC_ID_NONE) {
        pVideoStream = add_video_stream(pFormatCon, fmt->video_codec,VideoCon);
    }
    if (fmt->audio_codec != CODEC_ID_NONE) {
        pAudioStream = add_audio_stream(pFormatCon, fmt->audio_codec,AudioCon);
    }

    if (av_set_parameters(pFormatCon, NULL) < 0) {
        cout<<"Invalid output format parameters\n";
        return false;
    }

    if (pVideoStream)
        open_stream(pFormatCon, pVideoStream);
    if (pAudioStream)
        open_stream(pFormatCon, pAudioStream);

    dump_format(pFormatCon, 0, filename, 1);

    if (!(fmt->flags & AVFMT_NOFILE)) {
        if (url_fopen(&pFormatCon->pb, filename, URL_WRONLY) < 0) {
            cout<<"Could not open '%s'"<<filename<<endl;
            return false;
        }
    }

    /* write the stream header, if any */
    av_write_header(pFormatCon);
    return true;
}
开发者ID:arpu,项目名称:adscanner,代码行数:49,代码来源:ffmpeg_movie.cpp

示例10: open_file

static AVFormatContext *
open_file(const char *filename)
{
    AVFormatContext *afc;
    int err = av_open_input_file(&afc, filename, NULL, 0, NULL);

    if (!err)
        err = av_find_stream_info(afc);

    if (err < 0) {
        fprintf(stderr, "%s: lavf error %d\n", filename, err);
        exit(1);
    }

    dump_format(afc, 0, filename, 0);

    return afc;
}
开发者ID:robclark,项目名称:omapfbplay,代码行数:18,代码来源:omapfbplay.c

示例11: out

status_t 
ProducerNode::PrepareToConnect(
				const media_source & what,
				const media_destination & where,
				media_format * format,
				media_source * out_source,
				char * out_name)
{

	out("ProducerNode::PrepareToConnect\n");

	if (mOutput.source != what)
		return B_MEDIA_BAD_SOURCE;
	
	if (mOutput.destination != media_destination::null)
		return B_MEDIA_ALREADY_CONNECTED;

	if (format == NULL || out_source == NULL || out_name == NULL)
		return B_BAD_VALUE;

#if 0		
	ASSERT(mOutputEnabled == false);

	trace("old format:\n");
	dump_format(format);

	status_t status;
	
	status = specialize_format_to_inputformat(format);
	if (status != B_OK)
		return status;

#endif


	*out_source = mOutput.source;
	strcpy(out_name,mOutput.name);
	//mOutput.destination = where; //really now? fixme
	return B_OK;
}
开发者ID:BackupTheBerlios,项目名称:nemo,代码行数:40,代码来源:ProducerNode.cpp

示例12: av_find_input_format

void SWDecoder::decodeStream()
{
	int res = 0;
	if(!res) 
	{
		std::cout << "opening virtual file" << std::endl;
		AVInputFormat *pFmt = av_find_input_format("mpegts");
		res = av_open_input_file(&mState.pFormatCtx, boost::str(boost::format("dvrdecode://%p") % this).c_str(), pFmt, 0, 0);
		if(res)
		{
			std::cerr << boost::format("Error opening pseudo decoder file:%s") % strerror(errno) << std::endl;
		} else
		{
			std::cout << "finding virtual stream info" << std::endl;

			res = av_find_stream_info(mState.pFormatCtx);
			if(res)
			{
				std::cerr << boost::format("Error finding stream info:%s") % strerror(errno) << std::endl;
			}
			else
			{
				std::cout << "trying to dump format" << std::endl;
				dump_format(mState.pFormatCtx, 0, boost::str(boost::format("dvrdecode://%p") % this).c_str(), false);
				std::cout << "recognized format" << std::endl;
			}
			if(!res)
			{
				decodeFrames();
			}
		}

		if(mState.pFormatCtx)
		{
			av_close_input_file(mState.pFormatCtx);
		}
	}	
}
开发者ID:vitmod,项目名称:neutrino-hd-pc-experiments,代码行数:38,代码来源:decodethread.cpp

示例13: open_input_file

static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
{
    int err, i;
    AVFormatContext *fmt_ctx;

    fmt_ctx = avformat_alloc_context();
    set_context_opts(fmt_ctx, avformat_opts, AV_OPT_FLAG_DECODING_PARAM, NULL);

    if ((err = av_open_input_file(&fmt_ctx, filename, iformat, 0, NULL)) < 0) {
        print_error(filename, err);
        return err;
    }

    /* fill the streams in the format context */
    if ((err = av_find_stream_info(fmt_ctx)) < 0) {
        print_error(filename, err);
        return err;
    }

    dump_format(fmt_ctx, 0, filename, 0);

    /* bind a decoder to each input stream */
    for (i = 0; i < fmt_ctx->nb_streams; i++) {
        AVStream *stream = fmt_ctx->streams[i];
        AVCodec *codec;

        if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) {
            fprintf(stderr, "Unsupported codec (id=%d) for input stream %d\n",
                    stream->codec->codec_id, stream->index);
        } else if (avcodec_open(stream->codec, codec) < 0) {
            fprintf(stderr, "Error while opening codec for input stream %d\n",
                    stream->index);
        }
    }

    *fmt_ctx_ptr = fmt_ctx;
    return 0;
}
开发者ID:Gemini88,项目名称:xbmc-1,代码行数:38,代码来源:ffprobe.c

示例14: scan_metadata_ffmpeg

int
scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
{
  AVFormatContext *ctx;
  const struct metadata_map *extra_md_map;
  enum CodecID codec_id;
  enum CodecID video_codec_id;
  enum CodecID audio_codec_id;
  AVStream *video_stream;
  AVStream *audio_stream;
  int mdcount;
  int i;
  int ret;

  ctx = NULL;

#if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 3)
  ret = avformat_open_input(&ctx, file, NULL, NULL);
#else
  ret = av_open_input_file(&ctx, file, NULL, 0, NULL);
#endif
  if (ret != 0)
    {
      DPRINTF(E_WARN, L_SCAN, "Cannot open media file '%s': %s\n", file, strerror(AVUNERROR(ret)));

      return -1;
    }

  ret = av_find_stream_info(ctx);
  if (ret < 0)
    {
      DPRINTF(E_WARN, L_SCAN, "Cannot get stream info: %s\n", strerror(AVUNERROR(ret)));

      av_close_input_file(ctx);
      return -1;
    }

#if 0
  /* Dump input format as determined by ffmpeg */
# if LIBAVFORMAT_VERSION_MAJOR >= 52 || (LIBAVFORMAT_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 101)
  av_dump_format(ctx, 0, file, 0);
# else
  dump_format(ctx, 0, file, FALSE);
# endif
#endif

  DPRINTF(E_DBG, L_SCAN, "File has %d streams\n", ctx->nb_streams);

  /* Extract codec IDs, check for video */
  video_codec_id = CODEC_ID_NONE;
  video_stream = NULL;

  audio_codec_id = CODEC_ID_NONE;
  audio_stream = NULL;

  for (i = 0; i < ctx->nb_streams; i++)
    {
      switch (ctx->streams[i]->codec->codec_type)
	{
#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 64)
	  case AVMEDIA_TYPE_VIDEO:
#else
	  case CODEC_TYPE_VIDEO:
#endif
	    if (!video_stream)
	      {
		DPRINTF(E_DBG, L_SCAN, "File has video (stream %d)\n", i);

		mfi->has_video = 1;
		video_stream = ctx->streams[i];
		video_codec_id = video_stream->codec->codec_id;
	      }
	    break;

#if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 64)
	  case AVMEDIA_TYPE_AUDIO:
#else
	  case CODEC_TYPE_AUDIO:
#endif
	    if (!audio_stream)
	      {
		audio_stream = ctx->streams[i];
		audio_codec_id = audio_stream->codec->codec_id;
	      } 
	    break;

	  default:
	    break;
	}
    }

  if (audio_codec_id == CODEC_ID_NONE)
    {
      DPRINTF(E_DBG, L_SCAN, "File has no audio streams, discarding\n");

      av_close_input_file(ctx);
      return -1;
    }

  /* Common media information */
//.........这里部分代码省略.........
开发者ID:jjtheninth,项目名称:forked-daapd,代码行数:101,代码来源:filescanner_ffmpeg.c

示例15: avdevice_register_all

bool FFmpegDecoder::open(const std::string & filename, FFmpegParameters* parameters)
{
    try
    {
        // Open video file
        AVFormatContext * p_format_context = 0;

        if (filename.compare(0, 5, "/dev/")==0)
        {
            avdevice_register_all();
        
            OSG_NOTICE<<"Attempting to stream "<<filename<<std::endl;

            AVFormatParameters formatParams;
            memset(&formatParams, 0, sizeof(AVFormatParameters));
            AVInputFormat *iformat;

            formatParams.channel = 0;
            formatParams.standard = 0;
#if 1
            formatParams.width = 320;
            formatParams.height = 240;
#else
            formatParams.width = 640;
            formatParams.height = 480;
#endif            
            formatParams.time_base.num = 1;
            formatParams.time_base.den = 30;

            std::string format = "video4linux2";
            iformat = av_find_input_format(format.c_str());
            
            if (iformat)
            {
                OSG_NOTICE<<"Found input format: "<<format<<std::endl;
            }
            else
            {
                OSG_NOTICE<<"Failed to find input format: "<<format<<std::endl;
            }

            int error = av_open_input_file(&p_format_context, filename.c_str(), iformat, 0, &formatParams);
            if (error != 0)
            {
                std::string error_str;
                switch (error)
                {
                    //case AVERROR_UNKNOWN: error_str = "AVERROR_UNKNOWN"; break;   // same value as AVERROR_INVALIDDATA
                    case AVERROR_IO: error_str = "AVERROR_IO"; break;
                    case AVERROR_NUMEXPECTED: error_str = "AVERROR_NUMEXPECTED"; break;
                    case AVERROR_INVALIDDATA: error_str = "AVERROR_INVALIDDATA"; break;
                    case AVERROR_NOMEM: error_str = "AVERROR_NOMEM"; break;
                    case AVERROR_NOFMT: error_str = "AVERROR_NOFMT"; break;
                    case AVERROR_NOTSUPP: error_str = "AVERROR_NOTSUPP"; break;
                    case AVERROR_NOENT: error_str = "AVERROR_NOENT"; break;
                    case AVERROR_PATCHWELCOME: error_str = "AVERROR_PATCHWELCOME"; break;
                    default: error_str = "Unknown error"; break;
                }

                throw std::runtime_error("av_open_input_file() failed : " + error_str);
            }
        }
        else
        {
            AVInputFormat* av_format = (parameters ? parameters->getFormat() : 0);
            AVFormatParameters* av_params = (parameters ? parameters->getFormatParameter() : 0);
            if (av_open_input_file(&p_format_context, filename.c_str(), av_format, 0, av_params) !=0 )
                throw std::runtime_error("av_open_input_file() failed");
        }
        
        m_format_context.reset(p_format_context);

        // Retrieve stream info
        if (av_find_stream_info(p_format_context) < 0)
            throw std::runtime_error("av_find_stream_info() failed");

        m_duration = double(m_format_context->duration) / AV_TIME_BASE;
        m_start = double(m_format_context->start_time) / AV_TIME_BASE;

        // TODO move this elsewhere
        m_clocks.reset(m_start);

        // Dump info to stderr
        dump_format(p_format_context, 0, filename.c_str(), false);

        // Find and open the first video and audio streams (note that audio stream is optional and only opened if possible)

        findVideoStream();
        findAudioStream();

        m_video_decoder.open(m_video_stream);

        try
        {
            m_audio_decoder.open(m_audio_stream);
        }

        catch (const std::runtime_error & error)
        {
            OSG_WARN << "FFmpegImageStream::open audio failed, audio stream will be disabled: " << error.what() << std::endl;
//.........这里部分代码省略.........
开发者ID:aalex,项目名称:osg,代码行数:101,代码来源:FFmpegDecoder.cpp


注:本文中的dump_format函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。