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 14th October 2012, 01:00   #1  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
image reader for VapourSynth

New plugins for VapourSynth r19 or later.

vsimagereader-0.2.1.zip

source code
https://github.com/chikuzen/vsimagereader


helper module to read image sequense
Code:
#vsimghelper.py

import os
import vapoursynth as vs

class ImageReader(object):
    def __init__(self, path):
        self.core = vs.get_core()
        try:
            hasattr(core, 'imgr')
        except:
            self.core.std.LoadPlugin(path)

    def read(self, dir, ext, fpsnum=24, fpsden=1):
        srcs = [dir + '/' + src for src in os.listdir(dir) if src.endswith(ext)]
        return self.core.imgr.Read(srcs, fpsnum, fpsden)
put this script into Python3.x/Lib/site-packages as vsimghelper.py

usage:
Code:
>>> import vapoursynth as vs
>>> import vsimghelper as ih
>>> imgr = ih.ImageReader('/path/to/the/vsimagereader.dll')
>>> clip = imgr.read('/path/to/the/image/directory', ext='jpeg')

EDIT:
2013/07/31
Release vsimagereader-0.2.1
__________________
my repositories

Last edited by Chikuzen; 31st July 2013 at 10:12.
Chikuzen is offline   Reply With Quote
Old 14th October 2012, 13:39   #2  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,085
Hi Chikuzen, thanks again for another VS plugin.
I know if the width is not mod4, padding will be added, but what color is the padding supposed to be? I assume is black. The reason I ask is because I see both green and black padding.
Also, here's the source just in case if you want to try to reproduce the results below.

* Edit *
Updated to vsjpgreader 0.1.1
Code:
import vapoursynth as vs
core = vs.Core()
core.std.LoadPlugin(path=r'C:\vsjpgreader.dll')

src = core.jpgr.Read(['C:\test.jpg'])

# Only used to test YUV440P8 input since VFW/VSFS in not able to output that colorspace.
#src = core.resize.Bicubic(clip=src, format=vs.YUV422P8)

last = src
Here are the results of different image sizes.
Code:
Tested through VFW and VSFS using VapourSynth r13 and vsjpgreader 0.1.1. 
Gimp 2.8 was used for jpg compression.

1) width=597 height=398
4:2:0 Works correctly. Gets padded to 600x398.
4:2:2 YUV440P8. Works correctly. Gets padded to 600x398.
4:2:2 YUV422P8. Works correctly. Gets padded to 600x398.
4:4:4 Works correctly. Gets padded to 600x398.

2) width=598 height=399.
4:2:0 Works Correctly.  Gets padded to 600x400.
4:2:2 YUV440P8. works correctly. Gets padded to 600x400.
4:2:2 YUV422P8. works correctly. Gets padded to 600x399.
4:4:4 Works correctly. Gets padded to 600x399.

3) width=599 height=399
4:2:0 Works Correctly. Gets padded to 600x400.
4:2:2 YUV440P8. Works correctly. Gets padded to 600x400.
4:2:2 YUV422P8. Works correctly. Gets padded to 600x399.
4:4:4 Works Correctly. Gets padded to 600x399.

4) width=600 height=400
   All input colorspaces work correctly.

5) width=602 height=401
4:2:0 Green diagonal lines appear. Gets padded to 604x402.
4:2:2 YUV440P8. Works correctly. Gets padded to 604x402.
4:2:2 YUV422P8. Green diagonal lines appear. Gets padded to 604x401.
4:4:4 Works correctly. Gets padded to 604x401.

6) width=602 height=402
4:2:0 Green diagonal lines appear. Gets padded to 604x402.
4:2:2 YUV440P8. Works correctly. Gets padded to 604x402.
4:2:2 YUV422P8. Green diagonal lines appear. Gets padded to 604x402.
4:4:4 Works correctly. Gets padded to 604x402.

Last edited by Reel.Deel; 15th October 2012 at 22:19.
Reel.Deel is offline   Reply With Quote
Old 14th October 2012, 15:20   #3  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
@Reel.Deel
Thanks for the report
I fixed odd height issue, and updated to 0.1.1.

About the color of padding, it is based on the jpeg decode library which is used by this plugin.
It seems that the library do padding by zero.
so, this is normal behavior.
__________________
my repositories

Last edited by Chikuzen; 14th October 2012 at 15:28.
Chikuzen is offline   Reply With Quote
Old 15th October 2012, 22:51   #4  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,085
I updated my post above to vsjpgreader 0.1.1. While that solved some of the issues, there's still one remaining.
The diagonal lines only appear on image 5 & 6, only on the 4:2:0 and 4:2:2(YUV422P8) colorspace.


Last edited by Reel.Deel; 16th October 2012 at 03:50. Reason: grammar
Reel.Deel is offline   Reply With Quote
Old 16th October 2012, 04:05   #5  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
@Reel.Deel
Updated to 0.1.2.
Please try again.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 16th October 2012, 04:32   #6  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,085
I still have the same problem, except the image is now very distorted.

Last edited by Reel.Deel; 16th October 2012 at 04:46. Reason: added link to image.
Reel.Deel is offline   Reply With Quote
Old 16th October 2012, 04:48   #7  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
sorry, I found a typo in code.
updated to 0.1.2-2
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 16th October 2012, 04:55   #8  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,085
hmm, that also did not fix it. Wish I could help you find the problem but I don't know anything about programming.
Reel.Deel is offline   Reply With Quote
Old 16th October 2012, 05:30   #9  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
Quote:
Originally Posted by Reel.Deel View Post
hmm, that also did not fix it. Wish I could help you find the problem but I don't know anything about programming.
With which sample does your problem occur?
I tested all your 24 samples again. But seems no problem.
__________________
my repositories

Last edited by Chikuzen; 16th October 2012 at 06:00.
Chikuzen is offline   Reply With Quote
Old 16th October 2012, 11:52   #10  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: UK
Posts: 2,309
Quote:
Originally Posted by Reel.Deel View Post
I updated my post above to vsjpgreader 0.1.1. While that solved some of the issues, there's still one remaining.
The diagonal lines only appear on image 5 & 6, only on the 4:2:0 and 4:2:2(YUV422P8) colorspace.

Are you using latest vapoursynth?
kolak is offline   Reply With Quote
Old 16th October 2012, 12:42   #11  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,085
Quote:
Originally Posted by Chikuzen View Post
With which sample does your problem occur?
I tested all your 24 samples again. But seems no problem.
You're correct Chikuzen, your last update fixed remaining problems with VFW. I have been testing with both VFW and VSFS, but the last time I was lazy and only tested with VSFS. That's the problem. The issue is now only with VSFS.

Here's the problematic samples, If someone else wants to reproduce the distorted image through VSFS.

___________

@Kolak

Yes, I'm using r13.

Last edited by Reel.Deel; 16th October 2012 at 12:56.
Reel.Deel is offline   Reply With Quote
Old 16th October 2012, 16:49   #12  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,838
Quote:
Originally Posted by Reel.Deel View Post
You're correct Chikuzen, your last update fixed remaining problems with VFW. I have been testing with both VFW and VSFS, but the last time I was lazy and only tested with VSFS. That's the problem. The issue is now only with VSFS.

Here's the problematic samples, If someone else wants to reproduce the distorted image through VSFS.
Interesting... which format do you use for the output? I'll take a look at it later and see if I can figure out why it happens.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 16th October 2012, 17:25   #13  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,085
Quote:
Originally Posted by Myrsloik View Post
Interesting... which format do you use for the output?
Depending on the jpg colorspace, I used YUV420P8 and YUV422P8 for output.
Reel.Deel is offline   Reply With Quote
Old 16th October 2012, 22:57   #14  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,168
@Myrsloik,

You may not have a bug here per se', there is some confusion in the world about the line packing of planar YUV formats.

Dib derived formats like RGB24, RGB32 and Y800 (Y8, GREY) always have lines that are 32 bit DWORD aligned. There seems to be universal conformance for this.

However planar YUV formats are apparently supposed to be packed with the line pitch equal to the rowsize. Some documentation is quite vague on this point. Avery Lee has convinced me it is true and VirtualDub implements this. However a sizeable chunk of the world assume planar lines are 32 bit DWORD aligned.

I abandoned the moral high ground in favour of a functional user solution. On input I check the returned full frame size to see if it matches a 32 bit DWORD aligned size and crib the spec accordingly. On output there is the "OPT_AVIPadScanlines" option to force 32 bit DWORD aligned output through the AVIFile interface.
IanB is offline   Reply With Quote
Old 22nd October 2012, 11:02   #15  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
I wrote vsbmpreader, and added it to the first post.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 22nd October 2012, 11:03   #16  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Ikea Chair
Posts: 1,838
Maybe you should merge them or use a library to make a complete image reader? That'd be really good to have
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 22nd October 2012, 12:11   #17  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
Quote:
Originally Posted by Myrsloik View Post
Maybe you should merge them or use a library to make a complete image reader? That'd be really good to have
I will think after writing png and tga about it.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 23rd October 2012, 07:29   #18  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
added vspngreader to the first post.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 23rd October 2012, 14:04   #19  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,085
@Chikuzen
I was wondering if the 8bit limitation is due to libpng? If not, I think it would be great if it was compatible with 16bit png's.
Thanks again for another plugin, will test when I have some free time.

@Myrsloik
Any update of the problem above?
Reel.Deel is offline   Reply With Quote
Old 23rd October 2012, 14:41   #20  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
Quote:
Originally Posted by Reel.Deel View Post
@Chikuzen
I was wondering if the 8bit limitation is due to libpng?
no
Quote:
If not, I think it would be great if it was compatible with 16bit png's.
then, I'm great
__________________
my repositories

Last edited by Chikuzen; 23rd October 2012 at 14:51.
Chikuzen is offline   Reply With Quote
Reply

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 05:19.


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