[vlc-commits] avformat : add an option to force a specific format

Sébastien Escudier git at videolan.org
Fri Feb 17 08:55:44 CET 2012


vlc | branch: master | Sébastien Escudier <sebastien-devel at celeos.eu> | Thu Feb 16 15:08:33 2012 +0100| [56e7865dce209276279eae8d9c388c7e88737776] | committer: Sébastien Escudier

avformat : add an option to force a specific format

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=56e7865dce209276279eae8d9c388c7e88737776
---

 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 70ce57f..18f8640 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 d346f0f..7356bfe 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 );



More information about the vlc-commits mailing list