Commit 35d7ee99 authored by Rafaël Carré's avatar Rafaël Carré

ffmpeg: add ffmpeg-codec and sout-ffmpeg-codec

This allows specifying the libavcodec decoder/encoder by name
Useful in case there are more than one codec per fourcc

Example: ffvp8 / libvpx decoders for VP8
parent 344bc899
......@@ -127,6 +127,7 @@ vlc_module_begin ()
add_integer( "ffmpeg-debug", 0, DEBUG_TEXT, DEBUG_LONGTEXT,
true )
add_string( "ffmpeg-codec", NULL, CODEC_TEXT, CODEC_LONGTEXT, true )
#if defined(HAVE_AVCODEC_VAAPI) || defined(HAVE_AVCODEC_DXVA2)
add_bool( "ffmpeg-hw", false, HW_TEXT, HW_LONGTEXT, false )
#endif
......@@ -144,6 +145,7 @@ vlc_module_begin ()
set_capability( "encoder", 100 )
set_callbacks( OpenEncoder, CloseEncoder )
add_string( ENC_CFG_PREFIX "codec", NULL, CODEC_TEXT, CODEC_LONGTEXT, true )
add_string( ENC_CFG_PREFIX "hq", "simple", ENC_HQ_TEXT,
ENC_HQ_LONGTEXT, false )
change_string_list( enc_hq_list, enc_hq_list_text, 0 )
......@@ -237,7 +239,22 @@ static int OpenDecoder( vlc_object_t *p_this )
InitLibavcodec(p_this);
/* *** ask ffmpeg for a decoder *** */
p_codec = avcodec_find_decoder( i_codec_id );
char *psz_decoder = var_CreateGetString( p_this, "ffmpeg-codec" );
if( psz_decoder && *psz_decoder )
{
p_codec = avcodec_find_decoder_by_name( psz_decoder );
if( !p_codec )
msg_Err( p_this, "Decoder `%s' not found", psz_decoder );
else if( p_codec->id != i_codec_id )
{
msg_Err( p_this, "Decoder `%s' can't handle %4.4s",
psz_decoder, (char*)&p_dec->fmt_in.i_codec );
p_codec = NULL;
}
}
free( psz_decoder );
if( !p_codec )
p_codec = avcodec_find_decoder( i_codec_id );
if( !p_codec )
{
msg_Dbg( p_dec, "codec not found (%s)", psz_namecodec );
......
......@@ -115,6 +115,9 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
#define DEBUG_TEXT N_( "Debug mask" )
#define DEBUG_LONGTEXT N_( "Set FFmpeg debug mask" )
#define CODEC_TEXT N_( "Codec name" )
#define CODEC_LONGTEXT N_( "Internal libavcodec codec name" )
/* TODO: Use a predefined list, with 0,1,2,4,7 */
#define VISMV_TEXT N_( "Visualize motion vectors" )
#define VISMV_LONGTEXT N_( \
......
......@@ -146,7 +146,7 @@ struct encoder_sys_t
};
static const char *const ppsz_enc_options[] = {
"keyint", "bframes", "vt", "qmin", "qmax", "hq",
"keyint", "bframes", "vt", "qmin", "qmax", "codec", "hq",
"rc-buffer-size", "rc-buffer-aggressivity", "pre-me", "hurry-up",
"interlace", "interlace-me", "i-quant-factor", "noise-reduction", "mpeg4-matrix",
"trellis", "qscale", "strict", "lumi-masking", "dark-masking",
......@@ -196,7 +196,7 @@ int OpenEncoder( vlc_object_t *p_this )
encoder_t *p_enc = (encoder_t *)p_this;
encoder_sys_t *p_sys;
AVCodecContext *p_context;
AVCodec *p_codec;
AVCodec *p_codec = NULL;
int i_codec_id, i_cat;
const char *psz_namecodec;
float f_val;
......@@ -253,7 +253,22 @@ int OpenEncoder( vlc_object_t *p_this )
/* Initialization must be done before avcodec_find_encoder() */
InitLibavcodec( p_this );
p_codec = avcodec_find_encoder( i_codec_id );
char *psz_encoder = var_GetString( p_this, ENC_CFG_PREFIX "codec" );
if( psz_encoder && *psz_encoder )
{
p_codec = avcodec_find_encoder_by_name( psz_encoder );
if( !p_codec )
msg_Err( p_this, "Encoder `%s' not found", psz_encoder );
else if( p_codec->id != i_codec_id )
{
msg_Err( p_this, "Encoder `%s' can't handle %4.4s",
psz_encoder, (char*)&p_enc->fmt_out.i_codec );
p_codec = NULL;
}
}
free( psz_encoder );
if( !p_codec )
p_codec = avcodec_find_encoder( i_codec_id );
if( !p_codec )
{
msg_Err( p_enc, "cannot find encoder %s\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment