aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-01-17 14:38:30 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-17 14:38:33 +0100
commitc8b99f8ad0589bf1bf5f107f44eb4b207bf6c431 (patch)
treefacc9a941ddc8fde6351c67da3d41cf60f95553c /tools
parent9f3a555b84ba5ddc948e0700719ea2f9796acbd5 (diff)
parent87acd33c092ab9e7d73686627e9105d99c1e4928 (diff)
downloadffmpeg-c8b99f8ad0589bf1bf5f107f44eb4b207bf6c431.tar.gz
Merge commit '87acd33c092ab9e7d73686627e9105d99c1e4928'
* commit '87acd33c092ab9e7d73686627e9105d99c1e4928': aviocat: Add support for specifying the input duration Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'tools')
-rw-r--r--tools/aviocat.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/aviocat.c b/tools/aviocat.c
index 42560cbc41..56b918e44d 100644
--- a/tools/aviocat.c
+++ b/tools/aviocat.c
@@ -26,13 +26,13 @@
static int usage(const char *argv0, int ret)
{
- fprintf(stderr, "%s [-b bytespersec] input_url output_url\n", argv0);
+ fprintf(stderr, "%s [-b bytespersec] [-d duration] input_url output_url\n", argv0);
return ret;
}
int main(int argc, char **argv)
{
- int bps = 0, ret, i;
+ int bps = 0, duration = 0, ret, i;
const char *input_url = NULL, *output_url = NULL;
int64_t stream_pos = 0;
int64_t start_time;
@@ -46,6 +46,9 @@ int main(int argc, char **argv)
if (!strcmp(argv[i], "-b") && i + 1 < argc) {
bps = atoi(argv[i + 1]);
i++;
+ } else if (!strcmp(argv[i], "-d") && i + 1 < argc) {
+ duration = atoi(argv[i + 1]);
+ i++;
} else if (!input_url) {
input_url = argv[i];
} else if (!output_url) {
@@ -63,6 +66,15 @@ int main(int argc, char **argv)
fprintf(stderr, "Unable to open %s: %s\n", input_url, errbuf);
return 1;
}
+ if (duration && !bps) {
+ int64_t size = avio_size(input);
+ if (size < 0) {
+ av_strerror(ret, errbuf, sizeof(errbuf));
+ fprintf(stderr, "Unable to get size of %s: %s\n", input_url, errbuf);
+ goto fail;
+ }
+ bps = size / duration;
+ }
ret = avio_open2(&output, output_url, AVIO_FLAG_WRITE, NULL, NULL);
if (ret) {
av_strerror(ret, errbuf, sizeof(errbuf));