static int titleindex = 1;
static int longest_title = 0;
static int subtitle_scan = 0;
+static int subtitle_force = 0;
static char * native_language = NULL;
static int twoPass = 0;
-static int deinterlace = 0;
+static int deinterlace = 0;
+static char * deinterlace_opt = 0;
+static int deblock = 0;
+static char * deblock_opt = 0;
+static int denoise = 0;
+static char * denoise_opt = 0;
+static int detelecine = 0;
+static char * detelecine_opt = 0;
static int grayscale = 0;
static int vcodec = HB_VCODEC_FFMPEG;
static int h264_13 = 0;
static int maxHeight = 0;
static int maxWidth = 0;
static int turbo_opts_enabled = 0;
-static char * turbo_opts = "no-fast-pskip=0:subme=1:me=dia:trellis=0:analyse=none";
+static char * turbo_opts = "ref=1:subme=1:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0";
static int largeFileSize = 0;
/* Exit cleanly on Ctrl-C */
static int CheckOptions( int argc, char ** argv );
static int HandleEvents( hb_handle_t * h );
+/****************************************************************************
+ * hb_error_handler
+ *
+ * When using the CLI just display using hb_log as we always did in the past
+ * make sure that we prefix with a nice ERROR message to catch peoples eyes.
+ ****************************************************************************/
+static void hb_cli_error_handler ( const char *errmsg )
+{
+ fprintf( stderr, "ERROR: %s", errmsg );
+}
+
int main( int argc, char ** argv )
{
hb_handle_t * h;
return 1;
}
+ /* Register our error handler */
+ hb_register_error_handler(&hb_cli_error_handler);
+
/* Init libhb */
h = hb_init( debug, update );
job->grayscale = grayscale;
job->pixel_ratio = pixelratio;
+ /* Add selected filters */
+ job->filters = hb_list_init();
+ if( detelecine )
+ {
+ hb_filter_detelecine.settings = detelecine_opt;
+ hb_list_add( job->filters, &hb_filter_detelecine );
+ }
+ if( deinterlace )
+ {
+ hb_filter_deinterlace.settings = deinterlace_opt;
+ hb_list_add( job->filters, &hb_filter_deinterlace );
+ }
+ if( deblock )
+ {
+ hb_filter_deblock.settings = deblock_opt;
+ hb_list_add( job->filters, &hb_filter_deblock );
+ }
+ if( denoise )
+ {
+ hb_filter_denoise.settings = denoise_opt;
+ hb_list_add( job->filters, &hb_filter_denoise );
+ }
+
if( width && height )
{
job->width = width;
job->maxWidth = maxWidth;
if (maxHeight)
job->maxHeight = maxHeight;
-
+
+ if( subtitle_force )
+ {
+ job->subtitle_force = subtitle_force;
+ }
+
+ if( subtitle_scan )
+ {
+ char *x264opts_tmp;
+
+ /*
+ * When subtitle scan is enabled do a fast pre-scan job
+ * which will determine which subtitles to enable, if any.
+ */
+ job->pass = -1;
+
+ x264opts_tmp = job->x264opts;
+
+ job->x264opts = NULL;
+
+ job->indepth_scan = subtitle_scan;
+ fprintf( stderr, "Subtitle Scan Enabled - enabling "
+ "subtitles if found for foreign language segments\n");
+ job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
+ *(job->select_subtitle) = NULL;
+
+ /*
+ * Add the pre-scan job
+ */
+ hb_add( h, job );
+
+ job->x264opts = x264opts_tmp;
+ }
+
if( twoPass )
{
/*
* for the first pass and then off again for the
* second.
*/
+ hb_subtitle_t **subtitle_tmp = job->select_subtitle;
+
+ job->select_subtitle = NULL;
+
job->pass = 1;
- job->subtitle_scan = subtitle_scan;
- if( subtitle_scan )
- {
- fprintf( stderr, "Subtitle Scan Enabled - enabling "
- "subtitles if found for foreign language segments\n");
- job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
- *(job->select_subtitle) = NULL;
- }
+
+ job->indepth_scan = 0;
/*
* If turbo options have been selected then append them
*/
if( turbo_opts_enabled )
{
- int size = strlen(x264opts) + strlen(turbo_opts) + 2;
+ int size = (x264opts ? strlen(x264opts) : 0) + strlen(turbo_opts) + 2;
char *tmp_x264opts;
tmp_x264opts = malloc(size * sizeof(char));
job->x264opts = x264opts;
}
hb_add( h, job );
+
+ job->select_subtitle = subtitle_tmp;
+
job->pass = 2;
/*
* On the second pass we turn off subtitle scan so that we
* selected in the first pass (using the whacky select-subtitle
* attribute of the job).
*/
- job->subtitle_scan = 0;
+ job->indepth_scan = 0;
job->x264opts = x264opts2;
/*
* Turn on subtitle scan if requested, note that this option
* precludes encoding of any actual subtitles.
- */
- job->subtitle_scan = subtitle_scan;
- if ( subtitle_scan )
- {
- fprintf( stderr, "Subtitle Scan Enabled, will scan all "
- "subtitles matching the audio language for any\n"
- "that meet our auto-selection criteria.\n");
- }
+ */
+
+ job->indepth_scan = 0;
job->pass = 0;
hb_add( h, job );
}
"### Destination Options------------------------------------------------------\n\n"
" -o, --output <string> Set output file name\n"
- " -f, --format <string> Set output format (avi/mp4/ogm, default:\n"
+ " -f, --format <string> Set output format (avi/mp4/ogm/mkv, default:\n"
" autodetected from file name)\n"
" -4, --large-file Use 64-bit mp4 files that can hold more than\n"
" 4 GB. Note: Breaks iPod, @TV, PS3 compatibility.\n"""
" -Y, --maxHeight <#> Set maximum height\n"
" -X, --maxWidth <#> Set maximum width\n"
" -s, --subtitle <number> Select subtitle (default: none)\n"
- " -U, --subtitle-scan Scan for subtitles on the first pass, and choose\n"
- " the one that's only used 20 percent of the time\n"
+ " -U, --subtitle-scan Scan for subtitles in an extra first pass, and choose\n"
+ " the one that's only used 10 percent of the time\n"
" or less. This should locate subtitles for short\n"
- " foreign language segments. Only works with 2-pass.\n"
+ " foreign language segments. Best used in conjunction\n"
+ " with --subtitle-forced.\n"
+ " -F, --subtitle-forced Only display subtitles from the selected stream if\n"
+ " the subtitle has the forced flag set. May be used in\n"
+ " conjunction with --subtitle-scan to auto-select\n"
+ " a stream if it contains forced subtitles.\n"
" -N, --native-language Select subtitles with this language if it does not\n"
" <string> match the Audio language. Provide the language's\n"
" iso639-2 code (fre, eng, spa, dut, et cetera)\n"
fprintf( stderr, ")\n"
"\n"
" -2, --two-pass Use two-pass mode\n"
- " -d, --deinterlace Deinterlace video\n"
+ " -d, --deinterlace Deinterlace video with yadif/mcdeint filter\n"
+ " <YM:FD:MM:QP> (default 0:-1:-1:1)\n"
+ " -7, --deblock Deblock video with pp7 filter\n"
+ " <QP:M> (default 0:2)\n"
+ " -8, --denoise Denoise video with hqdn3d filter\n"
+ " <SL:SC:TL:TC> (default 4:3:6:4.5)\n"
+ " -9, --detelecine Detelecine video with pullup filter\n"
+ " <L:R:T:B:SB:MP> (default 1:1:4:4:0:0)\n"
" -g, --grayscale Grayscale encoding\n"
" -p, --pixelratio Store pixel aspect ratio in video stream\n"
{ "mixdown", required_argument, NULL, '6' },
{ "subtitle", required_argument, NULL, 's' },
{ "subtitle-scan", no_argument, NULL, 'U' },
+ { "subtitle-forced", no_argument, NULL, 'F' },
{ "native-language", required_argument, NULL,'N' },
{ "encoder", required_argument, NULL, 'e' },
{ "aencoder", required_argument, NULL, 'E' },
{ "two-pass", no_argument, NULL, '2' },
- { "deinterlace", no_argument, NULL, 'd' },
+ { "deinterlace", optional_argument, NULL, 'd' },
+ { "deblock", optional_argument, NULL, '7' },
+ { "denoise", optional_argument, NULL, '8' },
+ { "detelecine", optional_argument, NULL, '9' },
{ "grayscale", no_argument, NULL, 'g' },
{ "pixelratio", no_argument, NULL, 'p' },
{ "width", required_argument, NULL, 'w' },
int c;
c = getopt_long( argc, argv,
- "hvuC:f:4i:o:t:Lc:ma:6:s:UN:e:E:2dgpw:l:n:b:q:S:B:r:R:Qx:TY:X:",
+ "hvuC:f:4i:o:t:Lc:ma:6:s:UFN:e:E:2d789gpw:l:n:b:q:S:B:r:R:Qx:TY:X:",
long_options, &option_index );
if( c < 0 )
{
else if( !strcasecmp( optarg, "dpl2" ) )
{
audio_mixdown = HB_AMIXDOWN_DOLBYPLII;
- }
+ }
else if( !strcasecmp( optarg, "6ch" ) )
{
audio_mixdown = HB_AMIXDOWN_6CH;
case 'U':
subtitle_scan = 1;
break;
+ case 'F':
+ subtitle_force = 1;
+ break;
case 'N':
native_language = strdup( optarg );
break;
twoPass = 1;
break;
case 'd':
+ if( optarg != NULL )
+ {
+ deinterlace_opt = strdup( optarg );
+ }
deinterlace = 1;
break;
+ case '7':
+ if( optarg != NULL )
+ {
+ deblock_opt = strdup( optarg );
+ }
+ deblock = 1;
+ break;
+ case '8':
+ if( optarg != NULL )
+ {
+ denoise_opt = strdup( optarg );
+ }
+ denoise = 1;
+ break;
+ case '9':
+ if( optarg != NULL )
+ {
+ detelecine_opt = strdup( optarg );
+ }
+ detelecine = 1;
+ break;
case 'g':
grayscale = 1;
break;
vcodec = HB_VCODEC_X264;
h264_13 = 1;
}
- else if( !strcasecmp( optarg, "x264b30" ) )
- {
- vcodec = HB_VCODEC_X264;
- h264_30 = 1;
- }
+ else if( !strcasecmp( optarg, "x264b30" ) )
+ {
+ vcodec = HB_VCODEC_X264;
+ h264_30 = 1;
+ }
else
{
fprintf( stderr, "invalid codec (%s)\n", optarg );
{
acodec = HB_ACODEC_LAME;
}
+ else if( !strcasecmp( optarg, "faac" ) )
+ {
+ acodec = HB_ACODEC_FAAC;
+ }
+ else if( !strcasecmp( optarg, "vorbis") )
+ {
+ acodec = HB_ACODEC_VORBIS;
+ }
break;
case 'w':
width = atoi( optarg );
mux = HB_MUX_AVI;
}
else if( p && ( !strcasecmp( p, ".mp4" ) ||
- !strcasecmp( p, ".m4v" ) ) )
+ !strcasecmp( p, ".m4v" ) ) )
{
- if ( h264_30 == 1 )
+ if ( h264_30 == 1 )
mux = HB_MUX_IPOD;
- else
- mux = HB_MUX_MP4;
+ else
+ mux = HB_MUX_MP4;
}
else if( p && ( !strcasecmp( p, ".ogm" ) ||
!strcasecmp( p, ".ogg" ) ) )
{
mux = HB_MUX_OGM;
}
+ else if( p && !strcasecmp(p, ".mkv" ) )
+ {
+ mux = HB_MUX_MKV;
+ }
else
{
fprintf( stderr, "Output format couldn't be guessed "
}
else if( !strcasecmp( format, "mp4" ) )
{
- if ( h264_30 == 1)
- mux = HB_MUX_IPOD;
+ if ( h264_30 == 1)
+ mux = HB_MUX_IPOD;
else
- mux = HB_MUX_MP4;
+ mux = HB_MUX_MP4;
}
else if( !strcasecmp( format, "ogm" ) ||
!strcasecmp( format, "ogg" ) )
{
mux = HB_MUX_OGM;
}
+ else if( !strcasecmp( format, "mkv" ) )
+ {
+ mux = HB_MUX_MKV;
+ }
else
{
fprintf( stderr, "Invalid output format (%s). Possible "
- "choices are avi, mp4 and ogm\n.", format );
+ "choices are avi, mp4, m4v, ogm, ogg and mkv\n.", format );
return 1;
}
{
acodec = HB_ACODEC_VORBIS;
}
+ else if( mux == HB_MUX_MKV )
+ {
+ acodec = HB_ACODEC_AC3;
+ }
}
}
return 0;
}
-