1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 00:02:13 +00:00
mpv/player/screenshot.h
wm4 a3bd8c3b5f player: make screenshot each-frame mode more accurate
Due to asynchronicity, we generally can't guarantee that a video frame
matches up with other events such as playback time change exactly (since
decoding, presentation, and property update all happen at different
times). This is a complaint in the referenced bug report, where
screenshot filenames in each-frame screenshot did not use the correct
timestamp, and instead was lagging behind by 1 frame.

But in this case, synchronicity was already pretty much forced with wait
calls. The only problem was that the playback time was updated at a
later time, which results in the observed 1 frame lag. Fix this by
moving the place where the screenshot is triggered in this mode.

Normal screenshots may still have the old problem. There is no effort
made to guarantee the timestamps absolutely line up, same as with the
OSD. (If you want a guarantee, you need to use a video filter, such as
libavfilter's drawtext. These will obviously use the proper timestamp,
instead of going through the somewhat asynchronous property etc. system
in the player frontend.)

Fixes: #7433
2020-02-07 13:32:21 +01:00

47 lines
1.5 KiB
C

/*
* This file is part of mpv.
*
* mpv is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MPLAYER_SCREENSHOT_H
#define MPLAYER_SCREENSHOT_H
#include <stdbool.h>
struct MPContext;
struct mp_image;
struct mp_log;
struct mpv_global;
// One time initialization at program start.
void screenshot_init(struct MPContext *mpctx);
// Called by the playback core on each iteration.
void handle_each_frame_screenshot(struct MPContext *mpctx);
/* Return the image converted to the given format. If the pixel aspect ratio is
* not 1:1, the image is scaled as well. Returns NULL on failure.
* If global!=NULL, use command line scaler options etc.
*/
struct mp_image *convert_image(struct mp_image *image, int destfmt,
struct mpv_global *global, struct mp_log *log);
// Handlers for the user-facing commands.
void cmd_screenshot(void *p);
void cmd_screenshot_to_file(void *p);
void cmd_screenshot_raw(void *p);
#endif /* MPLAYER_SCREENSHOT_H */