mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 04:07:08 +00:00
video: add --video-rotate option for controlling auto-rotation
This commit is contained in:
parent
8665f78018
commit
6125ba613f
@ -2698,6 +2698,13 @@ OPTIONS
|
||||
|
||||
This option is disabled if the ``--no-keepaspect`` option is used.
|
||||
|
||||
``--video-rotate=<0-359|no>``
|
||||
Rotate the video clockwise, in degrees. Currently supports 90° steps only.
|
||||
If ``no`` is given, the video is never rotated, even if the file has
|
||||
rotation metadata. (The rotation value is added to the rotation metadata,
|
||||
which means the value ``0`` would rotate the video according to the
|
||||
rotation metadata.)
|
||||
|
||||
``--video-unscaled``
|
||||
Disable scaling of the video. If the window is larger than the video,
|
||||
black bars are added. Otherwise, the video is cropped. The video still
|
||||
|
@ -498,6 +498,8 @@ const m_option_t mp_opts[] = {
|
||||
({"auto", MP_CSP_LEVELS_AUTO},
|
||||
{"limited", MP_CSP_LEVELS_TV},
|
||||
{"full", MP_CSP_LEVELS_PC})),
|
||||
OPT_CHOICE_OR_INT("video-rotate", video_rotate, 0, 0, 359,
|
||||
({"no", -1})),
|
||||
|
||||
OPT_CHOICE_OR_INT("cursor-autohide", cursor_autohide_delay, 0,
|
||||
0, 30000, ({"no", -1}, {"always", -2})),
|
||||
|
@ -94,6 +94,8 @@ typedef struct MPOpts {
|
||||
int requested_input_range;
|
||||
int requested_output_range;
|
||||
|
||||
int video_rotate;
|
||||
|
||||
char *audio_decoders;
|
||||
char *video_decoders;
|
||||
|
||||
|
@ -420,6 +420,7 @@ static void update_image_params(struct dec_video *vd, AVFrame *frame,
|
||||
struct mp_image_params *out_params)
|
||||
{
|
||||
vd_ffmpeg_ctx *ctx = vd->priv;
|
||||
struct MPOpts *opts = ctx->opts;
|
||||
int width = frame->width;
|
||||
int height = frame->height;
|
||||
float aspect = av_q2d(frame->sample_aspect_ratio) * width / height;
|
||||
@ -448,6 +449,12 @@ static void update_image_params(struct dec_video *vd, AVFrame *frame,
|
||||
avchroma_location_to_mp(ctx->avctx->chroma_sample_location),
|
||||
.rotate = vd->header->video->rotate,
|
||||
};
|
||||
|
||||
if (opts->video_rotate < 0) {
|
||||
out_params->rotate = 0;
|
||||
} else {
|
||||
out_params->rotate = (out_params->rotate + opts->video_rotate) % 360;
|
||||
}
|
||||
}
|
||||
|
||||
static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx,
|
||||
|
Loading…
Reference in New Issue
Block a user