Log in

View Full Version : Reformatting Internal Frame Format?


jmac698
22nd July 2012, 05:01
I was wondering if this would work, I wrote (well, mostly Gavino) a script called SplitByLines, which changes a video into a 480x longer video that happens to have a height of 2.
it seems to me that the actual video data in memory doesn't have to change at all, and there should be someway to change the video structure to just say it's now lines.
Is this possible?

Example 720x480 video is suddenly interpreted as 720x2 video and 480x longer length, with NO copying.

TheFluff
22nd July 2012, 05:27
I don't think so, not without rewriting the VideoFrame and PVideoFrame classes at least. The problem is that such a filter needs to create new video frames, and that involves calling env->NewVideoFrame() and copying data. I can't think of any remotely simple ways to work around this, but I might be missing something.

edit: actually, take a look at env->Subframe() and env->SubframePlanar(). That might do what you want, but I'm not sure if it involves copying or not.

jmac698
22nd July 2012, 05:43
Oh, and while I'm at it, it would be nice to convert video to audio. I've digitized video with my soundcard, only 6 pixels wide, but still :)
If the video were audio, you could use RMAA to measure VCR's specs like S/N, distortion, frequency response, all that stuff.
www.rmaa.org

I had a use to convert rgb to yuv as well, but those were the days before I could write plugins. I have a way of capturing component through composite, but I get Y+Pb which I have to subract Y from. They add perfectly in analog, Pb is +-.35 V and Y is 0-1V. For normal video they stay within a valid range. Btw you can create your own custom HD signal by tying Y and Pb together and using certain colors to fake an HSYNC signal :)

Gavino
22nd July 2012, 07:58
actually, take a look at env->Subframe() and env->SubframePlanar(). That might do what you want, but I'm not sure if it involves copying or not.
Yes, Subframe() and SubframePlanar() (used, for example, by Crop()) would help for this task.

Each call still creates a new VideoFrame object, but the frame buffer itself is not copied.

Wilbert
22nd July 2012, 12:54
SeparateRows(clip.height/2)

You have to wait until a new version comes out though ;)

edit: that will get you line 1 and height/2 for the first frame, line 2 and height/2+1 for the second frame. perhaps not want you want?

jmac698
22nd July 2012, 14:25
Well.. no... and it doesn't seem the natural way.
I mean

SeparateRows2(1)#clip was Y8 say, function means "Separate Rows n at a time"
frame0=line0@frame0
frame1=line1@frame0
...
frame479=line479@frame0
frame480=line0@frame1


SeparateRows2(2)
frame0=line0@frame0
line1@frame0
frame1=line2@frame0
line3@frame0
...
frame239=line478@frame0
line479@frame0
frame240=line0@frame1
line1@frame1

You'd also need CombineRows(240) which would combine 240 frames as a newframe0=stackvertical(frame0,frame1...frame239)

And this is why it's useful; now you can extend every plugin to work on lines or block individually. Imagine breaking it up into rows of 16 to do a special deblocking on the middle 8 rows, with some masktools magic, then chopping again into 8 high rows, then combining.
I've used it for dejitter processing.

#Deblock
src.clip(0,4,0,-4)#don't process first and last rows
odd=SeparateRows(16)#lines 4-19 etc. to process rows 8-15
even=src.clip(0,12,0,-12).SeparateRows(16)#lines 12-27 for rows 16-23
#I have a row of 8 and 4 pixels each side to play with
#maybe that's not what I wanted.. probably would be better to extract 4 pixel high rows at boundaries...
#combine
CombineRows(weave(odd,even),480-8)
stackvertical(src.crop(0,0,0,-476),last,src.crop(0,476,0,0))

If that makes any sense *sigh*