summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-11 22:40:46 +0200
committerwm4 <wm4@nowhere>2013-05-12 21:57:02 +0200
commit989b482bd601013392e0797d4585d4c189127d19 (patch)
tree7e64fb004db217fd3d5f50972e3f23f371da78f0
parentfaad40aad92d51290ef2fc4d94277eca89863873 (diff)
downloadmpv-989b482bd601013392e0797d4585d4c189127d19.tar.bz2
mpv-989b482bd601013392e0797d4585d4c189127d19.tar.xz
core: re-add -dumpstream as --stream-dump
Apparently useful for dumping DVD. Could also be used to rip streams with libquvi and such, but for that there are better tools. Actually I doubt there aren't better tools to dump DVDs, but whatever, this was a feature request, so I don't need a good reason.
-rw-r--r--DOCS/man/en/changes.rst2
-rw-r--r--DOCS/man/en/options.rst4
-rw-r--r--core/cfg-mplayer.h1
-rw-r--r--core/mplayer.c34
-rw-r--r--core/options.h1
5 files changed, 42 insertions, 0 deletions
diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst
index 20f6be553a..4c80af6b25 100644
--- a/DOCS/man/en/changes.rst
+++ b/DOCS/man/en/changes.rst
@@ -125,6 +125,8 @@ Command line switches
-x W, -y H --geometry=WxH + --no-keepaspect
-xy W --autofit=W
-a52drc level --ad-lavc-ac3drc=level
+ -dumpstream --stream-dump=<filename>
+ -capture --stream-capture=<filename>
=================================== ===================================
*NOTE*: ``-opt val`` becomes ``--opt=val``.
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 2f3e5bf38d..453b49d30e 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1537,6 +1537,10 @@
interrupted. Note that, due to cache latencies, captured data may begin and
end somewhat delayed compared to what you see displayed.
+--stream-dump=<filename>
+ Same as ``--stream-capture``, but don't start playback. Instead, the full
+ file is dumped.
+
--playlist=<filename>
Play files according to a playlist file (ASX, Winamp, SMIL, or
one-file-per-line format).
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h
index 9feb82f9cd..b386cb53e8 100644
--- a/core/cfg-mplayer.h
+++ b/core/cfg-mplayer.h
@@ -635,6 +635,7 @@ const m_option_t mplayer_opts[]={
OPT_FLAG("untimed", untimed, 0),
OPT_STRING("stream-capture", stream_capture, 0),
+ OPT_STRING("stream-dump", stream_dump, 0),
#ifdef CONFIG_LIRC
{"lircconf", &lirc_configfile, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL},
diff --git a/core/mplayer.c b/core/mplayer.c
index ed8de9eb36..abd306426d 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -4105,6 +4105,35 @@ static void idle_loop(struct MPContext *mpctx)
}
}
+static void stream_dump(struct MPContext *mpctx)
+{
+ struct MPOpts *opts = &mpctx->opts;
+ char *filename = opts->stream_dump;
+ stream_t *stream = mpctx->stream;
+ assert(stream && filename);
+
+ stream_set_capture_file(stream, filename);
+
+ while (mpctx->stop_play == KEEP_PLAYING && !stream->eof) {
+ if (!opts->quiet && ((stream->pos / (1024 * 1024)) % 2) == 1) {
+ uint64_t pos = stream->pos - stream->start_pos;
+ uint64_t end = stream->end_pos - stream->start_pos;
+ char *line = talloc_asprintf(NULL, "Dumping %lld/%lld...",
+ (long long int)pos, (long long int)end);
+ write_status_line(mpctx, line);
+ talloc_free(line);
+ }
+ stream_fill_buffer(stream);
+ for (;;) {
+ mp_cmd_t *cmd = mp_input_get_cmd(mpctx->input, 0, false);
+ if (!cmd)
+ break;
+ run_command(mpctx, cmd);
+ talloc_free(cmd);
+ }
+ }
+}
+
// Start playing the current playlist entry.
// Handle initialization and deinitialization.
static void play_current_file(struct MPContext *mpctx)
@@ -4221,6 +4250,11 @@ static void play_current_file(struct MPContext *mpctx)
}
mpctx->stream->start_pos += opts->seek_to_byte;
+ if (opts->stream_dump && opts->stream_dump[0]) {
+ stream_dump(mpctx);
+ goto terminate_playback;
+ }
+
// CACHE2: initial prefill: 20% later: 5% (should be set by -cacheopts)
#ifdef CONFIG_DVBIN
goto_enable_cache: ;
diff --git a/core/options.h b/core/options.h
index 09cf20c852..b5370ebac7 100644
--- a/core/options.h
+++ b/core/options.h
@@ -86,6 +86,7 @@ typedef struct MPOpts {
char *vobsub_name;
int untimed;
char *stream_capture;
+ char *stream_dump;
int loop_times;
int ordered_chapters;
int chapter_merge_threshold;