[vlc-devel] [PATCH] avformat : add an option to force a specific format
Rafaël Carré
funman at videolan.org
Thu Feb 16 20:55:17 CET 2012
Le 2012-02-16 09:14, Sébastien Escudier a écrit :
> Hi,
>
> Why this patch ?
> Because ffmpeg can demux mxpeg stream, but does not autodetect it (with
> ffplay you must add -f mxg to read the stream).
>
> So I added an option to force a ffmpeg format, like the ffmpeg-codec
> option we already have.
>
> Is it ok ?
OK with me, I think it's a good idea.
> Regards,
> Sébastien.
>
>
>
> 0001-avformat-add-an-option-to-force-a-specific-format.patch
>
>
> From 01f88016d0b26b79509ac197de1e7446e4cf1638 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?S=C3=A9bastien=20Escudier?= <sebastien-devel at celeos.eu>
> 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 | 11 +++++++++--
> 2 files changed, 13 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..0704104 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,15 @@ 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 && *psz_format )
var_InheritString returns NULL if the string is empty (non NULL but "")
so you could skip the && *psz_format
> + {
> + if( fmt = av_find_input_format(psz_format) )
> + msg_Dbg( p_demux, "forcing format: %s", fmt->name );
> + }
> +
> /* 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 );
> -- 1.7.0.4
You're leaking psz_format.
More information about the vlc-devel
mailing list