mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
27.77k stars 2.86k forks source link

Panorama 360 video support #8283

Open IlyaIndigo opened 3 years ago

IlyaIndigo commented 3 years ago

mpv https://www.youtube.com/watch?v=gsQUZMKUxqA

If you watch this 360 video on YouTube, then you can twist it. Through mpv it is played back giving a picture from all cameras at once, without understanding what to do with it. I want mpv to be able to work with panoramic 360 videos and to be able to scroll them with the mouse in the same way as on YouTube.

progandy commented 3 years ago

It is possible with a lua script that configures the v360 filter. https://github.com/dfaker/VR-reversal

mpv --profile=vrplay "$url"

# mpv.conf
[vrplay]
script=~~/360plugin.lua

For the some videos a slight modification is necessary:

diff --git a/360plugin.lua b/360plugin.lua
index a02a661..318a209 100644
--- a/360plugin.lua
+++ b/360plugin.lua
@@ -38,14 +38,14 @@ local init_dfov = 0.0

 local doit = 0.0
-local res  = 1.0
+local res  = 3.0
 local dragging = false

 local smoothMouse = true

 local scaling   = 'linear'

-local in_stereo = 'sbs'
+local in_stereo = '2d'

 local h_flip    = '0'
 local in_flip   = ''
@@ -183,12 +183,13 @@ end
 local updateFilters = function ()

    if not filterIsOn then
+       mp.command_native_async({"no-osd", "vf", "add", "format=nv12"}, function() end )
        mp.command_native_async({"no-osd", "vf", "add", string.format("@vrrev:%sv360=%s:%s:in_stereo=%s:out_stereo=2d:id_fov=%s:d_fov=%.3f:yaw=%.3f:pitch=%s:roll=%.3f:w=%s*192.0:h=%.3f*108.0:h_flip=%s:interp=%s",in_flip,inputProjection,outputProjection,in_stereo,idfov,dfov,yaw,pitch,roll,res,res,h_flip,scaling)}, updateComplete)
        filterIsOn=true
    else
        if not updateAwaiting then
            updateAwaiting=true
-           mp.command_native_async({"no-osd", "vf", "set", string.format("@vrrev:%sv360=%s:%s:in_stereo=%s:out_stereo=2d:id_fov=%s:d_fov=%.3f:yaw=%.3f:pitch=%s:roll=%.3f:w=%s*192.0:h=%.3f*108.0:h_flip=%s:interp=%s",in_flip,inputProjection,outputProjection,in_stereo,idfov,dfov,yaw,pitch,roll,res,res,h_flip,scaling)}, updateComplete)
+           mp.command_native_async({"no-osd", "vf", "set", string.format("format=nv12,@vrrev:%sv360=%s:%s:in_stereo=%s:out_stereo=2d:id_fov=%s:d_fov=%.3f:yaw=%.3f:pitch=%s:roll=%.3f:w=%s*192.0:h=%.3f*108.0:h_flip=%s:interp=%s",in_flip,inputProjection,outputProjection,in_stereo,idfov,dfov,yaw,pitch,roll,res,res,h_flip,scaling)}, updateComplete)
        end
        filterIsOn=true
    end
@@ -359,17 +360,19 @@ local switchInputFovBounds = function()
 end

 local switchStereoMode = function()
-   if in_stereo == 'sbs' then
+   if in_stereo == '2d' then
        in_stereo = 'tb'
-   else
+   elseif in_stereo == 'tb' then
        in_stereo = 'sbs'
+   else 
+       in_stereo = '2d'
    end
    mp.osd_message("Input format: " .. in_stereo,0.5)
    updateFilters()
 end

 local showHelp  = function()
-   mp.osd_message("Keyboard and Mouse Controls:\n? = show help\ny,h = adjust quality\ni,j,k,l,mouseClick = Look around\nu,i = roll head\n-,=,mouseWheel = zoom\nr = switch SetereoMode\nt = switch Eye\ne = switch Scaler\ng = toggle mouse smothing\nn = start and stop motion recording\n1,2 - cycle in and out projections",10)
+   mp.osd_message("Keyboard and Mouse Controls:\n? = show help\ny,h = adjust quality\ni,j,k,l,mouseClick = Look around\nu,0 = roll head\n-,=,mouseWheel = zoom\nr = switch StereoMode\nt = switch Eye\ne = switch Scaler\ng = toggle mouse smothing\nn = start and stop motion recording\n1,2 - cycle in and out projections",10)
 end

 local closeCurrentLog = function()