diff options
author | eddyg <[email protected]> | 2008-10-10 04:43:13 +0000 |
---|---|---|
committer | eddyg <[email protected]> | 2008-10-10 04:43:13 +0000 |
commit | f1a5850f3f0aff7d0cbe10801ee650f78232fca9 (patch) | |
tree | cdd4669f62eb9c6ff4ea173f6f04012c0ac8312f | |
parent | 2a42c28786f15f007db8e03fc79ec8577a446faa (diff) |
CLI: Add support for naming audio tracks to the HandBrakeCLI, thanks to LePetomane for the patch.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1825 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/common.c | 1 | ||||
-rw-r--r-- | libhb/common.h | 1 | ||||
-rw-r--r-- | libhb/muxmp4.c | 34 | ||||
-rw-r--r-- | libhb/work.c | 3 | ||||
-rw-r--r-- | test/test.c | 58 |
5 files changed, 87 insertions, 10 deletions
diff --git a/libhb/common.c b/libhb/common.c index 073abb977..7cb6ec9a6 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -739,6 +739,7 @@ void hb_audio_config_init(hb_audio_config_t * audiocfg) audiocfg->out.samplerate = 44100; audiocfg->out.mixdown = HB_AMIXDOWN_DOLBYPLII; audiocfg->out.dynamic_range_compression = 0; + audiocfg->out.name = NULL; } /********************************************************************** diff --git a/libhb/common.h b/libhb/common.h index a5cfcf493..47f5503a0 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -329,6 +329,7 @@ struct hb_audio_config_s int bitrate; /* Output bitrate (kbps) */ int mixdown; /* The mixdown format to be used for this audio track (see HB_AMIXDOWN_*) */ double dynamic_range_compression; /* Amount of DRC that gets applied to this track */ + char * name; /* Output track name */ } out; /* Input */ diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c index febeb0194..807bc24cd 100644 --- a/libhb/muxmp4.c +++ b/libhb/muxmp4.c @@ -309,18 +309,36 @@ static int MP4Init( hb_mux_object_t * m ) mux_data->track = MP4AddAC3AudioTrack( m->file, m->samplerate, 1536, MP4_MPEG4_AUDIO_TYPE ); - MP4SetTrackBytesProperty( - m->file, mux_data->track, - "udta.name.value", - (const u_int8_t*)"Surround", strlen("Surround")); + if (audio->config.out.name == NULL) { + MP4SetTrackBytesProperty( + m->file, mux_data->track, + "udta.name.value", + (const u_int8_t*)"Surround", strlen("Surround")); + } + else { + MP4SetTrackBytesProperty( + m->file, mux_data->track, + "udta.name.value", + (const u_int8_t*)(audio->config.out.name), + strlen(audio->config.out.name)); + } } else { mux_data->track = MP4AddAudioTrack( m->file, m->samplerate, 1024, MP4_MPEG4_AUDIO_TYPE ); - MP4SetTrackBytesProperty( - m->file, mux_data->track, - "udta.name.value", - (const u_int8_t*)"Stereo", strlen("Stereo")); + if (audio->config.out.name == NULL) { + MP4SetTrackBytesProperty( + m->file, mux_data->track, + "udta.name.value", + (const u_int8_t*)"Stereo", strlen("Stereo")); + } + else { + MP4SetTrackBytesProperty( + m->file, mux_data->track, + "udta.name.value", + (const u_int8_t*)(audio->config.out.name), + strlen(audio->config.out.name)); + } MP4SetAudioProfileLevel( m->file, 0x0F ); MP4SetTrackESConfiguration( diff --git a/libhb/work.c b/libhb/work.c index 64b061718..91da97aea 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -285,7 +285,8 @@ hb_display_job_info( hb_job_t * job ) { audio = hb_list_item( title->list_audio, i ); - hb_log( " * audio track %d", audio->config.out.track ); + hb_log( " * audio track %d (%s)", audio->config.out.track, + audio->config.out.name ? audio->config.out.name : "no-name" ); hb_log( " + decoder: %s (track %d, id %x)", audio->config.lang.description, audio->config.in.track, audio->id ); diff --git a/test/test.c b/test/test.c index 03570016a..dc61c5793 100644 --- a/test/test.c +++ b/test/test.c @@ -55,6 +55,7 @@ static char * atracks = NULL; static char * arates = NULL; static char * abitrates = NULL; static char * acodecs = NULL; +static char * anames = NULL; static int default_acodec = HB_ACODEC_FAAC; static int default_arate = 48000; static int default_abitrate = 160; @@ -265,6 +266,10 @@ int main( int argc, char ** argv ) while( ( audio = hb_list_item( audios, 0 ) ) ) { hb_list_rem( audios, audio ); + if( audio->out.name ) + { + free( audio->out.name ); + } free( audio ); } hb_list_close( &audios ); @@ -275,6 +280,7 @@ int main( int argc, char ** argv ) if( arates ) free( arates ); if( abitrates ) free( abitrates ); if( acodecs ) free( acodecs ); + if( anames ) free( anames ); if (native_language ) free (native_language ); if( x264opts ) free (x264opts ); if( x264opts2 ) free (x264opts2 ); @@ -977,6 +983,10 @@ static int HandleEvents( hb_handle_t * h ) } hb_list_rem(audios, audio); if( audio != NULL) + if( audio->out.name ) + { + free( audio->out.name); + } free( audio ); } @@ -1215,6 +1225,42 @@ static int HandleEvents( hb_handle_t * h ) } /* Audio Mixdown */ + /* Audio Track Names */ + i = 0; + if ( anames ) + { + char * token = strtok(anames, ","); + if (token == NULL) + token = anames; + while ( token != NULL ) + { + audio = hb_list_audio_config_item(job->list_audio, i); + if( audio != NULL ) + { + audio->out.name = strdup(token); + if( (++i) >= num_audio_tracks ) + break; /* We have more names than audio tracks, oops */ + } + else + { + fprintf(stderr, "Ignoring aname '%s', no audio track\n", + token); + } + token = strtok(NULL, ","); + } + } + if( i < num_audio_tracks && i == 1 ) + { + /* We have exactly one name and more than one audio track. Use the same + * name for all tracks. */ + for ( ; i < num_audio_tracks; i++) + { + audio = hb_list_audio_config_item(job->list_audio, i); + audio->out.name = strdup(anames); + } + } + /* Audio Track Names */ + if( size ) { job->vbitrate = hb_calc_bitrate( job, size ); @@ -1592,6 +1638,8 @@ static void ShowHelp() " making soft sounds louder. Range is 1.0 to 4.0\n" " (too loud), with 1.5 - 2.5 being a useful range.\n" " Seperated by commas for more than one audio track.\n" + " -A, --aname <string> Audio channel name(s),\n" + " Separated by commas for more than one audio track.\n" "\n" @@ -1712,6 +1760,8 @@ static int ParseOptions( int argc, char ** argv ) { "preset", required_argument, NULL, 'Z' }, { "preset-list", no_argument, NULL, 'z' }, + { "aname", required_argument, NULL, 'A' }, + { 0, 0, 0, 0 } }; @@ -1719,7 +1769,7 @@ static int ParseOptions( int argc, char ** argv ) int c; c = getopt_long( argc, argv, - "hv::uC:f:4i:Io:t:Lc:m::a:6:s:UFN:e:E:2dD:7895gpOP::w:l:n:b:q:S:B:r:R:Qx:TY:X:Z:z", + "hv::uC:f:4i:Io:t:Lc:m::a:A:6:s:UFN:e:E:2dD:7895gpOP::w:l:n:b:q:S:B:r:R:Qx:TY:X:Z:z", long_options, &option_index ); if( c < 0 ) { @@ -2050,6 +2100,12 @@ static int ParseOptions( int argc, char ** argv ) case 'X': maxWidth = atoi (optarg ); break; + case 'A': + if( optarg != NULL ) + { + anames = strdup( optarg ); + } + break; default: fprintf( stderr, "unknown option (%s)\n", argv[optind] ); |