[FFmpeg-devel] [PATCH 1/1] Add Mono/2D option to stereo3d filter
James Lancaster
deathstalker at gmail.com
Mon May 9 23:23:09 EEST 2022
The following patch adds the option for mono input to the stereo3d filter,
allowing a 2D video source to be duplicated to any of the output formats.
This enables a few things which I find very useful:
1. Playing regular videos on VR headsets.
Using this to simply use the VR headset as a HMD without affecting anything
else.
Example usage: ffplay -vf stereo3d=mono:sbsl 2dvideofile.avi
Will simply modify it to display everywhere.
2. Screen capture and display on VR headsets as a 2D video.
This is something which for me works FAR better than any of the VR
'desktop' software which enables you to use your desktop in a VR space
(which always gives me a headache). In fact even watching videos of it
gives me a headache. Whereas I spent about 5 hours using my system this way
yesterday with no headache or problems aside from that (well and the whole
not being able to see things)
Note for anyone using this: I do recommend only going lower to the same
resolution or higher resolution, if possible.
Examples: (Main monitor set at 1280x1024 and off, and the VR headset)
Basic capture:
ffplay -vf stereo3d=mono:sbsl -video_size 1280x1024 -f x11grab :0.0+0,0
Also to pad it out, so you can see all of it. (Most Desktops aren't quite
setup for circular view.) This adds a 300 px border around the left/right
(and by default top bottom) which means that everything is in view in my
headset.
ffplay -vf pad=1580:1080:150:0,stereo3d=mono:sbsl -video_size 1280x1024 -f
x11grab :0.0+0,0
The default is pretty much exactly what is needed (frame copied to both
right and left output) this patch is pretty trivial, and I've used it on
multiple versions, but forgot to submit the patch for it in the past.
Since I don't see anything in particular about it, just to cover bases (And
if there's anything I did wrong, let me know so I can fix it in future
submissions):
Permission to apply and redistribute under the GNU GPL v2 or later versions
granted (As is the case for the file)
2022 James Lancaster
---
libavfilter/vf_stereo3d.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libavfilter/vf_stereo3d.c b/libavfilter/vf_stereo3d.c
index 0ba18861af..09397af14a 100644
--- a/libavfilter/vf_stereo3d.c
+++ b/libavfilter/vf_stereo3d.c
@@ -66,6 +66,7 @@ enum StereoCode {
INTERLEAVE_COLS_LR, // column-interleave (left eye first, right eye
second)
INTERLEAVE_COLS_RL, // column-interleave (right eye first, left eye
second)
HDMI, // HDMI frame pack (left eye first, right eye
second)
+ MONO, // Mono input for 2d to 3d
STEREO_CODE_COUNT // TODO: needs autodetection
};
@@ -177,6 +178,7 @@ static const AVOption stereo3d_options[] = {
{ "irr", "interleave rows right first", 0, AV_OPT_TYPE_CONST,
{.i64=INTERLEAVE_ROWS_RL}, 0, 0, FLAGS, "in" },
{ "icl", "interleave columns left first", 0, AV_OPT_TYPE_CONST,
{.i64=INTERLEAVE_COLS_LR}, 0, 0, FLAGS, "in" },
{ "icr", "interleave columns right first", 0, AV_OPT_TYPE_CONST,
{.i64=INTERLEAVE_COLS_RL}, 0, 0, FLAGS, "in" },
+ { "mono", "2D video", 0,
AV_OPT_TYPE_CONST, {.i64=MONO}, 0, 0, FLAGS, "in" },
{ "out", "set output format", OFFSET(out.format), AV_OPT_TYPE_INT,
{.i64=ANAGLYPH_RC_DUBOIS}, 0, STEREO_CODE_COUNT-1, FLAGS, "out"},
{ "ab2l", "above below half height left first", 0, AV_OPT_TYPE_CONST,
{.i64=ABOVE_BELOW_2_LR}, 0, 0, FLAGS, "out" },
{ "tb2l", "above below half height left first", 0, AV_OPT_TYPE_CONST,
{.i64=ABOVE_BELOW_2_LR}, 0, 0, FLAGS, "out" },
@@ -452,6 +454,8 @@ static int config_output(AVFilterLink *outlink)
s->out.format != CHECKERBOARD_RL)
s->height = inlink->h / 2;
break;
+ case MONO:
+ break;
default:
av_log(ctx, AV_LOG_ERROR, "input format %d is not supported\n",
s->in.format);
return AVERROR(EINVAL);
--
2.32.0
More information about the ffmpeg-devel
mailing list