[FFmpeg-devel] [PATCH] tools/aviocat: add support to input and output protocol options
Stefano Sabatini
stefasab at gmail.com
Thu Jan 31 21:06:55 CET 2013
---
tools/aviocat.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/tools/aviocat.c b/tools/aviocat.c
index f9c366a..c5e7b17d 100644
--- a/tools/aviocat.c
+++ b/tools/aviocat.c
@@ -44,7 +44,9 @@ static int usage(const char *argv0, int ret)
"-b set bytes per second\n"
"-h print this help\n"
"-i INPUT_URL set INPUT_URL\n"
- "-o OUTFILE set OUTFILE as output file\n");
+ "-I INPUT_URL_OPTS set INPUT_URL options\n"
+ "-o OUTFILE set OUTFILE as output file\n"
+ "-O OUTPUT_URL_OPTS set OUTPUT_URL options\n");
return ret;
}
@@ -52,6 +54,8 @@ int main(int argc, char **argv)
{
int bps = 0, ret, i;
const char *input_url = NULL, *output_url = NULL;
+ const char *input_url_opts = NULL, *output_url_opts = NULL;
+ AVDictionary *input_url_dict = NULL, *output_url_dict = NULL;
int64_t stream_pos = 0;
int64_t start_time;
char errbuf[50], c;
@@ -60,7 +64,7 @@ int main(int argc, char **argv)
av_register_all();
avformat_network_init();
- while ((c = getopt(argc, argv, "b:hi:o:")) != -1) {
+ while ((c = getopt(argc, argv, "b:hi:I:o:O:")) != -1) {
switch (c) {
case 'b':
bps = atoi(optarg);
@@ -70,9 +74,23 @@ int main(int argc, char **argv)
case 'i':
input_url = optarg;
break;
+ case 'I':
+ input_url_opts = optarg;
+ if (av_dict_parse_string(&input_url_dict, input_url_opts, "=", ",", 0) < 0) {
+ fprintf(stderr, "Cannot parse input options '%s'\n", input_url_opts);
+ return 1;
+ }
+ break;
case 'o':
output_url = optarg;
break;
+ case 'O':
+ output_url_opts = optarg;
+ if (av_dict_parse_string(&output_url_dict, output_url_opts, "=", ",", 0) < 0) {
+ fprintf(stderr, "Cannot parse output options '%s'\n", output_url_opts);
+ return 1;
+ }
+ break;
case '?':
return usage(argv[0], 1);
}
@@ -93,13 +111,13 @@ int main(int argc, char **argv)
return 1;
}
- ret = avio_open2(&input, input_url, AVIO_FLAG_READ, NULL, NULL);
+ ret = avio_open2(&input, input_url, AVIO_FLAG_READ, NULL, &input_url_dict);
if (ret) {
av_strerror(ret, errbuf, sizeof(errbuf));
fprintf(stderr, "Unable to open %s: %s\n", input_url, errbuf);
- return 1;
+ goto fail;
}
- ret = avio_open2(&output, output_url, AVIO_FLAG_WRITE, NULL, NULL);
+ ret = avio_open2(&output, output_url, AVIO_FLAG_WRITE, NULL, &output_url_dict);
if (ret) {
av_strerror(ret, errbuf, sizeof(errbuf));
fprintf(stderr, "Unable to open %s: %s\n", output_url, errbuf);
@@ -126,6 +144,8 @@ int main(int argc, char **argv)
avio_close(output);
fail:
+ av_dict_free(&input_url_dict);
+ av_dict_free(&output_url_dict);
avio_close(input);
avformat_network_deinit();
return ret ? 1 : 0;
--
1.7.9.5
More information about the ffmpeg-devel
mailing list