利用ffmpeg 将3D视频上下格式,左右格式转换为2D格式正常视频

xc
xc
2024-06-24 / 0 评论 / 5 阅读 / 正在检测是否收录...

概述

现在3D视频资源不多,虽然体感是不错,但穿戴麻烦,片源太大,在加上3DVR格式的加持,这东西半死不活,我有一个3D头盔,刚拿到手完了一段时间,现在一直在吃灰中。

3d-cover.jpg

手上有个三星公司出的3D视频,也是多年前从互联网下载的MTV,韩国男女团现场演唱会,很精彩,今天忽然想,要是能分享在我的视频页面就好了。

我的视频资源是上下格式的,在网上找以下资料,还是ffmpeg强大,原理到也简单,只保留左眼或右眼的视频,再调整一下画面比例就OK了。

videoproc-3d-to-2d-2.jpg

正文

上下/左右3D格式分离为2D正常视频

下面的代码是上下格式分离为正常的2D视频代码:相关的代码说明 stereo3d
最核心的代码就是:abl:ml
分离后,视频比例一般会失衡。所以用“-aspect 16:9”来调整视频画面比例,最后用“-vcodec h264” 编码转换为mp4格式。请根据自身情况,灵活调整。

上下格式代码

ffmpeg -i A.mkv -vf stereo3d=abl:ml -metadata:s:v:0 stereo_mode="mono"  -aspect 16:9 -vcodec h264 B.mp4

左右格式代码

ffmpeg -i A.mkv -vf stereo3d=sbsl:ml -metadata:s:v:0 stereo_mode="mono"  -aspect 16:9 -vcodec h264 B.mp4

这里copy一份stereo3d的官网内容,便于查询修改:

stereo3d

Convert between different stereoscopic image formats.

The filters accept the following options:

in
Set stereoscopic image format of input.

Available values for input image formats are:

‘sbsl’
side by side parallel (left eye left, right eye right)

‘sbsr’
side by side crosseye (right eye left, left eye right)

‘sbs2l’
side by side parallel with half width resolution (left eye left, right eye right)

‘sbs2r’
side by side crosseye with half width resolution (right eye left, left eye right)

‘abl’
‘tbl’
above-below (left eye above, right eye below)

‘abr’
‘tbr’
above-below (right eye above, left eye below)

‘ab2l’
‘tb2l’
above-below with half height resolution (left eye above, right eye below)

‘ab2r’
‘tb2r’
above-below with half height resolution (right eye above, left eye below)

‘al’
alternating frames (left eye first, right eye second)

‘ar’
alternating frames (right eye first, left eye second)

‘irl’
interleaved rows (left eye has top row, right eye starts on next row)

‘irr’
interleaved rows (right eye has top row, left eye starts on next row)

‘icl’
interleaved columns, left eye first

‘icr’
interleaved columns, right eye first

Default value is ‘sbsl’.

out
Set stereoscopic image format of output.

‘sbsl’
side by side parallel (left eye left, right eye right)

‘sbsr’
side by side crosseye (right eye left, left eye right)

‘sbs2l’
side by side parallel with half width resolution (left eye left, right eye right)

‘sbs2r’
side by side crosseye with half width resolution (right eye left, left eye right)

‘abl’
‘tbl’
above-below (left eye above, right eye below)

‘abr’
‘tbr’
above-below (right eye above, left eye below)

‘ab2l’
‘tb2l’
above-below with half height resolution (left eye above, right eye below)

‘ab2r’
‘tb2r’
above-below with half height resolution (right eye above, left eye below)

‘al’
alternating frames (left eye first, right eye second)

‘ar’
alternating frames (right eye first, left eye second)

‘irl’
interleaved rows (left eye has top row, right eye starts on next row)

‘irr’
interleaved rows (right eye has top row, left eye starts on next row)

‘arbg’
anaglyph red/blue gray (red filter on left eye, blue filter on right eye)

‘argg’
anaglyph red/green gray (red filter on left eye, green filter on right eye)

‘arcg’
anaglyph red/cyan gray (red filter on left eye, cyan filter on right eye)

‘arch’
anaglyph red/cyan half colored (red filter on left eye, cyan filter on right eye)

‘arcc’
anaglyph red/cyan color (red filter on left eye, cyan filter on right eye)

‘arcd’
anaglyph red/cyan color optimized with the least squares projection of dubois (red filter on left eye, cyan filter on right eye)

‘agmg’
anaglyph green/magenta gray (green filter on left eye, magenta filter on right eye)

‘agmh’
anaglyph green/magenta half colored (green filter on left eye, magenta filter on right eye)

‘agmc’
anaglyph green/magenta colored (green filter on left eye, magenta filter on right eye)

‘agmd’
anaglyph green/magenta color optimized with the least squares projection of dubois (green filter on left eye, magenta filter on right eye)

‘aybg’
anaglyph yellow/blue gray (yellow filter on left eye, blue filter on right eye)

‘aybh’
anaglyph yellow/blue half colored (yellow filter on left eye, blue filter on right eye)

‘aybc’
anaglyph yellow/blue colored (yellow filter on left eye, blue filter on right eye)

‘aybd’
anaglyph yellow/blue color optimized with the least squares projection of dubois (yellow filter on left eye, blue filter on right eye)

‘ml’
mono output (left eye only)

‘mr’
mono output (right eye only)

‘chl’
checkerboard, left eye first

‘chr’
checkerboard, right eye first

‘icl’
interleaved columns, left eye first

‘icr’
interleaved columns, right eye first

‘hdmi’
HDMI frame pack

Default value is ‘arcd’.

结尾

最终的效果,可以看我的视频页面-韩流来袭:
oh!-Girls Generationoh!-Girls Generation
sorry.sorry-Super Juniorsorry.sorry-Super Junior
是否很棒?
ffmpeg的更多用法,我已整理在一起了,请参考:
如何利用ffmpeg完成MKV转换MP4的视频格式,视频转gif图片格式。

0

评论 (0)

取消
使用 Typecho 建站,并搭配 joe 主题(有修改)
蜀ICP备2022005623号 川公网安备 51012202001212号
本站已运行 00000000
Copyright © 1970 ~ Xcshare All rights reserved.