Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Video Editing/Mangling

Reply
 
Thread Tools Display Modes
Old 11-25-2018, 07:49 PM   #41
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

wwwmaze, btw, there's a typo in your YV12 version, it needs to be _1=eval_w*.5-1, in order to reset every scanline

I've merged the updated Gaussian kernel into my newer blur, here it is:
Code:
// Blur (Gaussian)
//@param1:sigma_parm 'Sigma' 10 0.5 100 25 0.1
//@param2:weight_mod 'Y modifier' 1 .25 4 1.0 0.01
//@param4:want_l 'leftward' 1 0 1 0 1
//@param5:want_r 'rightward' 1 0 1 0 1
//@param6:want_u 'upward' 1 0 1 0 1
//@param7:want_d 'downward' 1 0 1 0 1

in=0;

colorspace!='RGBA' ? colorspace='YV12';
input_info(in,project_w,project_h);
w=project_w; h=project_h;

function rot(new_ang, dest, blur) local(lw,lh,ang) (
  gfx_dest=dest;
  ang = (new_ang+4-c_ang)&3;
  c_ang = new_ang&3;
  lw=(c_ang&1) ? h:w;
  lh=(c_ang&1) ? w:h;
  ang==0 ? gfx_blit(c_last,0, 0,0,lw,lh,0,0,lw,lh) :
  ang==1 ? gfx_deltablit(c_last, 0,0, lw,lh, 0,   lw-1,  0, -1,  1,  0) :
  ang==2 ? gfx_deltablit(c_last, 0,0, lw,lh, lw-1,lh-1, -1,  0,  0, -1):
  ang==3 ? gfx_deltablit(c_last, 0,0, lw,lh, lh-1,0,     0,  1, -1,  0);
  blur ? (
    sigma = sigma_parm * ((c_ang&1)?weight_mod:1/weight_mod);
    sigma > 0.5 ? (
    
      q = sigma <=2.5 ? 3.97156-4.14554*sqrt(1-0.26891*sigma) : 0.98711*sigma-0.96330;
      b0 = 1.57825 + 2.44413*q + 1.4281*q^2 + 0.422205*q^3;
      b1 = 2.44413*q + 2.85619*q^2 + 1.26661*q^3;
      b2 = -1.4281*q^2 - 1.26661*q^3;
      b3 = 0.422205*q^3;
      BB = 1-(b1+b2+b3)/b0;
      b1b0=b1/b0;
      b2b0=b2/b0;
      b3b0=b3/b0;
    
      eval_w = lw; 
      gfx_evalrect(0,0,lw,lh, 
        colorspace=='RGBA' ? "
          (_1 -= 1) < 0 ? (
            _1=eval_w-1;
            _31=_21=_11=r; _32=_22=_12=g; _33=_23=_13=b;
          );
          r=BB*r + b1b0*_11 + b2b0*_21 +b3b0*_31; _31=_21; _21=_11; _11=r;
          g=BB*g + b1b0*_12 + b2b0*_22 +b3b0*_32; _32=_22; _22=_12; _12=g;
          b=BB*b + b1b0*_13 + b2b0*_23 +b3b0*_33; _33=_23; _23=_13; _13=b;
        " : "
          (_1 -= 1) < 0 ? (
            _1=eval_w*.5-1;
            _31=_21=_11=y1; _32=_22=_12=y3; _33=_23=_13=u; _34=_24=_14=v;
          );
          y1=BB*y1 + b1b0*_11 + b2b0*_21 +b3b0*_31;
          y2=BB*y2 + b1b0*y1 + b2b0*_11 +b3b0*_21; _31=_11; _21=y1; _11=y2;
          y3=BB*y3 + b1b0*_12 + b2b0*_22 +b3b0*_32;
          y4=BB*y4 + b1b0*y3 + b2b0*_12 +b3b0*_22; _32=_12; _22=y3; _12=y4;
          
          _90=BB*u + b1b0*_13 + b2b0*_23 +b3b0*_33;
          u=BB*u + b1b0*_90 + b2b0*_13 +b3b0*_23; _33=_13; _23=_90; _13=u;
          _91=BB*v + b1b0*_14 + b2b0*_24 +b3b0*_34;
          v=BB*v + b1b0*_91 + b2b0*_14 +b3b0*_24; _34=_14; _24=_91; _14=v;
        "
      );
    );
  );
  c_last=dest;
);

c_ang=0;
c_last=in;
max(sigma_parm/weight_mod,sigma_parm*weight_mod)>.5? (
  want_l ? rot(2, -1, 1);
  want_d ? rot(3, img3 = gfx_img_resize(img3,h,w),1);
  want_u ? rot(1, img2 = gfx_img_resize(img2,h,w),1);
  want_r || c_last==-1 ? rot(0, c_last==-1 ? (img1 = gfx_img_resize(img1,w,h)) : -1,want_r);
);
c_last != -1 ? rot(0, -1, 0);
Justin is offline   Reply With Quote
Old 11-26-2018, 12:58 AM   #42
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

Wow! This more and more looks like the battle of the titans. Like Muhammad Ali vs. George Foreman. Or maybe more like Magnus Carlsen and Fabiano Caruana?

Anyway. We are pretty happy about how this thread turned out. Many thanks.
Eliseat is offline   Reply With Quote
Old 11-26-2018, 02:18 PM   #43
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by Eliseat View Post
Wow! This more and more looks like the battle of the titans. Like Muhammad Ali vs. George Foreman. Or maybe more like Magnus Carlsen and Fabiano Caruana?

Anyway. We are pretty happy about how this thread turned out. Many thanks.
Except we get to add on to eachother's work
Justin is offline   Reply With Quote
Old 11-26-2018, 06:16 PM   #44
wwwmaze
Human being with feelings
 
Join Date: Oct 2009
Posts: 99
Default

Quote:
Originally Posted by Justin View Post
Here's a version that uses the native colorspace (YV12 or RGBA), rather than forcing a colorspace (colorspace conversion is quite slow by itself!)
Good idea! Great to know this about conversion too, thanks. It seems to make a rather big difference.

Quote:
Originally Posted by Justin View Post
and here is the lower quality linear blur with the same multi-colorspace support:
Really like that one!

Quote:
Originally Posted by Justin View Post
wwwmaze, btw, there's a typo in your YV12 version, it needs to be _1=eval_w*.5-1, in order to reset every scanline
Ha you're right! Quite silly one too. That's probably why my YV12 version was so slow.

Quote:
Originally Posted by Justin View Post
I've merged the updated Gaussian kernel into my newer blur, here it is:
That's my favorite one by now. Love the controls, thanks!

Quote:
Originally Posted by Eliseat View Post
Wow! This more and more looks like the battle of the titans. Like Muhammad Ali vs. George Foreman. Or maybe more like Magnus Carlsen and Fabiano Caruana?
Hehe no battle at all Without all the help from Justin and the assurance that my approach of rotating the workspace might not be that hacky as I initially thought I probably would have stopped after the first blur
It's awesome to know that many filters are really feasible.
wwwmaze is offline   Reply With Quote
Old 11-29-2018, 07:16 PM   #45
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Some improvements coming in the latest pre-release -- gfx_evalrect() can take flags to process right to left, or vertically, avoiding all of the image shuffling. I've updated the built-in blur presets to take advantage of this, they should both be quite a bit faster.
Justin is offline   Reply With Quote
Old 11-30-2018, 08:23 AM   #46
wwwmaze
Human being with feelings
 
Join Date: Oct 2009
Posts: 99
Default

Quote:
Originally Posted by Justin View Post
Some improvements coming in the latest pre-release -- gfx_evalrect() can take flags to process right to left, or vertically, avoiding all of the image shuffling. I've updated the built-in blur presets to take advantage of this, they should both be quite a bit faster.
How cool is that! The code looks so much cleaner now. Thanks a lot! And it's faster too (21% instead of 25% on my old Linux box here) classic win-win.

Just a heads up: If I set colorspace to 'RGB' in project settings and run this I420/YV12 video through any blur preset I'm getting reproducible crashes with dev1129. Not with the edge detection preset and not with dev1128.

Just saw the mention in the preset Thank you I'm feeling very honored man
(shhhh...originally not my work...got it from here: https://www.researchgate.net/publica...aussian_filter )
wwwmaze is offline   Reply With Quote
Old 11-30-2018, 08:51 AM   #47
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Quote:
Originally Posted by wwwmaze View Post
How cool is that! The code looks so much cleaner now. Thanks a lot! And it's faster too (21% instead of 25% on my old Linux box here) classic win-win.

Just a heads up: If I set colorspace to 'RGB' in project settings and run this I420/YV12 video through any blur preset I'm getting reproducible crashes with dev1129. Not with the edge detection preset and not with dev1128.

Just saw the mention in the preset Thank you I'm feeling very honored man
(shhhh...originally not my work...got it from here: https://www.researchgate.net/publica...aussian_filter )
Thanks, fixing! I tested the YV12 mode extensively (got it to produce byte-for-byte identical results to the old algorithm) but didn't really test RGBA, oops.
Justin is offline   Reply With Quote
Old 12-06-2018, 03:51 AM   #48
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

I left in last Pre release thread about about RGB color shift with blur, the common approach and the better one :


https://forum.cockos.com/showpost.ph...61&postcount=5


Can interest some of you here :P
X-Raym is offline   Reply With Quote
Old 12-06-2018, 06:20 AM   #49
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

Quote:
Originally Posted by X-Raym View Post
I left in last Pre release thread about about RGB color shift with blur, the common approach and the better one :


https://forum.cockos.com/showpost.ph...61&postcount=5


Can interest some of you here :P
Very interesting. And it seems its a pretty simple fix as shown in the video.

Many thanks for the info.

Btw: Why are you not coding in video processor? Is it not your programming language or is it just not your genre? I'm just curios as you are known for your lots of scripts in other areas.
Eliseat is offline   Reply With Quote
Old 12-06-2018, 11:36 AM   #50
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@Eliseat
I coded few things for video items but not actual new video processor preset indeed.


Basically, it's just that I'm used to video editor softwares which offers the tools I need (mostly GUI acceleration and RGB curves and advanced text tools) for video editing. I do use Video features in REAPER, mostly when I need to make a sound for video. Though basic color correction are very welcome in this case.


Also, it's pretty hard :P Justin code is very conzise, but there is more complexlity in it than all my scripts of the same size ^^


I keep an eye on new video features, native or user made.
X-Raym is offline   Reply With Quote
Old 12-21-2018, 10:30 AM   #51
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
Default

Quote:
Originally Posted by Eliseat View Post
Its like: "Can we fly to the moon?"
Wwwmaze, waving from the moon: "Yes, we can!"

HAHAHAHAHHAHA. Solid gold.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 12-21-2018, 10:32 AM   #52
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
Default

Quote:
Originally Posted by X-Raym View Post
I left in last Pre release thread about about RGB color shift with blur, the common approach and the better one :


https://forum.cockos.com/showpost.ph...61&postcount=5


Can interest some of you here :P
This is fascinating, by the way. Definitely needs to be seen.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 04-11-2023, 12:04 AM   #53
carbon
Human being with feelings
 
carbon's Avatar
 
Join Date: Feb 2008
Location: Eesti
Posts: 2,716
Default

I know I'm resurrecting an old thread, but I have a few questions about the blurs.

Which one of the above blur presets is best for faking or enhancing the depth of field blurriness?

How is it done selectively, meaning farther areas get progressively more blurred, with a gradient mask with alpha channel?
__________________
projektorn
carbon is offline   Reply With Quote
Old 04-11-2023, 05:38 AM   #54
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 679
Default

Quote:
Originally Posted by carbon View Post
I know I'm resurrecting an old thread, but I have a few questions about the blurs.

Which one of the above blur presets is best for faking or enhancing the depth of field blurriness?

How is it done selectively, meaning farther areas get progressively more blurred, with a gradient mask with alpha channel?
If you dig deep enough your should find a transparency mask preset in the "additional presets" sticky thread. Blur your image for background. Alpha mask your source again for foreground. That should do the trick.

Last edited by papagirafe; 04-11-2023 at 05:49 AM.
papagirafe is online now   Reply With Quote
Old 04-11-2023, 08:01 AM   #55
chip mcdonald
Human being with feelings
 
chip mcdonald's Avatar
 
Join Date: May 2006
Location: NA - North Augusta South Carolina
Posts: 4,294
Default

Please, when you're finished working out the various filter parameters, put them all in one plugin ui and refer to it by it's proper name:

__________________
]]] guitar lessons - www.chipmcdonald.com [[[
WEAR A FRAKKING MASK!!!!
chip mcdonald is offline   Reply With Quote
Old 04-11-2023, 03:30 PM   #56
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default

^^^That kind of thing is exceedingly complicated because distance from camera is not specifically encoded in the video file, so you either need a second video file in which that is encoded to act as a mask, or you need to somehow figure it out from the limited information available. I think the best algorithms are AI driven. We theoretically could do AI in VP, but it wouldn’t be a whole lot of fun.

If you have a static angle and a static background, you could might be able to use a static shot of the scene without your foreground subject to do some trickery to create a mask out of the difference between the actual scene and that background, but that requires forethought, and kind of only works to the extent that everything (lighting, exposure, focus, etc) is exactly the same except the moving foreground element. Honestly, it’s almost easier to just greenscreen it.
ashcat_lt is online now   Reply With Quote
Old 04-11-2023, 03:38 PM   #57
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
Default

Yeah, honestly, REAPER's video tools are not advanced enough to do this. Your best option would be to look to Davinci Resolve, but even that is not black magic ( See what I did there?)

You're asking software to generate a 3D map from 2D vision. It's easy for us to tell what is near and far in a shot, but that's because we have neural processing and a lot of historic data for what depth looks like.
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 04-11-2023, 03:44 PM   #58
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
Default

Quote:
Originally Posted by chip mcdonald View Post
XD XD XD
__________________
Puzzle Factory Sound Studios, London [Website] [Instagram]
[AMD 5800X, 32Gb RAM, Win10x64, NVidia GTX1080ti, UAD2-OCTO, FireFaceUCX, REAPER x64]
[Feature request: More details in Undo History]
daxliniere is offline   Reply With Quote
Old 04-11-2023, 10:39 PM   #59
carbon
Human being with feelings
 
carbon's Avatar
 
Join Date: Feb 2008
Location: Eesti
Posts: 2,716
Default

Quote:
Originally Posted by daxliniere View Post
Yeah, honestly, REAPER's video tools are not advanced enough to do this. Your best option would be to look to Davinci Resolve, but even that is not black magic ( See what I did there?)

You're asking software to generate a 3D map from 2D vision. It's easy for us to tell what is near and far in a shot, but that's because we have neural processing and a lot of historic data for what depth looks like.
I was more or less able to paint the mask by hand with gradients. There were a few spots where the far background peeked through a small moving opening.
So that would need the mask to be animated too. Because of that and the overall feel of the blur, I decided it isn't worth the hassle with this instance at least.

The Toneh is funny though.
__________________
projektorn
carbon is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:42 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.