コード例 #1
0
VideoFFmpegWriter::VideoFFmpegWriter()
	: FFmpeg             ( )
	, FFmpegPreset       ( )
	, _avformatOptions   ( NULL )
	, _sws_context       ( NULL )
	, _stream            ( NULL )
	, _codec             ( NULL )
	, _ofmt              ( NULL )
	, _error             ( IGNORE_FINISH )
	, _filename          ( "" )
	, _width             ( 0 )
	, _height            ( 0 )
	, _aspectRatio       ( 1 )
	, _out_pixelFormat   ( PIX_FMT_YUV420P )
	, _fps               ( 25.0f )
	, _formatName        ( "" )
	, _codecName         ( "" )
	, _videoPresetName   ( "" )
	, _bitRate           ( 400000 )
	, _bitRateTolerance  ( 4000 * 10000 )
	, _gopSize           ( 12 )
	, _bFrames           ( 0 )
	, _mbDecision        ( FF_MB_DECISION_SIMPLE )
{
	av_log_set_level( AV_LOG_WARNING );
	av_register_all();

	AVOutputFormat* fmt = av_oformat_next( NULL );
	while( fmt )
	{
		if( fmt->video_codec != CODEC_ID_NONE )
		{
			if( fmt->long_name )
			{
				_formatsLongNames.push_back( std::string( fmt->long_name ) + std::string( " (" ) + std::string( fmt->name ) + std::string( ")" ) );
				_formatsShortNames.push_back( std::string( fmt->name ) );
			}
		}
		fmt = av_oformat_next( fmt );
	}

	AVCodec* c = av_codec_next( NULL );
	while( c )
	{
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT( 53, 34, 0 )
		if( c->type == AVMEDIA_TYPE_VIDEO && c->encode2 )
#else
		if( c->type == AVMEDIA_TYPE_VIDEO && c->encode )
#endif
		{
			if( c->long_name )
			{
				_codecsLongNames.push_back( std::string( c->long_name ) );
				_codecsShortNames.push_back( std::string( c->name ) );
			}
		}
		c = av_codec_next( c );
	}
}
コード例 #2
0
VideoFFmpegWriter::VideoFFmpegWriter()
	: _avformatOptions( 0 )
	, _sws_context( NULL )
	, _stream( 0 )
	, _error( IGNORE_FINISH )
	, _filename( "" )
	, _width( 0 )
	, _height( 0 )
	, _aspectRatio( 1 )
	, _out_pixelFormat( PIX_FMT_YUV420P )
	, _fps( 25.0f )
	, _format( "default" )
	, _codec( "default" )
	, _bitRate( 400000 )
	, _bitRateTolerance( 4000 * 10000 )
	, _gopSize( 12 )
	, _bFrames( 0 )
	, _mbDecision( FF_MB_DECISION_SIMPLE )
{
	av_log_set_level( AV_LOG_WARNING );
	av_register_all();

	for( int i = 0; i < CODEC_TYPE_NB; ++i )
		_avctxOptions[i] = avcodec_alloc_context2( CodecType( i ) );

	_formatsLongNames.push_back( std::string( "default" ) );
	_formatsShortNames.push_back( std::string(  "default" ) );
	AVOutputFormat* fmt = av_oformat_next( NULL );
	while( fmt )
	{
		if( fmt->video_codec != CODEC_ID_NONE )
		{
			if( fmt->long_name )
			{
				_formatsLongNames.push_back( std::string( fmt->long_name ) + std::string( " (" ) + std::string( fmt->name ) + std::string( ")" ) );
				_formatsShortNames.push_back( std::string( fmt->name ) );
			}
		}
		fmt = av_oformat_next( fmt );
	}

	_codecsLongNames.push_back( std::string( "default" ) );
	_codecsShortNames.push_back( std::string( "default" ) );
	AVCodec* c = av_codec_next( NULL );
	while( c )
	{
		if( c->type == CODEC_TYPE_VIDEO && c->encode )
		{
			if( c->long_name )
			{
				_codecsLongNames.push_back( std::string( c->long_name ) );
				_codecsShortNames.push_back( std::string( c->name ) );
			}
		}
		c = av_codec_next( c );
	}
}
コード例 #3
0
ファイル: options.c プロジェクト: 15806905685/FFmpeg
static const AVClass *codec_child_class_next(const AVClass *prev)
{
    AVCodec *c = NULL;

    /* find the codec that corresponds to prev */
    while (prev && (c = av_codec_next(c)))
        if (c->priv_class == prev)
            break;

    /* find next codec with priv options */
    while (c = av_codec_next(c))
        if (c->priv_class)
            return c->priv_class;
    return NULL;
}
コード例 #4
0
ファイル: genericaudio.cpp プロジェクト: kostyll/justcutit
static AVCodec* findCodec(AVCodecID id, AVSampleFormat fmt)
{
	for(AVCodec* p = av_codec_next(0); p; p = av_codec_next(p))
	{
		if(p->id != id || (!p->encode && !p->encode2))
			continue;
		
		for(const AVSampleFormat* f = p->sample_fmts; *f != -1; ++f)
		{
			if(*f == fmt)
				return p;
		}
	}
	
	return 0;
}
コード例 #5
0
ファイル: cmdutils.c プロジェクト: kaone3/vsmm
int opt_default(const char *opt, const char *arg){
    int type;
    int ret= 0;
    const AVOption *o= NULL;
    int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};

    for(type=0; *avcodec_opts && type<AVMEDIA_TYPE_NB && ret>= 0; type++){
        const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]);
        if(o2)
            ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o);
    }
    if(!o && avformat_opts)
        ret = av_set_string3(avformat_opts, opt, arg, 1, &o);
    if(!o && sws_opts)
        ret = av_set_string3(sws_opts, opt, arg, 1, &o);
    if(!o){
        if (opt[0] == 'a' && avcodec_opts[AVMEDIA_TYPE_AUDIO])
            ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o);
        else if(opt[0] == 'v' && avcodec_opts[AVMEDIA_TYPE_VIDEO])
            ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o);
        else if(opt[0] == 's' && avcodec_opts[AVMEDIA_TYPE_SUBTITLE])
            ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o);
    }
    if (o && ret < 0) {
        fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt);
        exit(1);
    }
    if (!o) {
        AVCodec *p = NULL;
        AVOutputFormat *oformat = NULL;
        while ((p=av_codec_next(p))){
            AVClass *c= p->priv_class;
            if(c && av_find_opt(&c, opt, NULL, 0, 0))
                break;
        }
        if (!p) {
            while ((oformat = av_oformat_next(oformat))) {
                const AVClass *c = oformat->priv_class;
                if (c && av_find_opt(&c, opt, NULL, 0, 0))
                    break;
            }
        }
        if(!p && !oformat){
            fprintf(stderr, "Unrecognized option '%s'\n", opt);
            exit(1);
        }
    }

//    av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avcodec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL));

    //FIXME we should always use avcodec_opts, ... for storing options so there will not be any need to keep track of what i set over this
    opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1));
    opt_values[opt_name_count]= o ? NULL : arg;
    opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
    opt_names[opt_name_count++]= o ? o->name : opt;

    if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug))
        av_log_set_level(AV_LOG_DEBUG);
    return 0;
}
コード例 #6
0
ファイル: FFMPEGInvoker.cpp プロジェクト: juehv/uscxml
Data FFMPEGInvoker::getDataModelVariables() {
    Data data;

    AVCodec* codec = NULL;
    while((codec = av_codec_next(codec))) {
        AVCodec* codecInst = avcodec_find_encoder(codec->id);
        if (!codecInst)
            continue;

        switch (codec->type) {
        case AVMEDIA_TYPE_VIDEO: {
            Data codecData;
            codecData.compound["name"] = Data(codec->name, Data::VERBATIM);
            codecData.compound["longName"] = Data(codec->long_name, Data::VERBATIM);
            data.compound["video"].compound[codec->name] = codecData;
            break;
        }
        case AVMEDIA_TYPE_AUDIO: {
            Data codecData;
            codecData.compound["name"] = Data(codec->name, Data::VERBATIM);
            codecData.compound["longName"] = Data(codec->long_name, Data::VERBATIM);
            data.compound["audio"].compound[codec->name] = codecData;
            break;
        }
        default:
            break;
        }
    }

    return data;
}
コード例 #7
0
ファイル: AddonCallbacksCodec.cpp プロジェクト: 0xheart0/xbmc
  CCodecIds(void)
  {
    // get ids and names
    AVCodec* codec = NULL;
    xbmc_codec_t tmp;
    while ((codec = av_codec_next(codec)))
    {
      if (av_codec_is_decoder(codec))
      {
        tmp.codec_type = (xbmc_codec_type_t)codec->type;
        tmp.codec_id   = codec->id;

        std::string strUpperCodecName = codec->name;
        StringUtils::ToUpper(strUpperCodecName);

        m_lookup.insert(std::make_pair(strUpperCodecName, tmp));
      }
    }

    // teletext is not returned by av_codec_next. we got our own decoder
    tmp.codec_type = XBMC_CODEC_TYPE_SUBTITLE;
    tmp.codec_id   = AV_CODEC_ID_DVB_TELETEXT;
    m_lookup.insert(std::make_pair("TELETEXT", tmp));

    // rds is not returned by av_codec_next. we got our own decoder
    tmp.codec_type = XBMC_CODEC_TYPE_RDS;
    tmp.codec_id   = AV_CODEC_ID_NONE;
    m_lookup.insert(std::make_pair("RDS", tmp));
  }
コード例 #8
0
/**
 * com.leixiaohua1020.sffmpegandroidhelloworld.MainActivity.avcodecinfo()
 * AVCodec Support Information
 */
JNIEXPORT jstring Java_com_leixiaohua1020_sffmpegandroidhelloworld_MainActivity_avcodecinfo(JNIEnv *env, jobject obj)
{
	char info[40000] = { 0 };

	av_register_all();

	AVCodec *c_temp = av_codec_next(NULL);

	while(c_temp!=NULL){
		if (c_temp->decode!=NULL){
			sprintf(info, "%s[Dec]", info);
		}
		else{
			sprintf(info, "%s[Enc]", info);
		}
		switch (c_temp->type){
		case AVMEDIA_TYPE_VIDEO:
			sprintf(info, "%s[Video]", info);
			break;
		case AVMEDIA_TYPE_AUDIO:
			sprintf(info, "%s[Audio]", info);
			break;
		default:
			sprintf(info, "%s[Other]", info);
			break;
		}
		sprintf(info, "%s[%10s]\n", info, c_temp->name);

		
		c_temp=c_temp->next;
	}
	//LOGE("%s", info);

	return (*env)->NewStringUTF(env, info);
}
コード例 #9
0
ファイル: common_ff.cpp プロジェクト: hftom/MachinTruc
bool FFmpegCommon::initFFmpeg()
{
	if ( !initDone ) {
		av_lockmgr_register( lockManager );
		avcodec_register_all();
		av_register_all();
		avfilter_register_all();
		initDone = true;
		
		/*const AVCodecDescriptor *desc = NULL;
		desc = avcodec_descriptor_next( desc );
		while ( desc ) {
			qDebug() << desc->name;
			//qDebug() << "	" << desc->long_name;
			desc = avcodec_descriptor_next( desc );
		}*/
		
		/*const AVOutputFormat *format = NULL;
		format = av_oformat_next( format );
		while ( format ) {
			qDebug() << format->name << avcodec_get_name( format->video_codec ) << avcodec_get_name( format->audio_codec );
			format = av_oformat_next( format );
		}*/
		
		h264CodecNames << "default";
		hevcCodecNames << "default";
		
		AVCodec * codec = av_codec_next(NULL);
		while (codec != NULL) {
			if (av_codec_is_encoder(codec) && codec->type == AVMEDIA_TYPE_VIDEO) {
				QString cn = codec->name;
				if (cn.contains("264")) {
					qDebug() << codec->name;
					h264CodecNames << codec->name;
				}
				else if (cn.contains("hevc") || cn.contains("265")) {
					qDebug() << codec->name;
					hevcCodecNames << codec->name;
				}
			}
			codec = av_codec_next(codec);
		}
	}

	return initDone;
}
コード例 #10
0
ファイル: ff-util.c プロジェクト: AhmedAbdulSalam5/obs-studio
static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev)
{
    while ((prev = av_codec_next(prev))) {
        if (prev->id == id && av_codec_is_encoder(prev))
            return prev;
    }

    return NULL;
}
コード例 #11
0
status_t
build_decoder_formats(media_format** _formats, size_t* _count)
{
	BMediaFormats mediaFormats;
	if (mediaFormats.InitCheck() != B_OK)
		return B_ERROR;

	int32 index = 0;
	AVCodec* codec = NULL;
	while ((codec = av_codec_next(codec)) != NULL) {
		if (index >= sMaxFormatCount) {
			fprintf(stderr, "Maximum format count reached for auto-generated "
				"AVCodec to media_format mapping, but there are still more "
				"AVCodecs compiled into libavcodec!\n");
			break;
		}
		media_format format;
		// Determine media type
		switch (codec->type) {
			case AVMEDIA_TYPE_VIDEO:
				format.type = B_MEDIA_ENCODED_VIDEO;
				break;
			case AVMEDIA_TYPE_AUDIO:
				format.type = B_MEDIA_ENCODED_AUDIO;
				break;
			default:
				// ignore this AVCodec
				continue;
		}

		media_format_description description;
		memset(&description, 0, sizeof(description));

		// Hard-code everything to B_MISC_FORMAT_FAMILY to ease matching
		// later on.
		description.family = B_MISC_FORMAT_FAMILY;
		description.u.misc.file_format = 'ffmp';
		description.u.misc.codec = codec->id;

		format.require_flags = 0;
		format.deny_flags = B_MEDIA_MAUI_UNDEFINED_FLAGS;

		if (mediaFormats.MakeFormatFor(&description, 1, &format) != B_OK)
			return B_ERROR;

		gAVCodecFormats[index] = format;

		index++;
	}

	*_formats = gAVCodecFormats;
	*_count = index;

	return B_OK;
}
コード例 #12
0
ファイル: grabber_ffmpeg.c プロジェクト: GeeXboX/libvalhalla
static const char *
grabber_ffmpeg_codec_name (enum AVCodecID id)
{
  AVCodec *avc = NULL;

  while ((avc = av_codec_next (avc)))
    if (avc->id == id)
      return avc->long_name ? avc->long_name : avc->name;

  return NULL;
}
コード例 #13
0
ファイル: IoAVCodec.c プロジェクト: BMeph/io
IoObject *IoAVCodec_encodeCodecNames(IoAVCodec *self, IoObject *locals, IoMessage *m)
{
	/*doc AVCodec encodeCodecNames
	Returns a list of strings with the names of the encode codecs.
	*/

	AVCodec *p = av_codec_next(NULL);
	IoList *names = IoList_new(IOSTATE);

	while (p)
	{
		if (p->encode)
		{
			IoList_rawAppend_(names, IOSYMBOL(p->name));
		}

        p = av_codec_next(p);
	}

	return names;
}
コード例 #14
0
ファイル: libde265dec.c プロジェクト: Ivansss/libde265-ffmpeg
static void ff_libde265dec_unregister_codecs(enum AVCodecID id)
{
    AVCodec *prev = NULL;
    AVCodec *codec = av_codec_next(NULL);
    while (codec != NULL) {
        AVCodec *next = av_codec_next(codec);
        if (codec->id == id) {
            if (prev != NULL) {
                // remove previously registered codec with the same id
                // NOTE: this won't work for the first registered codec
                //       which is fine for this use case
                prev->next = next;
            } else {
                prev = codec;
            }
        } else {
            prev = codec;
        }
        codec = next;
    }
}
コード例 #15
0
ファイル: av_common.c プロジェクト: rcombs/mpv
// (Abuses the decoder list data structures.)
void mp_add_lavc_encoders(struct mp_decoder_list *list)
{
    AVCodec *cur = NULL;
    for (;;) {
        cur = av_codec_next(cur);
        if (!cur)
            break;
        if (av_codec_is_encoder(cur)) {
            mp_add_decoder(list, "lavc", mp_codec_from_av_codec_id(cur->id),
                           cur->name, cur->long_name);
        }
    }
}
コード例 #16
0
ファイル: av_common.c プロジェクト: rcombs/mpv
void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type)
{
    AVCodec *cur = NULL;
    for (;;) {
        cur = av_codec_next(cur);
        if (!cur)
            break;
        if (av_codec_is_decoder(cur) && cur->type == type && !is_crap(cur)) {
            mp_add_decoder(list, "lavc", mp_codec_from_av_codec_id(cur->id),
                           cur->name, cur->long_name);
        }
    }
}
コード例 #17
0
ファイル: AudioEncoder.cpp プロジェクト: SvetZari/QtAV
QStringList AudioEncoder::supportedCodecs()
{
    static QStringList codecs;
    if (!codecs.isEmpty())
        return codecs;
    avcodec_register_all();
    AVCodec* c = NULL;
    while ((c=av_codec_next(c))) {
        if (!av_codec_is_encoder(c) || c->type != AVMEDIA_TYPE_AUDIO)
            continue;
        codecs.append(QString::fromLatin1(c->name));
    }
    return codecs;
}
コード例 #18
0
ファイル: util.cpp プロジェクト: amoylel/avTranscoder
OptionArrayMap getAudioCodecOptions()
{
    OptionArrayMap audioCodecOptions;

    AVCodec* codec = av_codec_next( NULL );

    // iterate on codecs
    while( codec )
    {
        // add only audio codec
        if( codec->type == AVMEDIA_TYPE_AUDIO )
        {
            if( codec->priv_class )
            {
                std::string audioCodecName( codec->name );
                OptionArray options;
                loadOptions( options, (void*)&codec->priv_class, 0  );
                audioCodecOptions.insert( std::make_pair( audioCodecName, options ) );
            }
        }
        codec = av_codec_next( codec );
    }
    return audioCodecOptions;
}
コード例 #19
0
ファイル: utils.c プロジェクト: 15806905685/FFmpeg
int main(void){
    AVCodec *codec = NULL;
    int ret = 0;
    avcodec_register_all();

    while (codec = av_codec_next(codec)) {
        if (av_codec_is_encoder(codec)) {
            if (codec->type == AVMEDIA_TYPE_AUDIO) {
                if (!codec->sample_fmts) {
                    av_log(NULL, AV_LOG_FATAL, "Encoder %s is missing the sample_fmts field\n", codec->name);
                    ret = 1;
                }
            }
        }
    }
    return ret;
}
コード例 #20
0
ファイル: options.c プロジェクト: eugenehp/ffmbc
static const AVOption *opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
{
    AVCodecContext *s = obj;
    AVCodec        *c = NULL;

    if (s->priv_data) {
        if (s->codec->priv_class)
            return av_opt_find(s->priv_data, name, unit, opt_flags, search_flags);
        return NULL;
    }

    while ((c = av_codec_next(c))) {
        const AVOption *o;
        if (c->priv_class && (o = av_opt_find(&c->priv_class, name, unit, opt_flags, search_flags)))
            return o;
    }
    return NULL;
}
コード例 #21
0
 const std::list<Demuxer::DecoderInfo>& Demuxer::getAvailableDecoders()
 {
     AVCodec* codec = nullptr;
     loadFFmpeg();
     
     if (g_availableDecoders.empty())
     {
         while (nullptr != (codec = av_codec_next(codec)))
         {
             DecoderInfo info =
             {
                 avcodec_get_name(codec->id),
                 codec->long_name,
                 AVMediaTypeToMediaType(codec->type)
             };
             
             g_availableDecoders.push_back(info);
         }
     }
     
     return g_availableDecoders;
 }
コード例 #22
0
ファイル: util.cpp プロジェクト: amoylel/avTranscoder
NamesArray getAudioCodecsNames()
{
    NamesArray audioCodecsNames;

    AVCodec* c = NULL;
    while( ( c = av_codec_next( c ) ) != NULL )
    {
        if( c->type == AVMEDIA_TYPE_AUDIO )
        {
            if( ! c->name && ! c->long_name )
                continue;

            std::pair< std::string, std::string > codecNames( std::string( c->name ? c->name : "" ), std::string( c->long_name ? c->long_name : "" ) );

            // skip duplicates
            if( std::find( audioCodecsNames.begin(), audioCodecsNames.end(), codecNames ) != audioCodecsNames.end() )
                continue;

            audioCodecsNames.push_back( codecNames );
        }
    }
    return audioCodecsNames;
}
コード例 #23
0
ファイル: mediasink.cpp プロジェクト: hpfn/webcamoid
QStringList MediaSink::supportedCodecs(const QString &format,
                                       const QString &type)
{
    AVOutputFormat *outputFormat = av_guess_format(format.toStdString().c_str(),
                                                   NULL,
                                                   NULL);

    if (!outputFormat)
        return QStringList();

    QStringList codecs;
    AVCodec *codec = NULL;

    while ((codec = av_codec_next(codec))) {
        if ((type.isEmpty() || mediaTypeToStr->value(codec->type) == type)
            && av_codec_is_encoder(codec)
            && avformat_query_codec(outputFormat,
                                    codec->id,
                                    FF_COMPLIANCE_NORMAL) > 0)
            codecs << QString(codec->name);
    }

    return codecs;
}
コード例 #24
0
JNIEXPORT jstring JNICALL Java_com_pl_asndktest_jni_NdkTest_avcodecinfo
  (JNIEnv * env, jobject thiz)
{
    char info[40000] = { 0 };  
  
    av_register_all();  
  
    AVCodec *c_temp = av_codec_next(NULL);  
  
    while(c_temp!=NULL){  
        if (c_temp->decode!=NULL){  
            sprintf(info, "%s[Dec]", info);  
        }  
        else{  
            sprintf(info, "%s[Enc]", info);  
        }  
        switch (c_temp->type){  
        case AVMEDIA_TYPE_VIDEO:  
            sprintf(info, "%s[Video]", info);  
            break;  
        case AVMEDIA_TYPE_AUDIO:  
            sprintf(info, "%s[Audio]", info);  
            break;  
        default:  
            sprintf(info, "%s[Other]", info);  
            break;  
        }  
        sprintf(info, "%s[%10s]\n", info, c_temp->name);  
  
          
        c_temp=c_temp->next;  
    }  
    //LOGE("%s", info);  
  
    return (*env)->NewStringUTF(env, info); 
}
コード例 #25
0
ファイル: producer_avformat.c プロジェクト: rayl/MLT
mlt_producer producer_avformat_init( mlt_profile profile, char *file )
{
	int error = 0;

	// Report information about available demuxers and codecs as YAML Tiny
	if ( file && strstr( file, "f-list" ) )
	{
		fprintf( stderr, "---\nformats:\n" );
		AVInputFormat *format = NULL;
		while ( ( format = av_iformat_next( format ) ) )
			fprintf( stderr, "  - %s\n", format->name );
		fprintf( stderr, "...\n" );
		error = 1;
	}
	if ( file && strstr( file, "acodec-list" ) )
	{
		fprintf( stderr, "---\naudio_codecs:\n" );
		AVCodec *codec = NULL;
		while ( ( codec = av_codec_next( codec ) ) )
			if ( codec->decode && codec->type == CODEC_TYPE_AUDIO )
				fprintf( stderr, "  - %s\n", codec->name );
		fprintf( stderr, "...\n" );
		error = 1;
	}
	if ( file && strstr( file, "vcodec-list" ) )
	{
		fprintf( stderr, "---\nvideo_codecs:\n" );
		AVCodec *codec = NULL;
		while ( ( codec = av_codec_next( codec ) ) )
			if ( codec->decode && codec->type == CODEC_TYPE_VIDEO )
				fprintf( stderr, "  - %s\n", codec->name );
		fprintf( stderr, "...\n" );
		error = 1;
	}
	if ( error )
		return NULL;

	mlt_producer this = NULL;

	// Check that we have a non-NULL argument
	if ( file != NULL )
	{
		// Construct the producer
		this = calloc( 1, sizeof( struct mlt_producer_s ) );

		// Initialise it
		if ( mlt_producer_init( this, NULL ) == 0 )
		{
			// Get the properties
			mlt_properties properties = MLT_PRODUCER_PROPERTIES( this );

			// Set the resource property (required for all producers)
			mlt_properties_set( properties, "resource", file );

			// Register our get_frame implementation
			this->get_frame = producer_get_frame;

			// Open the file
			if ( producer_open( this, profile, file ) != 0 )
			{
				// Clean up
				mlt_producer_close( this );
				this = NULL;
			}
			else
			{
				// Close the file to release resources for large playlists - reopen later as needed
				mlt_properties_set_data( properties, "dummy_context", NULL, 0, NULL, NULL );
				mlt_properties_set_data( properties, "audio_context", NULL, 0, NULL, NULL );
				mlt_properties_set_data( properties, "video_context", NULL, 0, NULL, NULL );

				// Default the user-selectable indices from the auto-detected indices
				mlt_properties_set_int( properties, "audio_index",  mlt_properties_get_int( properties, "_audio_index" ) );
				mlt_properties_set_int( properties, "video_index",  mlt_properties_get_int( properties, "_video_index" ) );
			}
		}
	}

	return this;
}
コード例 #26
0
ファイル: cmdutils.c プロジェクト: Amalerd/SoxPlayer
int opt_default(const char *opt, const char *arg){
    int type;
    int ret= 0;
    const AVOption *o= NULL;
    int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
    AVCodec *p = NULL;
    AVOutputFormat *oformat = NULL;
    AVInputFormat *iformat = NULL;

    while ((p = av_codec_next(p))) {
        AVClass *c = p->priv_class;
        if (c && av_find_opt(&c, opt, NULL, 0, 0))
            break;
    }
    if (p)
        goto out;
    while ((oformat = av_oformat_next(oformat))) {
        const AVClass *c = oformat->priv_class;
        if (c && av_find_opt(&c, opt, NULL, 0, 0))
            break;
    }
    if (oformat)
        goto out;
    while ((iformat = av_iformat_next(iformat))) {
        const AVClass *c = iformat->priv_class;
        if (c && av_find_opt(&c, opt, NULL, 0, 0))
            break;
    }
    if (iformat)
        goto out;

    for(type=0; *avcodec_opts && type<AVMEDIA_TYPE_NB && ret>= 0; type++){
        const AVOption *o2 = av_find_opt(avcodec_opts[0], opt, NULL, opt_types[type], opt_types[type]);
        if(o2)
            ret = av_set_string3(avcodec_opts[type], opt, arg, 1, &o);
    }
    if(!o && avformat_opts)
        ret = av_set_string3(avformat_opts, opt, arg, 1, &o);
    if(!o && sws_opts)
        ret = av_set_string3(sws_opts, opt, arg, 1, &o);
    if(!o){
        if (opt[0] == 'a' && avcodec_opts[AVMEDIA_TYPE_AUDIO])
            ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_AUDIO], opt+1, arg, 1, &o);
        else if(opt[0] == 'v' && avcodec_opts[AVMEDIA_TYPE_VIDEO])
            ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_VIDEO], opt+1, arg, 1, &o);
        else if(opt[0] == 's' && avcodec_opts[AVMEDIA_TYPE_SUBTITLE])
            ret = av_set_string3(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], opt+1, arg, 1, &o);
        if (ret >= 0)
            opt += 1;
    }
    if (o && ret < 0) {
        fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt);
        exit(1);
    }
    if (!o) {
        fprintf(stderr, "Unrecognized option '%s'\n", opt);
        exit(1);
    }

 out:
//    av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avcodec_opts, opt, NULL), (int)av_get_int(avcodec_opts, opt, NULL));

    opt_values= av_realloc(opt_values, sizeof(void*)*(opt_name_count+1));
    opt_values[opt_name_count] = av_strdup(arg);
    opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
    opt_names[opt_name_count++] = av_strdup(opt);

    if ((*avcodec_opts && avcodec_opts[0]->debug) || (avformat_opts && avformat_opts->debug))
        av_log_set_level(AV_LOG_DEBUG);
    return 0;
}
コード例 #27
0
ファイル: factory.c プロジェクト: elfring/mlt
static mlt_properties avformat_metadata( mlt_service_type type, const char *id, void *data )
{
	char file[ PATH_MAX ];
	const char *service_type = NULL;
	mlt_properties result = NULL;

	// Convert the service type to a string.
	switch ( type )
	{
		case consumer_type:
			service_type = "consumer";
			break;
		case filter_type:
			service_type = "filter";
			break;
		case producer_type:
			service_type = "producer";
			break;
		case transition_type:
			service_type = "transition";
			break;
		default:
			return NULL;
	}
	// Load the yaml file
	snprintf( file, PATH_MAX, "%s/avformat/%s_%s.yml", mlt_environment( "MLT_DATA" ), service_type, id );
	result = mlt_properties_parse_yaml( file );
	if ( result && ( type == consumer_type || type == producer_type ) )
	{
		// Annotate the yaml properties with AVOptions.
		mlt_properties params = (mlt_properties) mlt_properties_get_data( result, "parameters", NULL );
		AVFormatContext *avformat = avformat_alloc_context();
#if LIBAVCODEC_VERSION_INT > ((53<<16)+(8<<8)+0)
		AVCodecContext *avcodec = avcodec_alloc_context3( NULL );
#else
		AVCodecContext *avcodec = avcodec_alloc_context();
#endif
		int flags = ( type == consumer_type )? AV_OPT_FLAG_ENCODING_PARAM : AV_OPT_FLAG_DECODING_PARAM;

		add_parameters( params, avformat, flags, NULL, NULL );
#if LIBAVFORMAT_VERSION_MAJOR >= 53
		avformat_init();
		if ( type == producer_type )
		{
			AVInputFormat *f = NULL;
			while ( ( f = av_iformat_next( f ) ) )
				if ( f->priv_class )
					add_parameters( params, &f->priv_class, flags, NULL, f->name );
		}
		else
		{
			AVOutputFormat *f = NULL;
			while ( ( f = av_oformat_next( f ) ) )
				if ( f->priv_class )
					add_parameters( params, &f->priv_class, flags, NULL, f->name );
		}
#endif

		add_parameters( params, avcodec, flags, NULL, NULL );
#if LIBAVCODEC_VERSION_MAJOR >= 53
		AVCodec *c = NULL;
		while ( ( c = av_codec_next( c ) ) )
			if ( c->priv_class )
				add_parameters( params, &c->priv_class, flags, NULL, c->name );
#endif

		av_free( avformat );
		av_free( avcodec );
	}
	return result;
}
コード例 #28
0
      VideoPanel::VideoPanel(std::map<std::string, std::string>& p) : _parameter(p), Wt::Ext::Panel() {
        //        setLayout(new Wt::WFitLayout());
        Wt::WBorderLayout*l = new Wt::WBorderLayout();
        setLayout(l);
        std::set<std::string> avail_codecs;
        if (_parameter.count("available_codecs") > 0) {
          LOGDEBUG("Available codes" << _parameter["available_codecs"]);
          org::esb::util::StringTokenizer st(_parameter["available_codecs"], ",");
          while (st.hasMoreTokens()) {
            std::string codec_id = st.nextToken();
            avail_codecs.insert(codec_id);
            LOGDEBUG("avalable codec list" << codec_id);
          }
        }
        /*
         * Combobox for the Codec Selector
         */
        KeyValueModel * codec_model = new KeyValueModel();
        codec_model->addModelData("novideo", "No Video");
        codec_model->addModelData("copy", "Stream Copy");

        AVCodec *codec = NULL;
        int a = 0;
        while ((codec = av_codec_next(codec))) {
          if (codec->encode && codec->type == AVMEDIA_TYPE_VIDEO) {
            if (avail_codecs.count(codec->name) > 0) {
              codec_model->addModelData(codec->name, codec->long_name);
            } else {
              if (avail_codecs.size() == 0)
                codec_model->addModelData(codec->name, codec->long_name);
            }
          }
        }
        codec_model->sort(1);

        _codec = new ComboBox();

        _codec->setModel(codec_model);
        _codec->setModelColumn(1);
        _codec->setSelectedEntry(_parameter["codec_id"]);
        _codec->setTextSize(50);
        _codec->resize(300, Wt::WLength());


        _codec->activated().connect(SLOT(this, VideoPanel::codecSelected));


        main_panel = new Wt::Ext::Panel();
        Wt::WFitLayout * fit = new Wt::WFitLayout();
        main_panel->setLayout(fit);
        //main_panel->setBorder(false);

        l->addWidget(main_panel, Wt::WBorderLayout::Center);

        Wt::Ext::Panel * top_panel = new Wt::Ext::Panel();
        top_panel->resize(Wt::WLength(), 40);
        top_panel->setLayout(new Wt::WFitLayout());
        top_panel->setBorder(false);
        //        top_panel->layout()->addWidget(_codec);

        Wt::WContainerWidget *top = new Wt::WContainerWidget();
        top_panel->layout()->addWidget(top);
        Wt::WGridLayout * grid = new Wt::WGridLayout();
        top->setLayout(grid);
        top->resize(Wt::WLength(), 40);

        l->addWidget(top_panel, Wt::WBorderLayout::North);
        Wt::WLabel * label = new Wt::WLabel("Codec:");
        label->setBuddy(_codec);

        grid->addWidget(label, 0, 0);
        grid->addWidget(_codec, 0, 1);
        grid->addWidget(new Wt::WText(""), 0, 2);
        grid->setColumnStretch(1, 1);




        setCodecGui(_parameter["codec_id"]);
        //l->addWidget(builder,Wt::WBorderLayout::Center);
        //        return;
      }
コード例 #29
0
ファイル: cmdutils.c プロジェクト: csd/ffmpeg
void show_codecs(void)
{
    AVCodec *p=NULL, *p2;
    const char *last_name;
    printf(
        "Codecs:\n"
        " D..... = Decoding supported\n"
        " .E.... = Encoding supported\n"
        " ..V... = Video codec\n"
        " ..A... = Audio codec\n"
        " ..S... = Subtitle codec\n"
        " ...S.. = Supports draw_horiz_band\n"
        " ....D. = Supports direct rendering method 1\n"
        " .....T = Supports weird frame truncation\n"
        " ------\n");
    last_name= "000";
    for(;;){
        int decode=0;
        int encode=0;
        int cap=0;
        const char *type_str;

        p2=NULL;
        while((p= av_codec_next(p))) {
            if((p2==NULL || strcmp(p->name, p2->name)<0) &&
                strcmp(p->name, last_name)>0){
                p2= p;
                decode= encode= cap=0;
            }
            if(p2 && strcmp(p->name, p2->name)==0){
                if(p->decode) decode=1;
                if(p->encode) encode=1;
                cap |= p->capabilities;
            }
        }
        if(p2==NULL)
            break;
        last_name= p2->name;

        switch(p2->type) {
        case AVMEDIA_TYPE_VIDEO:
            type_str = "V";
            break;
        case AVMEDIA_TYPE_AUDIO:
            type_str = "A";
            break;
        case AVMEDIA_TYPE_SUBTITLE:
            type_str = "S";
            break;
        default:
            type_str = "?";
            break;
        }
        printf(
            " %s%s%s%s%s%s %-15s %s",
            decode ? "D": (/*p2->decoder ? "d":*/" "),
            encode ? "E":" ",
            type_str,
            cap & CODEC_CAP_DRAW_HORIZ_BAND ? "S":" ",
            cap & CODEC_CAP_DR1 ? "D":" ",
            cap & CODEC_CAP_TRUNCATED ? "T":" ",
            p2->name,
            p2->long_name ? p2->long_name : "");
       /* if(p2->decoder && decode==0)
            printf(" use %s for decoding", p2->decoder->name);*/
        printf("\n");
    }
    printf("\n");
    printf(
"Note, the names of encoders and decoders do not always match, so there are\n"
"several cases where the above table shows encoder only or decoder only entries\n"
"even though both encoding and decoding are supported. For example, the h263\n"
"decoder corresponds to the h263 and h263p encoders, for file formats it is even\n"
"worse.\n");
}
コード例 #30
0
ファイル: cmdutils.c プロジェクト: mrtos/Logitech-Revue
void show_formats(void)
{
    AVInputFormat *ifmt=NULL;
    AVOutputFormat *ofmt=NULL;
    URLProtocol *up=NULL;
    AVCodec *p=NULL, *p2;
    AVBitStreamFilter *bsf=NULL;
    const char *last_name;

    printf(
        "File formats:\n"
        " D. = Demuxing supported\n"
        " .E = Muxing supported\n"
        " --\n");
    last_name= "000";
    for(;;){
        int decode=0;
        int encode=0;
        const char *name=NULL;
        const char *long_name=NULL;

        while((ofmt= av_oformat_next(ofmt))) {
            if((name == NULL || strcmp(ofmt->name, name)<0) &&
                strcmp(ofmt->name, last_name)>0){
                name= ofmt->name;
                long_name= ofmt->long_name;
                encode=1;
            }
        }
        while((ifmt= av_iformat_next(ifmt))) {
            if((name == NULL || strcmp(ifmt->name, name)<0) &&
                strcmp(ifmt->name, last_name)>0){
                name= ifmt->name;
                long_name= ifmt->long_name;
                encode=0;
            }
            if(name && strcmp(ifmt->name, name)==0)
                decode=1;
        }
        if(name==NULL)
            break;
        last_name= name;

        printf(
            " %s%s %-15s %s\n",
            decode ? "D":" ",
            encode ? "E":" ",
            name,
            long_name ? long_name:" ");
    }
    printf("\n");

    printf(
        "Codecs:\n"
        " D..... = Decoding supported\n"
        " .E.... = Encoding supported\n"
        " ..V... = Video codec\n"
        " ..A... = Audio codec\n"
        " ..S... = Subtitle codec\n"
        " ...S.. = Supports draw_horiz_band\n"
        " ....D. = Supports direct rendering method 1\n"
        " .....T = Supports weird frame truncation\n"
        " ------\n");
    last_name= "000";
    for(;;){
        int decode=0;
        int encode=0;
        int cap=0;
        const char *type_str;

        p2=NULL;
        while((p= av_codec_next(p))) {
            if((p2==NULL || strcmp(p->name, p2->name)<0) &&
                strcmp(p->name, last_name)>0){
                p2= p;
                decode= encode= cap=0;
            }
            if(p2 && strcmp(p->name, p2->name)==0){
                if(p->decode) decode=1;
                if(p->encode) encode=1;
                cap |= p->capabilities;
            }
        }
        if(p2==NULL)
            break;
        last_name= p2->name;

        switch(p2->type) {
        case CODEC_TYPE_VIDEO:
            type_str = "V";
            break;
        case CODEC_TYPE_AUDIO:
            type_str = "A";
            break;
        case CODEC_TYPE_SUBTITLE:
            type_str = "S";
            break;
        default:
            type_str = "?";
            break;
        }
        printf(
            " %s%s%s%s%s%s %-15s %s",
            decode ? "D": (/*p2->decoder ? "d":*/" "),
            encode ? "E":" ",
            type_str,
            cap & CODEC_CAP_DRAW_HORIZ_BAND ? "S":" ",
            cap & CODEC_CAP_DR1 ? "D":" ",
            cap & CODEC_CAP_TRUNCATED ? "T":" ",
            p2->name,
            p2->long_name ? p2->long_name : "");
       /* if(p2->decoder && decode==0)
            printf(" use %s for decoding", p2->decoder->name);*/
        printf("\n");
    }
    printf("\n");

    printf("Bitstream filters:\n");
    while((bsf = av_bitstream_filter_next(bsf)))
        printf(" %s", bsf->name);
    printf("\n");

    printf("Supported file protocols:\n");
    while((up = av_protocol_next(up)))
        printf(" %s:", up->name);
    printf("\n");

    printf("Frame size, frame rate abbreviations:\n ntsc pal qntsc qpal sntsc spal film ntsc-film sqcif qcif cif 4cif\n");
    printf("\n");
    printf(
"Note, the names of encoders and decoders do not always match, so there are\n"
"several cases where the above table shows encoder only or decoder only entries\n"
"even though both encoding and decoding are supported. For example, the h263\n"
"decoder corresponds to the h263 and h263p encoders, for file formats it is even\n"
"worse.\n");
}