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

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th August 2017, 07:22   #2681  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Los Angeles, California
Posts: 2,000
@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
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated

Last edited by feisty2; 18th August 2017 at 07:24.
feisty2 is online now   Reply With Quote
Old 18th August 2017, 11:15   #2682  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,479
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   #2683  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: Los Angeles, California
Posts: 2,000
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
__________________
If I got new ideas, will post here: https://github.com/IFeelBloated
feisty2 is online now   Reply With Quote
Old Yesterday, 01:42   #2684  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 625
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 Yesterday, 08:30   #2685  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 5,250
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
Reply

Tags
speed, vaporware, vapoursynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 +1. The time now is 17:21.


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