diff options
author | jstebbins <[email protected]> | 2011-07-16 17:16:22 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-07-16 17:16:22 +0000 |
commit | 9b6e65252ec843f3701e7f554da48269d17530c8 (patch) | |
tree | 691d8181b782e80acaeaa0ce2d3706d681df2ffb /test | |
parent | ffd720064b4a3b9a06483f68d3443079c63c0a91 (diff) |
cli: add --audio-copy-mask and --audio-fallback options
--audio-copy-mask sets which audio codecs are permitted to be passed thru
when the "copy" encoder option is specified.
--audio-fallback sets which encoder to use when it is not possible to
pass thru an input audio track
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4113 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'test')
-rw-r--r-- | test/test.c | 87 |
1 files changed, 76 insertions, 11 deletions
diff --git a/test/test.c b/test/test.c index 57e8d0642..ec72f9f78 100644 --- a/test/test.c +++ b/test/test.c @@ -66,12 +66,14 @@ static int vcodec = HB_VCODEC_FFMPEG_MPEG4; static hb_list_t * audios = NULL; static hb_audio_config_t * audio = NULL; static int num_audio_tracks = 0; +static int allowed_audio_copy = HB_ACODEC_PASS_MASK; static char * mixdowns = NULL; static char * dynamic_range_compression = NULL; static char * audio_gain = NULL; static char * atracks = NULL; static char * arates = NULL; static char * abitrates = NULL; +static char * acodec_fallback = NULL; static char * acodecs = NULL; static char ** anames = NULL; #ifdef __APPLE_CC__ @@ -1952,10 +1954,19 @@ static int HandleEvents( hb_handle_t * h ) ( audio->out.codec & HB_ACODEC_PASS_FLAG ) && !( audio->out.codec & audio->in.codec ) ) { - // AC3 passthru not possible, fallback to AC3 encoder. - fprintf( stderr, "AC3 passthru requested and input codec is not AC3 for track %d, using AC3 encoder\n", - audio->out.track ); - audio->out.codec = HB_ACODEC_AC3; + // AC3 passthru not possible, use fallback + if ( acodec_fallback ) + { + fprintf( stderr, "AC3 passthru requested and input codec is not AC3 for track %d, using fallback\n", + audio->out.track ); + audio->out.codec = get_acodec_for_string( acodec_fallback); + } + else + { + fprintf( stderr, "AC3 passthru requested and input codec is not AC3 for track %d, using AC3 encoder\n", + audio->out.track ); + audio->out.codec = HB_ACODEC_AC3; + } audio->out.mixdown = hb_get_default_mixdown( audio->out.codec, audio->in.channel_layout ); audio->out.bitrate = hb_get_default_audio_bitrate( audio->out.codec, audio->out.samplerate, audio->out.mixdown ); @@ -1966,12 +1977,21 @@ static int HandleEvents( hb_handle_t * h ) audio->out.codec &= (audio->in.codec | HB_ACODEC_PASS_FLAG); if ( !( audio->out.codec & HB_ACODEC_MASK ) ) { - // Passthru not possible, drop audio. - fprintf( stderr, "Passthru requested and input codec is not the same as output codec for track %d, dropping track\n", - audio->out.track ); - hb_audio_t * item = hb_list_item( job->list_audio, i ); - hb_list_rem( job->list_audio, item ); - continue; + if ( acodec_fallback ) + { + fprintf( stderr, "Passthru requested and input codec is not compatible for track %d, using fallback\n", + audio->out.track ); + audio->out.codec = get_acodec_for_string( acodec_fallback); + } + else + { + // Passthru not possible, drop audio. + fprintf( stderr, "Passthru requested and input codec is not the same as output codec for track %d, dropping track\n", + audio->out.track ); + hb_audio_t * item = hb_list_item( job->list_audio, i ); + hb_list_rem( job->list_audio, item ); + continue; + } } } i++; @@ -2555,6 +2575,13 @@ static void ShowHelp() " (default: faac for mp4, lame for mkv)\n" ); #endif fprintf( out, + " --audio-copy-mask Set audio codecs that are permitted when\n" + " <string> \"copy\" audio encoder option is specified.\n" + " Separated by commas for mutiple allowed options.\n"); + fprintf( out, + " --audio-fallback Set audio codec to use when it is not possible\n" + " <string> to copy an audio track without re-encoding.\n"); + fprintf( out, " -B, --ab <kb/s> Set audio bitrate(s) (default: depends on the\n" " selected codec, mixdown and samplerate)\n" " Separated by commas for more than one audio track.\n" @@ -2795,6 +2822,20 @@ static char** str_split( char *str, char delem ) return ret; } +static void str_vfree( char **strv ) +{ + int i; + + if (strv == NULL) + return; + + for ( i = 0; strv[i]; i++ ) + { + free( strv[i] ); + } + free( strv ); +} + /**************************************************************************** * ParseOptions: ****************************************************************************/ @@ -2824,6 +2865,8 @@ static int ParseOptions( int argc, char ** argv ) #define MAIN_FEATURE 277 #define MIN_DURATION 278 #define AUDIO_GAIN 279 + #define ALLOWED_AUDIO_COPY 280 + #define AUDIO_FALLBACK 281 for( ;; ) { @@ -2909,6 +2952,8 @@ static int ParseOptions( int argc, char ** argv ) #if defined( __APPLE_CC__ ) { "no-vlc-dylib-path", no_argument, &no_vlc_dylib, 1 }, #endif + { "audio-copy-mask", required_argument, NULL, ALLOWED_AUDIO_COPY }, + { "audio-fallback", required_argument, NULL, AUDIO_FALLBACK }, { 0, 0, 0, 0 } }; @@ -3365,6 +3410,26 @@ static int ParseOptions( int argc, char ** argv ) stop_at_pts *= 90000LL; } break; + case ALLOWED_AUDIO_COPY: + { + int i; + char **allowed = str_split( optarg, ',' ); + + allowed_audio_copy = 0; + for ( i = 0; allowed[i]; i++ ) + { + if ( !strcmp( allowed[i], "ac3" ) ) + allowed_audio_copy |= HB_ACODEC_AC3; + if ( !strcmp( allowed[i], "dts" ) ) + allowed_audio_copy |= HB_ACODEC_DCA; + if ( !strcmp( allowed[i], "dtshd" ) ) + allowed_audio_copy |= HB_ACODEC_DCA_HD; + } + str_vfree( allowed ); + } break; + case AUDIO_FALLBACK: + acodec_fallback = strdup( optarg ); + break; case 'M': if( atoi( optarg ) == 601 ) color_matrix = 1; @@ -3530,7 +3595,7 @@ static int get_acodec_for_string( char *codec ) } else if( !strcasecmp( codec, "copy" ) ) { - return HB_ACODEC_AC3_PASS | HB_ACODEC_DCA_PASS | HB_ACODEC_DCA_HD_PASS; + return (HB_ACODEC_PASS_MASK & allowed_audio_copy) | HB_ACODEC_PASS_FLAG; } else if( !strcasecmp( codec, "copy:ac3" ) ) { |