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,049
@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 offline   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,519
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,049
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 offline   Reply With Quote
Old 20th August 2017, 01:42   #2684  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 698
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   #2685  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 5,263
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   #2686  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 373
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?
__________________
VirtualDub FilterMod
shekh is offline   Reply With Quote
Old 23rd August 2017, 06:47   #2687  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,519
Quote:
Originally Posted by lansing View Post
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.
Wil be fixed in the next version
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 23rd August 2017, 06:59   #2688  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,519
Quote:
Originally Posted by shekh View Post
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?
Pitch is a multiple of 256 bytes. Can't even find a source on it rogjt now.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 23rd August 2017, 09:35   #2689  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 373
Quote:
Originally Posted by Myrsloik View Post
Pitch is a multiple of 256 bytes. Can't even find a source on it rogjt now.
Good, found it in ffmpeg code.
__________________
VirtualDub FilterMod
shekh is offline   Reply With Quote
Old 23rd August 2017, 09:39   #2690  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,519
Quote:
Originally Posted by shekh View Post
Good, found it in ffmpeg code.
Note that you can't always assume it because for v210 and r210 and just about every format with special stride requirements at least half the software gets it wrong. Fun fact.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 24th August 2017, 18:36   #2691  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,519
Here's R39 test1

It would be a proper RC if it wasn't for a bit more optimization and refactoring I want to do in the 3x3 pixel filter part of the code (aka the previously known as genericfilters part).

Glorious changes:
Code:
r39:
fixed missing fps correction in avisource that would produce an error with some files
switched to nasm as the assembler
updated to zimg v2.6
visual studio runtime detection is improved in the installer, it should no longer attempt re-installs when a newer version is present
minor optimization in vspipe, you can now output blankclip into the void much faster
memory will now be 64 byte aligned on systems with avx512 support
added swapn and dupn operators to expr
reverted the argument handling in levels, arguments no longer take a 3 plane list due it making no sense when combined with the planes argument
optimized levels, the integer version is now implemented with a lut and the floating point version is faster when gamma=1.0
improved get_outputs() in python (stuxcrystal)
format objects can now be cast to int which will return the format id (stuxcrystal)
added method to make it easier to query formats from python (stuxcrystal)
made it possible to install the python part as a module (stuxcrystal)
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 24th August 2017, 23:28   #2692  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 698
Quote:
Originally Posted by Myrsloik View Post
Here's R39 test1

It would be a proper RC if it wasn't for a bit more optimization and refactoring I want to do in the 3x3 pixel filter part of the code (aka the previously known as genericfilters part).

Glorious changes:
Code:
r39:
fixed missing fps correction in avisource that would produce an error with some files
switched to nasm as the assembler
updated to zimg v2.6
visual studio runtime detection is improved in the installer, it should no longer attempt re-installs when a newer version is present
minor optimization in vspipe, you can now output blankclip into the void much faster
memory will now be 64 byte aligned on systems with avx512 support
added swapn and dupn operators to expr
reverted the argument handling in levels, arguments no longer take a 3 plane list due it making no sense when combined with the planes argument
optimized levels, the integer version is now implemented with a lut and the floating point version is faster when gamma=1.0
improved get_outputs() in python (stuxcrystal)
format objects can now be cast to int which will return the format id (stuxcrystal)
added method to make it easier to query formats from python (stuxcrystal)
made it possible to install the python part as a module (stuxcrystal)
My video from frameserve is able to open now, but it was turned upside down
lansing is offline   Reply With Quote
Old 25th August 2017, 12:07   #2693  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,519
What's the format? Can I have a sample of the input? 10 frames is enough
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 25th August 2017, 14:06   #2694  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 698
Quote:
Originally Posted by Myrsloik View Post
What's the format? Can I have a sample of the input? 10 frames is enough
The video file was a dummy generated by the frame server, here's the video info
Code:
Video
ID                          : 0
Format                      : VFW
Codec ID                    : DFSC
Codec ID/Info               : DebugMode FrameServer VFW
Duration                    : 24 min 13 s
Bit rate                    : 767 b/s
Width                       : 1 920 pixels
Height                      : 1 080 pixels
Display aspect ratio        : 16:9
Frame rate                  : 23.976 (24000/1001) FPS
Bits/(Pixel*Frame)          : 0.000
Stream size                 : 136 KiB (14%)
You can reproduce it with Premiere and this frame server. Media player classic play the file with no problem.
lansing is offline   Reply With Quote
Old 25th August 2017, 18:45   #2695  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,519
Quote:
Originally Posted by lansing View Post
The video file was a dummy generated by the frame server, here's the video info
Code:
Video
ID                          : 0
Format                      : VFW
Codec ID                    : DFSC
Codec ID/Info               : DebugMode FrameServer VFW
Duration                    : 24 min 13 s
Bit rate                    : 767 b/s
Width                       : 1 920 pixels
Height                      : 1 080 pixels
Display aspect ratio        : 16:9
Frame rate                  : 23.976 (24000/1001) FPS
Bits/(Pixel*Frame)          : 0.000
Stream size                 : 136 KiB (14%)
You can reproduce it with Premiere and this frame server. Media player classic play the file with no problem.
I said a sample. As in a piece of raw video. Not going to install that mess.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 25th August 2017, 19:16   #2696  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 698
Quote:
Originally Posted by Myrsloik View Post
I said a sample. As in a piece of raw video. Not going to install that mess.
The frameserver export a dummy avi while Premiere was still on, then I loaded that dummy avi into vs. The problem was not on any particular video that was frameserved, as I tried on a couple of different videos already, so there's no sample I can give.
lansing is offline   Reply With Quote
Old 25th August 2017, 22:19   #2697  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 698
I found another problem with avisource, it couldn't open avi with Lagarith codec in RGB colorspace, it only works for lagarith yv12. I got this error "AttributeError: 'list' object has no attribute 'set_output'".

sample
lansing is offline   Reply With Quote
Old 25th August 2017, 22:21   #2698  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,519
Quote:
Originally Posted by lansing View Post
I found another problem with avisource, it couldn't open avi with Lagarith codec in RGB colorspace, it only works for lagarith yv12. I got this error "AttributeError: 'list' object has no attribute 'set_output'".

sample
It works. You get two clips back in a list when there's an alpha plane too. Set alpha=false if you don't need it at all.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 25th August 2017, 22:30   #2699  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 698
Quote:
Originally Posted by Myrsloik View Post
It works. You get two clips back in a list when there's an alpha plane too. Set alpha=false if you don't need it at all.
There is no alpha option in avisource
lansing is offline   Reply With Quote
Old 25th August 2017, 22:32   #2700  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,519
Quote:
Originally Posted by lansing View Post
There is no alpha option in avisource
Ignore the part about that then. Confused it with ffms2. clip[0] and you're good.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik 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 23:59.


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