summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-03-25 23:44:32 +0100
committerwm4 <wm4@nowhere>2013-03-26 01:29:53 +0100
commit790df511c4aad28c64998783b5b599e88177356e (patch)
tree1e0ad36033de405ea2641f79d5744fc68f3771c1
parent54e8e0a50207283d1cbe595e69e5cd10c346ed40 (diff)
downloadmpv-790df511c4aad28c64998783b5b599e88177356e.tar.bz2
mpv-790df511c4aad28c64998783b5b599e88177356e.tar.xz
core: output --playing-msg message only after at least one frame is shown
This way it's possible to retrieve correct information about video, like actual width/height, which in general are available only after at least one frame has been sent to the video output, such as dwidth/dheight. mpv_identify.sh becomes a bit slower, because we let it decode enough audio and video to fill the audio buffers and to send one frame to the video output. Also, --playing-msg isn't shown anymore with --frames=0 (could be fixed by special-casing it, should this break any use cases). Note that in some corner cases, like when the demuxer for some reason returns lots of audio packets but no video packets at the start, but video actually starts later, the --playing-msg will still be output before video starts.
-rw-r--r--DOCS/man/en/options.rst2
-rwxr-xr-xTOOLS/mpv_identify.sh2
-rw-r--r--core/mp_core.h1
-rw-r--r--core/mplayer.c14
4 files changed, 11 insertions, 8 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 6651e97a67..91078b2424 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1455,7 +1455,7 @@
*WARNING*: works with the deprecated ``mp_http://`` protocol only.
--playing-msg=<string>
- Print out a string before starting playback. The string is expanded for
+ Print out a string after starting playback. The string is expanded for
properties, e.g. ``--playing-msg=file: ${filename}`` will print the string
``file:`` followed by a space and the currently played filename.
diff --git a/TOOLS/mpv_identify.sh b/TOOLS/mpv_identify.sh
index cd006c5db5..34c67a18a1 100755
--- a/TOOLS/mpv_identify.sh
+++ b/TOOLS/mpv_identify.sh
@@ -100,7 +100,7 @@ for __midentify__key in $__midentify__allprops; do
eval unset $__midentify__nextprefix$__midentify__key
done
-__midentify__output=`mpv --playing-msg="$__midentify__propstr" --vo=null --ao=null --frames=0 "$@"`
+__midentify__output=`mpv --playing-msg="$__midentify__propstr" --vo=null --ao=null --frames=1 "$@"`
__midentify__fileindex=0
__midentify__prefix=
while :; do
diff --git a/core/mp_core.h b/core/mp_core.h
index 8e76160a08..206ad030c9 100644
--- a/core/mp_core.h
+++ b/core/mp_core.h
@@ -255,6 +255,7 @@ typedef struct MPContext {
int step_frames;
// Counted down each frame, stop playback if 0 is reached. (-1 = disable)
int max_frames;
+ bool playing_msg_shown;
bool paused_for_cache;
diff --git a/core/mplayer.c b/core/mplayer.c
index ed8505251a..1a79213bdc 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -3397,6 +3397,13 @@ static void run_playloop(struct MPContext *mpctx)
update_subtitles(mpctx, a_pos);
}
+ if (opts->playing_msg && !mpctx->playing_msg_shown && new_frame_shown) {
+ mpctx->playing_msg_shown = true;
+ char *msg = mp_property_expand_string(mpctx, opts->playing_msg);
+ mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s\n", msg);
+ talloc_free(msg);
+ }
+
/* It's possible for the user to simultaneously switch both audio
* and video streams to "disabled" at runtime. Handle this by waiting
* rather than immediately stopping playback due to EOF.
@@ -4013,12 +4020,6 @@ goto_enable_cache: ;
goto terminate_playback;
}
- if (opts->playing_msg) {
- char *msg = mp_property_expand_string(mpctx, opts->playing_msg);
- mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s\n", msg);
- talloc_free(msg);
- }
-
// Disable the term OSD in verbose mode
if (verbose)
opts->term_osd = 0;
@@ -4079,6 +4080,7 @@ goto_enable_cache: ;
mpctx->step_frames = 0;
mpctx->total_avsync_change = 0;
mpctx->last_chapter_seek = -2;
+ mpctx->playing_msg_shown = false;
// If there's a timeline force an absolute seek to initialize state
double startpos = rel_time_to_abs(mpctx, opts->play_start, -1);