Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th August 2017, 22:55   #2621  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by TheFluff View Post
Well, I dunno. Aside from DeleteFrames taking a list of ints, not a single int (I think) that kinda looks like it should work (maybe; I'm a bit unsure of what'll happen on the last frame of the clip). I don't think "source = abc.avi" is what's actually in your script though. What does happen when you try to run it?
There's no error, it skips the first return and just do the second return, which give me back the source clip.
lansing is offline   Reply With Quote
Old 14th August 2017, 23:28   #2622  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Are you sure about that? I suspect the problem might be that calling deleteframes there doesn't do what you think it does. It won't change the length of the clip returned by frameeval, I'm pretty darn sure. What I'd expect it to do is to replace even numbered frames with the following frame.

Last edited by TheFluff; 14th August 2017 at 23:31.
TheFluff is offline   Reply With Quote
Old 14th August 2017, 23:55   #2623  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by TheFluff View Post
Are you sure about that? I suspect the problem might be that calling deleteframes there doesn't do what you think it does. It won't change the length of the clip returned by frameeval, I'm pretty darn sure. What I'd expect it to do is to replace even numbered frames with the following frame.
Oh yes it did replace the even number frame with the odd one.

So I can't delete frames with arbitrary functions using FrameEval?
lansing is offline   Reply With Quote
Old 15th August 2017, 01:55   #2624  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
Quote:
Originally Posted by lansing View Post
Oh yes it did replace the even number frame with the odd one.

So I can't delete frames with arbitrary functions using FrameEval?
If you're clever you can reorder things. Note that frameeval takes a clip argument that's only used to set the output format and length. Adjist the total number of frames there.

Probably what you wanted to do. Halve the framecount and you're done.
Code:
def DeleteEven(n, clip):	
	return clip[n // 2]
Can also be expressed as clip[::2] without resorting to frameeval at all.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 15th August 2017, 11:48   #2625  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,100
Quote:
Originally Posted by lansing View Post
Oh yes it did replace the even number frame with the odd one.

So I can't delete frames with arbitrary functions using FrameEval?
You can't change the length of the clip, no. When you use FrameEval, the frame number requested from the clip you return from the evaluator function doesn't change. When the client application requests (say) frame 4, and your evaluator function gets n = 4 as an argument and returns a clip that's the same as the original but with frame 4 deleted, FrameEval requests frame 4 from that clip, but since you deleted the original frame 4, the frame now numbered 4 in that clip is number 5 in the original clip. That's why even numbered frames get replaced with the following even one.

The thing Myrsloik did relies on the fact that requesting a frame beyond the end of a clip just returns the last frame, so you get back a clip with the same length as the original, but every frame after the halfway point is just the same as the last.
TheFluff is offline   Reply With Quote
Old 16th August 2017, 18:54   #2626  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
Is there something like ffmpegs shuffleframes in Vapoursynth? (A filter which allows so swap and drop frames by a given pattern?)
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 16th August 2017, 18:56   #2627  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
Quote:
Originally Posted by Selur View Post
Is there something like ffmpegs shuffleframes in Vapoursynth? (A filter which allows so swap and drop frames by a given pattern?)
See frameeval. Especially the most recent posts. A simple callback and you can apply any remapping.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 16th August 2017, 19:00   #2628  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Isn't it easier with SelectEvery?
sneaker_ger is offline   Reply With Quote
Old 16th August 2017, 19:03   #2629  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
Quote:
Originally Posted by sneaker_ger View Post
Isn't it easier with SelectEvery?
If your pattern can be expressed with it. Yes. But it gets kinda iffy for 1000+ frame cycles and can't do stuff like drop all prime number frames.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 16th August 2017, 19:05   #2630  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
SelectEvery could do the dropping, but not the shuffling, or am I misunderstanding the filter?
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 16th August 2017, 19:06   #2631  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
Quote:
Originally Posted by Selur View Post
SelectEvery could do the dropping, but not the shuffling, or am I misunderstanding the filter?
Correct, no shuffle.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 16th August 2017, 19:13   #2632  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
I think Selur means "shuffle" as in "re-order with fixed pattern", not "re-order randomly".

So it should be able to do everything ffmpeg's shuffleframes can do.
sneaker_ger is offline   Reply With Quote
Old 16th August 2017, 19:17   #2633  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
Yes, given a pattern like for example "0 2 7 5 4 3 1 6 8" would do some crazy reordering on each set of 9 frames.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 16th August 2017, 19:20   #2634  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
Quote:
Originally Posted by Selur View Post
Yes, given a pattern like for example "0 2 7 5 4 3 1 6 8" would do some crazy reordering on each set of 9 frames.
I think that works. Try it and see. I probably made selectevery take the order into account.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 18th August 2017, 07:22   #2635  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
@Myrsloik
can you write something to convert a vaporsynth video clip to a numpy array and a reverse conversion like-wise? so, like
forward conversion: video clip -> numpy.array((framecount, height, width, channel))
reverse conversion: numpy.array((framecount, height, width, channel)) -> video clip
the conversion should only support GRAYS/RGBS/YUV444PS inputs obviously

the thing is... I wanna pre-process my image samples with vaporsynth before feeding them to keras
I could use vspipe to generate raw files and load them with numpy.memmap for now, but it sucks

Last edited by feisty2; 18th August 2017 at 07:24.
feisty2 is offline   Reply With Quote
Old 18th August 2017, 11:15   #2636  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,555
All frames are exposed as a memoryview. Just use get_frame(). I don't know the exact python way but I'm very certain you can create numpy arrays from memoryviews. Or maybe it already is one.

For the reverse you can probably use modifyframe (see the insane filter writing in python thread). No idea what the speed will be like, probably not that bad as long as you find the appropriate.

Or do it all in a single modifyframe callback. I have no idea what kind of preprocessing you want to do.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 18th August 2017, 13:57   #2637  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
Quote:
Originally Posted by Myrsloik View Post
I have no idea what kind of preprocessing you want to do.
say I wanna do a super resolution neural net with keras, first I would need to generate the corresponding low resolution version of the high resolution samples, and for that I need resampling filters.
there's scipy.misc.imresize but it's pretty rudimentary comparing to fmtc, it has very few resampling kernels, doesn't even have spline! and you can't tweak stuff like "taps" or whatever for each kernel, with fmtc I got control over everything, I can even create my own resampling kernel or resize under linear light
so I want vaporsynth (filters) to do stuff like that

concretely, something like
Code:
def GenLowResSamples(samples):
    core = vs.get_core()
    samples = ArrayToVideo(samples) #reverse conversion
    samples = core.fmtc.resample(samples, sample.width//2, sample.height//2, kernel="sinc", taps=128, fulls=True, fulld=True)
    samples = core.fmtc.resample(samples, sample.width*2, sample.height*2, kernel="sinc", taps=128, fulls=True, fulld=True)
    samples = VideoToArray(samples) #forward conversion
    return samples
feisty2 is offline   Reply With Quote
Old 20th August 2017, 01:42   #2638  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Hi I'm trying to frame serve a video from Adobe Premiere to Vapoursynth using this frame server called advanced frame server, when I try to grab it with avisource, the editor crashed and I got this error "setVideoInfo: The frame rate specified by AVISource must be a reduced fraction. (Instead, it is 23976/1000.)", and there's no option in avisource to change it.
lansing is offline   Reply With Quote
Old 20th August 2017, 08:30   #2639  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
Quote:
I think that works. Try it and see. I probably made selectevery take the order into account.
Works fine! Thanks to myrsloik and sneaker_ger for the help and pointing to SelectEvery() !
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 23rd August 2017, 02:24   #2640  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
Tried to implement r210 DIB. Have issue with VapourSynth-R38

r = core.avisource.AVISource('rgb.avi')
r = core.resize.Point(r, format=vs.RGB30)
r.set_output()

Source is 784x400 but appears to have 832*4 pitch from vs (I derived it from total size and it works).
Is this error on output or there is some rule for it?
__________________
VirtualDub2
shekh is offline   Reply With Quote
Reply

Tags
speed, vaporware, vapoursynth


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 +1. The time now is 12:04.


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