From 56e7865dce209276279eae8d9c388c7e88737776 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Escudier?= Date: Thu, 16 Feb 2012 15:08:33 +0100 Subject: [PATCH] avformat : add an option to force a specific format --- modules/demux/avformat/avformat.c | 4 ++++ modules/demux/avformat/demux.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/demux/avformat/avformat.c b/modules/demux/avformat/avformat.c index 70ce57f303..18f864070d 100644 --- a/modules/demux/avformat/avformat.c +++ b/modules/demux/avformat/avformat.c @@ -32,6 +32,9 @@ #include "avformat.h" +#define FORMAT_TEXT N_( "Format name" ) +#define FORMAT_LONGTEXT N_( "Internal libavcodec format name" ) + vlc_module_begin () #endif /* MERGE_FFMPEG */ add_shortcut( "ffmpeg", "avformat" ) @@ -41,6 +44,7 @@ vlc_module_begin () set_shortname( N_("Avformat") ) set_capability( "demux", 2 ) set_callbacks( OpenDemux, CloseDemux ) + add_string( "ffmpeg-format", NULL, FORMAT_TEXT, FORMAT_LONGTEXT, true ) #ifdef ENABLE_SOUT /* mux submodule */ diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c index d346f0f665..7356bfe2c6 100644 --- a/modules/demux/avformat/demux.c +++ b/modules/demux/avformat/demux.c @@ -112,7 +112,7 @@ int OpenDemux( vlc_object_t *p_this ) demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys; AVProbeData pd; - AVInputFormat *fmt; + AVInputFormat *fmt = NULL; unsigned int i; int64_t i_start_time = -1; bool b_can_seek; @@ -141,8 +141,16 @@ int OpenDemux( vlc_object_t *p_this ) av_register_all(); /* Can be called several times */ vlc_avcodec_unlock(); + char *psz_format = var_InheritString( p_this, "ffmpeg-format" ); + if( psz_format ) + { + if( fmt = av_find_input_format(psz_format) ) + msg_Dbg( p_demux, "forcing format: %s", fmt->name ); + free( psz_format ); + } + /* Guess format */ - if( !( fmt = av_probe_input_format( &pd, 1 ) ) ) + if( !fmt && !( fmt = av_probe_input_format( &pd, 1 ) ) ) { msg_Dbg( p_demux, "couldn't guess format" ); free( psz_url ); -- 2.39.2