[x264-devel] Re: allow y4m input through stdin
Limin Wang
lance.lmwang at gmail.com
Tue Mar 13 11:49:07 CET 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
* Sam Mortimer <sam.mortimer at gmail.com> [2007-03-13 09:43:08 +0000]:
> >> I don't like magic names, however unlikely they are.
>
> Nor do I. I wrote the attached patch a few weeks ago. Key points:
>
> *) allows input and output file formats to be set using --input-format
> and --output-format.
> *) preserves existing filename based format selection. ie is backwards
> compatible.
> *) the input and output driver functions must be set after all option
> parsing is complete so all code (in Parse()) which relates to this has
> been moved to immediately below the option parsing block.
>
> Is this of any use? I'm happy to make changes if it needs a few
> pokes and prods.
>
> Regards,
> -Sam.
> --- x264.c.orig 2007-02-19 21:49:55.000000000 +0000
> +++ x264.c 2007-03-13 09:21:22.000000000 +0000
> @@ -142,7 +142,8 @@
> - /* Get the file name */
> + /* Determine output format and filename and then open */
> + if( !out_fname )
> + {
> + fprintf( stderr, "x264 [error]: No output file. Run x264 --help for a list of options.\n");
> + return -1;
> + }
> + out_ext=out_fname + strlen(out_fname) - 4;
> + if( out_ext < out_fname )
> + out_ext = out_fname; /* filename is < 4 chars long */
You're assuming the file extension is 4 chars. General way to get file
extension:
out_ext = strchr(out_fname, '.');
if(out_ext) {
fprintf( stderr, "no output file extension, use default output \n");
}
> + /* Default output file driver */
> + p_open_outfile = open_file_bsf;
> + p_set_outfile_param = set_param_bsf;
> + p_write_nalu = write_nalu_bsf;
> + p_set_eop = set_eop_bsf;
> + p_close_outfile = close_file_bsf;
> + if( (out_fmt && !strcasecmp(out_fmt, "mp4"))
> + || (!out_fmt && !strncasecmp(out_ext, ".mp4", 4)) )
> + {
> +#ifdef MP4_OUTPUT
> + p_open_outfile = open_file_mp4;
> + p_write_nalu = write_nalu_mp4;
> + p_set_outfile_param = set_param_mp4;
> + p_set_eop = set_eop_mp4;
> + p_close_outfile = close_file_mp4;
> +#else
> + fprintf( stderr, "x264 [error]: not compiled with MP4 output support\n" );
> + return -1;
> +#endif
> + }
> + else if( (out_fmt && !strcasecmp(out_fmt, "mkv"))
> + || (!out_fmt && !strncasecmp(out_ext, ".mkv", 4)) )
> + {
> + p_open_outfile = open_file_mkv;
> + p_write_nalu = write_nalu_mkv;
> + p_set_outfile_param = set_param_mkv;
> + p_set_eop = set_eop_mkv;
> + p_close_outfile = close_file_mkv;
> + }
> + else if( out_fmt && strcmp(out_fmt, "264") )
> + {
> + fprintf( stderr, "x264 [error]: Invalid output file format. "
> + "Run x264 --help for a list of options.\n" );
> + return -1;
> + }
> + if( !strcmp(out_fname, "-") )
> + opt->hout = stdout;
> + else if( p_open_outfile( out_fname, &opt->hout ) )
> + {
> + fprintf( stderr, "x264 [error]: can't open output file `%s'\n", out_fname );
> + return -1;
> + }
> + if( out_fmt )
> + free( out_fmt );
> + free( out_fname );
> + /* End of output format determination and file open */
> +
> + /* Determine input format and filename and then open */
> + /* Get the input file name */
> if( optind > argc - 1 || !opt->hout )
> {
> fprintf( stderr, "x264 [error]: No %s file. Run x264 --help for a list of options.\n",
> optind > argc - 1 ? "input" : "output" );
> return -1;
> }
> - psz_filename = argv[optind++];
> + in_fname = argv[optind++];
> + in_ext=in_fname + strlen(in_fname) - 4;
> + if( in_ext < in_fname )
> + in_ext = in_fname; /* filename is < 4 chars long */
[...]
Thanks,
Limin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iQEVAwUBRfaBokztbf7dKiuoAQKlIAf/efVJQy4IyPAktm4XUvAVWRnspPqWtwpq
ej6Resqp2+HwgfH6/bbnfHKI9LCp90uytvv/12gaC+XDTa+0Kam8eR2KRf99q0ve
idvW5bYIAzDpgePf25xbARenjV9LNpIBTE6sreCs99an9QxN9/v55AXt6Lt3Zjwp
7ZIPd+yXb0tjntVtn0+qQOWF/xdk8u46toVYQuPRMcBBKqPzSq1yiOtzJikFtlgN
EJyI1l6sBc48ND8Owvrb7B7AvcixElXrZ9jhif5Q+yKOB6zAaSlV2dIgZO9vuiP6
f8mGkL3lLIbiFHNcjgkdyQ5xjeWcdeY1N/HOOQ4Ncrgdm27YZcOoFQ==
=Ditw
-----END PGP SIGNATURE-----
--
This is the x264-devel mailing-list
To unsubscribe, go to: http://developers.videolan.org/lists.html
More information about the x264-devel
mailing list