diff options
-rw-r--r-- | DOCS/man/en/options.rst | 7 | ||||
-rw-r--r-- | options/options.c | 2 | ||||
-rw-r--r-- | options/options.h | 2 | ||||
-rw-r--r-- | video/decode/vd_lavc.c | 7 |
4 files changed, 18 insertions, 0 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 9a24d3f01f..811fcf19dc 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -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 diff --git a/options/options.c b/options/options.c index 7377f666d9..173d3493cc 100644 --- a/options/options.c +++ b/options/options.c @@ -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})), diff --git a/options/options.h b/options/options.h index 6b482e2665..6ddb432867 100644 --- a/options/options.h +++ b/options/options.h @@ -94,6 +94,8 @@ typedef struct MPOpts { int requested_input_range; int requested_output_range; + int video_rotate; + char *audio_decoders; char *video_decoders; diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 1ba579abed..2593e50285 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -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, |