/*****************************************************************************
* x264: top-level x264cli functions
*****************************************************************************
/*****************************************************************************
* x264: top-level x264cli functions
*****************************************************************************
* For more information, contact us at licensing@x264.com.
*****************************************************************************/
* For more information, contact us at licensing@x264.com.
*****************************************************************************/
static const char * const pulldown_names[] = { "none", "22", "32", "64", "double", "triple", "euro", 0 };
static const char * const log_level_names[] = { "none", "error", "warning", "info", "debug", 0 };
static const char * const pulldown_names[] = { "none", "22", "32", "64", "double", "triple", "euro", 0 };
static const char * const log_level_names[] = { "none", "error", "warning", "info", "debug", 0 };
printf( "x264 "X264_POINTVER"\n" );
#else
printf( "x264 0.%d.X\n", X264_BUILD );
printf( "x264 "X264_POINTVER"\n" );
#else
printf( "x264 0.%d.X\n", X264_BUILD );
+#endif
+#if HAVE_SWSCALE
+ printf( "(libswscale %d.%d.%d)\n", LIBSWSCALE_VERSION_MAJOR, LIBSWSCALE_VERSION_MINOR, LIBSWSCALE_VERSION_MICRO );
+#endif
+#if HAVE_LAVF
+ printf( "(libavformat %d.%d.%d)\n", LIBAVFORMAT_VERSION_MAJOR, LIBAVFORMAT_VERSION_MINOR, LIBAVFORMAT_VERSION_MICRO );
+#endif
+#if HAVE_FFMS
+ printf( "(ffmpegsource %d.%d.%d.%d)\n", FFMS_VERSION >> 24, (FFMS_VERSION & 0xff0000) >> 16, (FFMS_VERSION & 0xff00) >> 8, FFMS_VERSION & 0xff );
#endif
printf( "configuration: --bit-depth=%d\n", x264_bit_depth );
printf( "x264 license: " );
#endif
printf( "configuration: --bit-depth=%d\n", x264_bit_depth );
printf( "x264 license: " );
-#if HAVE_LAVF
- const char *license = avformat_license();
- printf( "libavformat license: %s\n", license );
+#if HAVE_SWSCALE
+ const char *license = swscale_license();
+ printf( "libswscale%s%s license: %s\n", HAVE_LAVF ? "/libavformat" : "", HAVE_FFMS ? "/ffmpegsource" : "" , license );
if( !strcmp( license, "nonfree and unredistributable" ) ||
(!HAVE_GPL && (!strcmp( license, "GPL version 2 or later" )
|| !strcmp( license, "GPL version 3 or later" ))))
if( !strcmp( license, "nonfree and unredistributable" ) ||
(!HAVE_GPL && (!strcmp( license, "GPL version 2 or later" )
|| !strcmp( license, "GPL version 3 or later" ))))
#ifdef _WIN32
_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
#endif
#ifdef _WIN32
_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
#endif
/* Parse command line */
if( parse( argc, argv, ¶m, &opt ) < 0 )
/* Parse command line */
if( parse( argc, argv, ¶m, &opt ) < 0 )
-#if PTW32_STATIC_LIB
- pthread_win32_thread_detach_np();
- pthread_win32_process_detach_np();
-#endif
+ /* clean up handles */
+ if( filter.free )
+ filter.free( opt.hin );
+ else if( opt.hin )
+ cli_input.close_file( opt.hin );
+ if( opt.hout )
+ cli_output.close_file( opt.hout, 0, 0 );
+ if( opt.tcfile_out )
+ fclose( opt.tcfile_out );
+ if( opt.qpfile )
+ fclose( opt.qpfile );
+
+ SetConsoleTitle( originalCTitle );
for( enum PixelFormat i = PIX_FMT_NONE+1; i < PIX_FMT_NB; i++ )
{
const char *pfname = av_pix_fmt_descriptors[i].name;
for( enum PixelFormat i = PIX_FMT_NONE+1; i < PIX_FMT_NB; i++ )
{
const char *pfname = av_pix_fmt_descriptors[i].name;
" No lossless.\n"
" Support for bit depth 8-10.\n" );
else H0( " - baseline,main,high,high10\n" );
" No lossless.\n"
" Support for bit depth 8-10.\n" );
else H0( " - baseline,main,high,high10\n" );
" - superfast:\n"
" --no-mbtree --me dia --no-mixed-refs\n"
" --partitions i8x8,i4x4 --rc-lookahead 0\n"
" - superfast:\n"
" --no-mbtree --me dia --no-mixed-refs\n"
" --partitions i8x8,i4x4 --rc-lookahead 0\n"
" - faster:\n"
" --no-mixed-refs --rc-lookahead 20\n"
" --ref 2 --subme 4 --weightp 1\n"
" - fast:\n"
" --rc-lookahead 30 --ref 2 --subme 6\n"
" - faster:\n"
" --no-mixed-refs --rc-lookahead 20\n"
" --ref 2 --subme 4 --weightp 1\n"
" - fast:\n"
" --rc-lookahead 30 --ref 2 --subme 6\n"
" --bframes 16 --b-adapt 2 --direct auto\n"
" --slow-firstpass --no-fast-pskip\n"
" --me tesa --merange 24 --partitions all\n"
" --bframes 16 --b-adapt 2 --direct auto\n"
" --slow-firstpass --no-fast-pskip\n"
" --me tesa --merange 24 --partitions all\n"
" --trellis 2\n" );
else H0( " - ultrafast,superfast,veryfast,faster,fast\n"
" - medium,slow,slower,veryslow,placebo\n" );
" --trellis 2\n" );
else H0( " - ultrafast,superfast,veryfast,faster,fast\n"
" - medium,slow,slower,veryslow,placebo\n" );
" - strict: Strictly hierarchical pyramid\n"
" - normal: Non-strict (not Blu-ray compatible)\n",
strtable_lookup( x264_b_pyramid_names, defaults->i_bframe_pyramid ) );
" - strict: Strictly hierarchical pyramid\n"
" - normal: Non-strict (not Blu-ray compatible)\n",
strtable_lookup( x264_b_pyramid_names, defaults->i_bframe_pyramid ) );
- H1( " --open-gop <string> Use recovery points to close GOPs [none]\n"
- " - none: closed GOPs only\n"
- " - normal: standard open GOPs\n"
- " (not Blu-ray compatible)\n"
- " - bluray: Blu-ray-compatible open GOPs\n"
+ H1( " --open-gop Use recovery points to close GOPs\n"
" Only available with b-frames\n" );
H1( " --no-cabac Disable CABAC\n" );
H1( " -r, --ref <integer> Number of reference frames [%d]\n", defaults->i_frame_reference );
" Only available with b-frames\n" );
H1( " --no-cabac Disable CABAC\n" );
H1( " -r, --ref <integer> Number of reference frames [%d]\n", defaults->i_frame_reference );
H2( " --fake-interlaced Flag stream as interlaced but encode progressive.\n"
" Makes it possible to encode 25p and 30p Blu-Ray\n"
" streams. Ignored in interlaced mode.\n" );
H2( " --fake-interlaced Flag stream as interlaced but encode progressive.\n"
" Makes it possible to encode 25p and 30p Blu-Ray\n"
" streams. Ignored in interlaced mode.\n" );
+ H2( " --frame-packing <integer> For stereoscopic videos define frame arrangement\n"
+ " - 0: checkerboard - pixels are alternatively from L and R\n"
+ " - 1: column alternation - L and R are interlaced by column\n"
+ " - 2: row alternation - L and R are interlaced by row\n"
+ " - 3: side by side - L is on the left, R on the right\n"
+ " - 4: top bottom - L is on top, R on bottom\n"
+ " - 5: frame alternation - one view per frame\n" );
H0( "\n" );
H0( "Ratecontrol:\n" );
H0( "\n" );
H1( " -q, --qp <integer> Force constant QP (0-%d, 0=lossless)\n", QP_MAX );
H0( " -B, --bitrate <integer> Set bitrate (kbit/s)\n" );
H0( "\n" );
H0( "Ratecontrol:\n" );
H0( "\n" );
H1( " -q, --qp <integer> Force constant QP (0-%d, 0=lossless)\n", QP_MAX );
H0( " -B, --bitrate <integer> Set bitrate (kbit/s)\n" );
- H0( " --crf <float> Quality-based VBR (%d-51) [%.1f]\n", 51 - QP_MAX, defaults->rc.f_rf_constant );
+ H0( " --crf <float> Quality-based VBR (%d-51) [%.1f]\n", 51 - QP_MAX_SPEC, defaults->rc.f_rf_constant );
H1( " --rc-lookahead <integer> Number of frames for frametype lookahead [%d]\n", defaults->rc.i_lookahead );
H0( " --vbv-maxrate <integer> Max local bitrate (kbit/s) [%d]\n", defaults->rc.i_vbv_max_bitrate );
H0( " --vbv-bufsize <integer> Set size of the VBV buffer (kbit) [%d]\n", defaults->rc.i_vbv_buffer_size );
H1( " --rc-lookahead <integer> Number of frames for frametype lookahead [%d]\n", defaults->rc.i_lookahead );
H0( " --vbv-maxrate <integer> Max local bitrate (kbit/s) [%d]\n", defaults->rc.i_vbv_max_bitrate );
H0( " --vbv-bufsize <integer> Set size of the VBV buffer (kbit) [%d]\n", defaults->rc.i_vbv_buffer_size );
H2( " --no-weightb Disable weighted prediction for B-frames\n" );
H1( " --weightp <integer> Weighted prediction for P-frames [%d]\n"
" - 0: Disabled\n"
H2( " --no-weightb Disable weighted prediction for B-frames\n" );
H1( " --weightp <integer> Weighted prediction for P-frames [%d]\n"
" - 0: Disabled\n"
H1( " --me <string> Integer pixel motion estimation method [\"%s\"]\n",
strtable_lookup( x264_motion_est_names, defaults->analyse.i_me_method ) );
H2( " - dia: diamond search, radius 1 (fast)\n"
H1( " --me <string> Integer pixel motion estimation method [\"%s\"]\n",
strtable_lookup( x264_motion_est_names, defaults->analyse.i_me_method ) );
H2( " - dia: diamond search, radius 1 (fast)\n"
" - 7: RD mode decision for all frames\n"
" - 8: RD refinement for I/P-frames\n"
" - 9: RD refinement for all frames\n"
" - 7: RD mode decision for all frames\n"
" - 8: RD refinement for I/P-frames\n"
" - 9: RD refinement for all frames\n"
- " - 10: QP-RD - requires trellis=2, aq-mode>0\n" );
- else H1( " decision quality: 1=fast, 10=best.\n" );
- H1( " --psy-rd Strength of psychovisual optimization [\"%.1f:%.1f\"]\n"
+ " - 10: QP-RD - requires trellis=2, aq-mode>0\n"
+ " - 11: Full RD: disable all early terminations\n" );
+ else H1( " decision quality: 1=fast, 11=best\n" );
+ H1( " --psy-rd <float:float> Strength of psychovisual optimization [\"%.1f:%.1f\"]\n"
" #1: RD (requires subme>=6)\n"
" #2: Trellis (requires trellis, experimental)\n",
defaults->analyse.f_psy_rd, defaults->analyse.f_psy_trellis );
" #1: RD (requires subme>=6)\n"
" #2: Trellis (requires trellis, experimental)\n",
defaults->analyse.f_psy_rd, defaults->analyse.f_psy_trellis );
" Takes a comma-separated list of 16 integers.\n" );
H2( " --cqm8 <list> Set all 8x8 quant matrices\n"
" Takes a comma-separated list of 64 integers.\n" );
" Takes a comma-separated list of 16 integers.\n" );
H2( " --cqm8 <list> Set all 8x8 quant matrices\n"
" Takes a comma-separated list of 64 integers.\n" );
- H2( " --cqm4i, --cqm4p, --cqm8i, --cqm8p\n"
+ H2( " --cqm4i, --cqm4p, --cqm8i, --cqm8p <list>\n"
- H2( " --cqm4iy, --cqm4ic, --cqm4py, --cqm4pc\n"
+ H2( " --cqm4iy, --cqm4ic, --cqm4py, --cqm4pc <list>\n"
H1( " --muxer <string> Specify output container format [\"%s\"]\n"
" - %s\n", muxer_names[0], stringify_names( buf, muxer_names ) );
H1( " --demuxer <string> Specify input container format [\"%s\"]\n"
" - %s\n", demuxer_names[0], stringify_names( buf, demuxer_names ) );
H1( " --muxer <string> Specify output container format [\"%s\"]\n"
" - %s\n", muxer_names[0], stringify_names( buf, muxer_names ) );
H1( " --demuxer <string> Specify input container format [\"%s\"]\n"
" - %s\n", demuxer_names[0], stringify_names( buf, demuxer_names ) );
H1( " --input-csp <string> Specify input colorspace format for raw input\n" );
print_csp_names( longhelp );
H1( " --input-csp <string> Specify input colorspace format for raw input\n" );
print_csp_names( longhelp );
H1( " --input-depth <integer> Specify input bit depth for raw input\n" );
H1( " --input-res <intxint> Specify input resolution (width x height)\n" );
H1( " --index <string> Filename for input index file\n" );
H1( " --input-depth <integer> Specify input bit depth for raw input\n" );
H1( " --input-res <intxint> Specify input resolution (width x height)\n" );
H1( " --index <string> Filename for input index file\n" );
H0( " --seek <integer> First frame to encode\n" );
H0( " --frames <integer> Maximum number of frames to encode\n" );
H0( " --level <string> Specify level (as defined by Annex A)\n" );
H0( " --seek <integer> First frame to encode\n" );
H0( " --frames <integer> Maximum number of frames to encode\n" );
H0( " --level <string> Specify level (as defined by Annex A)\n" );
H1( "\n" );
H1( " -v, --verbose Print stats for each frame\n" );
H1( " --no-progress Don't show the progress indicator while encoding\n" );
H1( "\n" );
H1( " -v, --verbose Print stats for each frame\n" );
H1( " --no-progress Don't show the progress indicator while encoding\n" );
{ "no-b-adapt", no_argument, NULL, 0 },
{ "b-bias", required_argument, NULL, 0 },
{ "b-pyramid", required_argument, NULL, 0 },
{ "no-b-adapt", no_argument, NULL, 0 },
{ "b-bias", required_argument, NULL, 0 },
{ "b-pyramid", required_argument, NULL, 0 },
- { "open-gop", required_argument, NULL, 0 },
+ { "open-gop", no_argument, NULL, 0 },
+ { "bluray-compat", no_argument, NULL, 0 },
{ "min-keyint", required_argument, NULL, 'i' },
{ "keyint", required_argument, NULL, 'I' },
{ "intra-refresh", no_argument, NULL, 0 },
{ "min-keyint", required_argument, NULL, 'i' },
{ "keyint", required_argument, NULL, 'I' },
{ "intra-refresh", no_argument, NULL, 0 },
{ "nal-hrd", required_argument, NULL, 0 },
{ "pulldown", required_argument, NULL, OPT_PULLDOWN },
{ "fake-interlaced", no_argument, NULL, 0 },
{ "nal-hrd", required_argument, NULL, 0 },
{ "pulldown", required_argument, NULL, OPT_PULLDOWN },
{ "fake-interlaced", no_argument, NULL, 0 },
{ "vf", required_argument, NULL, OPT_VIDEO_FILTER },
{ "video-filter", required_argument, NULL, OPT_VIDEO_FILTER },
{ "vf", required_argument, NULL, OPT_VIDEO_FILTER },
{ "video-filter", required_argument, NULL, OPT_VIDEO_FILTER },
{ "input-res", required_argument, NULL, OPT_INPUT_RES },
{ "input-csp", required_argument, NULL, OPT_INPUT_CSP },
{ "input-depth", required_argument, NULL, OPT_INPUT_DEPTH },
{ "dts-compress", no_argument, NULL, OPT_DTS_COMPRESSION },
{ "input-res", required_argument, NULL, OPT_INPUT_RES },
{ "input-csp", required_argument, NULL, OPT_INPUT_CSP },
{ "input-depth", required_argument, NULL, OPT_INPUT_DEPTH },
{ "dts-compress", no_argument, NULL, OPT_DTS_COMPRESSION },
param->b_annexb = 0;
param->b_repeat_headers = 0;
}
else if( !strcasecmp( ext, "flv" ) )
{
param->b_annexb = 0;
param->b_repeat_headers = 0;
}
else if( !strcasecmp( ext, "flv" ) )
{
if( !strcasecmp( module, "avs" ) || !strcasecmp( ext, "d2v" ) || !strcasecmp( ext, "dga" ) )
{
#if HAVE_AVS
if( !strcasecmp( module, "avs" ) || !strcasecmp( ext, "d2v" ) || !strcasecmp( ext, "dga" ) )
{
#if HAVE_AVS
}
#endif
if( b_auto && !raw_input.open_file( filename, p_handle, info, opt ) )
{
module = "raw";
b_auto = 0;
}
#endif
if( b_auto && !raw_input.open_file( filename, p_handle, info, opt ) )
{
module = "raw";
b_auto = 0;
-static int init_vid_filters( char *sequence, hnd_t *handle, video_info_t *info, x264_param_t *param )
+static int init_vid_filters( char *sequence, hnd_t *handle, video_info_t *info, x264_param_t *param, int output_csp )
- /* if the current csp is supported by libx264, have libx264 use this csp.
- * otherwise change the csp to I420 and have libx264 use this.
- * when more colorspaces are supported, this decision will need to be updated. */
+ /* force the output csp to what the user specified (or the default) */
+ param->i_csp = info->csp;
- if( csp > X264_CSP_NONE && csp < X264_CSP_MAX )
- param->i_csp = info->csp;
- else
- param->i_csp = X264_CSP_I420 | ( info->csp & X264_CSP_HIGH_DEPTH );
+ if( output_csp == X264_CSP_I420 && (csp < X264_CSP_I420 || csp > X264_CSP_NV12) )
+ param->i_csp = X264_CSP_I420;
+ else if( output_csp == X264_CSP_I444 && (csp < X264_CSP_I444 || csp > X264_CSP_YV24) )
+ param->i_csp = X264_CSP_I444;
+ else if( output_csp == X264_CSP_RGB && (csp < X264_CSP_BGR || csp > X264_CSP_RGB) )
+ param->i_csp = X264_CSP_RGB;
+ param->i_csp |= info->csp & X264_CSP_HIGH_DEPTH;
+
if( x264_init_vid_filter( "resize", handle, &filter, info, param, NULL ) )
return -1;
if( x264_init_vid_filter( "resize", handle, &filter, info, param, NULL ) )
return -1;
memset( &input_opt, 0, sizeof(cli_input_opt_t) );
memset( &output_opt, 0, sizeof(cli_output_opt_t) );
input_opt.bit_depth = 8;
memset( &input_opt, 0, sizeof(cli_input_opt_t) );
memset( &output_opt, 0, sizeof(cli_output_opt_t) );
input_opt.bit_depth = 8;
+ case OPT_OUTPUT_CSP:
+ FAIL_IF_ERROR( parse_enum_value( optarg, output_csp_names, &output_csp ), "Unknown output csp `%s'\n", optarg )
+ // correct the parsed value to the libx264 csp value
+ output_csp = !output_csp ? X264_CSP_I420 : (output_csp == 1 ? X264_CSP_I444 : X264_CSP_RGB);
+ break;
- FAIL_IF_ERROR( output.open_file( output_filename, &opt->hout, &output_opt ), "could not open output file `%s'\n", output_filename )
+ FAIL_IF_ERROR( cli_output.open_file( output_filename, &opt->hout, &output_opt ), "could not open output file `%s'\n", output_filename )
if( select_input( demuxer, demuxername, input_filename, &opt->hin, &info, &input_opt ) )
return -1;
if( select_input( demuxer, demuxername, input_filename, &opt->hin, &info, &input_opt ) )
return -1;
- FAIL_IF_ERROR( !opt->hin && input.open_file( input_filename, &opt->hin, &info, &input_opt ),
+ FAIL_IF_ERROR( !opt->hin && cli_input.open_file( input_filename, &opt->hin, &info, &input_opt ),
"could not open input file `%s'\n", input_filename )
x264_reduce_fraction( &info.sar_width, &info.sar_height );
"could not open input file `%s'\n", input_filename )
x264_reduce_fraction( &info.sar_width, &info.sar_height );
{
FAIL_IF_ERROR( b_user_fps, "--fps + --tcfile-in is incompatible.\n" )
FAIL_IF_ERROR( timecode_input.open_file( tcfile_name, &opt->hin, &info, &input_opt ), "timecode input failed\n" )
{
FAIL_IF_ERROR( b_user_fps, "--fps + --tcfile-in is incompatible.\n" )
FAIL_IF_ERROR( timecode_input.open_file( tcfile_name, &opt->hin, &info, &input_opt ), "timecode input failed\n" )
}
else FAIL_IF_ERROR( !info.vfr && input_opt.timebase, "--timebase is incompatible with cfr input\n" )
/* init threaded input while the information about the input video is unaltered by filtering */
}
else FAIL_IF_ERROR( !info.vfr && input_opt.timebase, "--timebase is incompatible with cfr input\n" )
/* init threaded input while the information about the input video is unaltered by filtering */
if( info.thread_safe && (b_thread_input || param->i_threads > 1
|| (param->i_threads == X264_THREADS_AUTO && x264_cpu_num_processors() > 1)) )
{
if( info.thread_safe && (b_thread_input || param->i_threads > 1
|| (param->i_threads == X264_THREADS_AUTO && x264_cpu_num_processors() > 1)) )
{
- if( init_vid_filters( vid_filters, &opt->hin, &info, param ) )
+ if( init_vid_filters( vid_filters, &opt->hin, &info, param, output_csp ) )
x264_cli_log( "x264", X264_LOG_WARNING, "input appears to be interlaced, enabling %cff interlaced mode.\n"
" If you want otherwise, use --no-interlaced or --%cff\n",
info.tff ? 't' : 'b', info.tff ? 'b' : 't' );
param->b_interlaced = 1;
param->b_tff = !!info.tff;
x264_cli_log( "x264", X264_LOG_WARNING, "input appears to be interlaced, enabling %cff interlaced mode.\n"
" If you want otherwise, use --no-interlaced or --%cff\n",
info.tff ? 't' : 'b', info.tff ? 'b' : 't' );
param->b_interlaced = 1;
param->b_tff = !!info.tff;
- i_frame_size = output.write_frame( hout, nal[0].p_payload, i_frame_size, &pic_out );
+ i_frame_size = cli_output.write_frame( hout, nal[0].p_payload, i_frame_size, &pic_out );
-static void print_status( int64_t i_start, int i_frame, int i_frame_total, int64_t i_file, x264_param_t *param, int64_t last_ts )
+static int64_t print_status( int64_t i_start, int64_t i_previous, int i_frame, int i_frame_total, int64_t i_file, x264_param_t *param, int64_t last_ts )
fprintf( stderr, "%s \r", buf+5 );
SetConsoleTitle( buf );
fflush( stderr ); // needed in windows
fprintf( stderr, "%s \r", buf+5 );
SetConsoleTitle( buf );
fflush( stderr ); // needed in windows
- int i_frame, i_frame_output;
- int64_t i_start, i_end;
+ int i_frame = 0;
+ int i_frame_output = 0;
+ int64_t i_end, i_previous = 0, i_start = 0;
- FAIL_IF_ERROR( fmod( param->i_fps_num * pulldown->fps_factor, 1 ),
- "unsupported framerate for chosen pulldown\n" )
+ FAIL_IF_ERROR2( fmod( param->i_fps_num * pulldown->fps_factor, 1 ),
+ "unsupported framerate for chosen pulldown\n" )
- if( ( h = x264_encoder_open( param ) ) == NULL )
- {
- x264_cli_log( "x264", X264_LOG_ERROR, "x264_encoder_open failed\n" );
- filter.free( opt->hin );
- return -1;
- }
+ h = x264_encoder_open( param );
+ FAIL_IF_ERROR2( !h, "x264_encoder_open failed\n" );
- if( output.set_param( opt->hout, param ) )
- {
- x264_cli_log( "x264", X264_LOG_ERROR, "can't set outfile param\n" );
- filter.free( opt->hin );
- output.close_file( opt->hout, largest_pts, second_largest_pts );
- return -1;
- }
+ FAIL_IF_ERROR2( cli_output.set_param( opt->hout, param ), "can't set outfile param\n" );
/* ticks/frame = ticks/second / frames/second */
ticks_per_frame = (int64_t)param->i_timebase_den * param->i_fps_den / param->i_timebase_num / param->i_fps_num;
/* ticks/frame = ticks/second / frames/second */
ticks_per_frame = (int64_t)param->i_timebase_den * param->i_fps_den / param->i_timebase_num / param->i_fps_num;
- FAIL_IF_ERROR( ticks_per_frame < 1 && !param->b_vfr_input, "ticks_per_frame invalid: %"PRId64"\n", ticks_per_frame )
+ FAIL_IF_ERROR2( ticks_per_frame < 1 && !param->b_vfr_input, "ticks_per_frame invalid: %"PRId64"\n", ticks_per_frame )
ticks_per_frame = X264_MAX( ticks_per_frame, 1 );
if( !param->b_repeat_headers )
ticks_per_frame = X264_MAX( ticks_per_frame, 1 );
if( !param->b_repeat_headers )
- FAIL_IF_ERROR( x264_encoder_headers( h, &headers, &i_nal ) < 0, "x264_encoder_headers failed\n" )
- if( (i_file = output.write_headers( opt->hout, headers )) < 0 )
- return -1;
+ FAIL_IF_ERROR2( x264_encoder_headers( h, &headers, &i_nal ) < 0, "x264_encoder_headers failed\n" )
+ FAIL_IF_ERROR2( (i_file = cli_output.write_headers( opt->hout, headers )) < 0, "error writing headers to output file\n" );
prev_dts = last_dts;
i_frame_size = encode_frame( h, opt->hout, &pic, &last_dts );
if( i_frame_size < 0 )
prev_dts = last_dts;
i_frame_size = encode_frame( h, opt->hout, &pic, &last_dts );
if( i_frame_size < 0 )
- if( opt->b_progress && i_frame_output % i_update_interval == 0 && i_frame_output )
- print_status( i_start, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
+ if( opt->b_progress && i_frame_output )
+ i_previous = print_status( i_start, i_previous, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
prev_dts = last_dts;
i_frame_size = encode_frame( h, opt->hout, NULL, &last_dts );
if( i_frame_size < 0 )
prev_dts = last_dts;
i_frame_size = encode_frame( h, opt->hout, NULL, &last_dts );
if( i_frame_size < 0 )
- if( opt->b_progress && i_frame_output % i_update_interval == 0 && i_frame_output )
- print_status( i_start, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
+ if( opt->b_progress && i_frame_output )
+ i_previous = print_status( i_start, i_previous, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
if( pts_warning_cnt >= MAX_PTS_WARNING && cli_log_level < X264_LOG_DEBUG )
x264_cli_log( "x264", X264_LOG_WARNING, "%d suppressed nonmonotonic pts warnings\n", pts_warning_cnt-MAX_PTS_WARNING );
if( pts_warning_cnt >= MAX_PTS_WARNING && cli_log_level < X264_LOG_DEBUG )
x264_cli_log( "x264", X264_LOG_WARNING, "%d suppressed nonmonotonic pts warnings\n", pts_warning_cnt-MAX_PTS_WARNING );
/* Erase progress indicator before printing encoding stats. */
if( opt->b_progress )
fprintf( stderr, " \r" );
/* Erase progress indicator before printing encoding stats. */
if( opt->b_progress )
fprintf( stderr, " \r" );
fprintf( stderr, "\n" );
if( b_ctrl_c )
fprintf( stderr, "aborted at input frame %d, output frame %d\n", opt->i_seek + i_frame, i_frame_output );
fprintf( stderr, "\n" );
if( b_ctrl_c )
fprintf( stderr, "aborted at input frame %d, output frame %d\n", opt->i_seek + i_frame, i_frame_output );
- if( opt->tcfile_out )
- {
- fclose( opt->tcfile_out );
- opt->tcfile_out = NULL;
- }
-
- filter.free( opt->hin );
- output.close_file( opt->hout, largest_pts, second_largest_pts );
+ cli_output.close_file( opt->hout, largest_pts, second_largest_pts );
+ opt->hout = NULL;