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 4th August 2014, 22:07   #1  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
ImageMagick writer/reader

I made a simple image reader and writer since people don't have much luck with the existing ones.

Usage examples:
Code:
core.imwri.Read('E:/testdir/testimg000001.png', alpha=False)
core.imwri.Write(main, 'PNG32', 'E:/testdir/testimg%06d.png')
Documentation

imwri test9 32bit
imwri test9 64bit
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet

Last edited by Myrsloik; 6th January 2018 at 23:24. Reason: New version
Myrsloik is offline   Reply With Quote
Old 4th August 2014, 23:35   #2  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
How is the dllpath thing supposed to work after the plugin should've already been loaded?
sneaker_ger is offline   Reply With Quote
Old 5th August 2014, 00:17   #3  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by sneaker_ger View Post
How is the dllpath thing supposed to work after the plugin should've already been loaded?
That's a very good question. Basically ImageMagick decided that normal library ideas were too mundane.

So you not ONLY need to link against imagemagick using your standard .lib files in windows. The linking gives you access to a function in imagemagick so you can tell imagemagick where to find all its other dlls after the main dll has been loaded. It's dll hell illustrated.

A normal library (which this is most certainly not) simply would've loaded all its parts at once.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 5th August 2014, 09:30   #4  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Well, I can't even get past LoadPlugin because of missing dlls even when they are in the same directory as imwri.dll.
sneaker_ger is offline   Reply With Quote
Old 5th August 2014, 10:34   #5  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
I'll look at it a bit more later but this is how I tested it:
I only used vspipe, I made sure both the script and all the plugin files are in the same directory AND that the working directory is the script directory.

I'll see if I can modify the source a bit and use mingw instead for the test versions as well...
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 5th August 2014, 13:11   #6  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Running the script from the same folder as the dlls yields success. I had only tried running vspipe from the dll folder prior to this.
sneaker_ger is offline   Reply With Quote
Old 5th August 2014, 14:17   #7  |  Link
Mystery Keeper
Beyond Kawaii
 
Mystery Keeper's Avatar
 
Join Date: Feb 2008
Location: Russia
Posts: 724
The most simple solution is to add dlls folder to PATH environment variable.
__________________
...desu!
Mystery Keeper is offline   Reply With Quote
Old 6th August 2014, 23:41   #8  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
I've added a second test version that's compiled for 64 bits (link in the first post). Nodame worked long and hard and managed to make it a single dll so the dllpath argument isn't needed anymore.

Report on your success/failures with unicode filenames.

This plugin will be added to the main source tree once it's working well enough.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 7th August 2014, 01:28   #9  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by sneaker_ger View Post
Well, I can't even get past LoadPlugin because of missing dlls even when they are in the same directory as imwri.dll.
Quote:
Originally Posted by sneaker_ger View Post
Running the script from the same folder as the dlls yields success. I had only tried running vspipe from the dll folder prior to this.
Keep in mind that Windows only looks for DLL's in the same folder where the main EXE file is located. But if some DLL depends on additional DLL's, it will not necessarily look in the folder where the DLL is located.

For example, if some EXE file explicitly loads a plug-in DLL from a certain "plug-ins" directory that differs from the directory where the EXE file itself is located and if that plug-in DLL depends on yet another DLL, then Windows will not look in the "plug-ins" directory for that other DLL (as one might expect) - it still only looks in the folder where the main EXE resides!

If the required DLL could not be found in the directory where the EXE file is located, Windows falls back to certain system directories (C:\Windows\System32, C:\Windows, etc). Then to the directories contained in the PATH environment variable. And finally it falls back to the "current" directory. So that's probably why "running the script from the same folder as the dlls" worked, because that happened to be your "current" directory then.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 7th August 2014 at 01:31.
LoRd_MuldeR is offline   Reply With Quote
Old 7th August 2014, 11:41   #10  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
First post once again updated with an improved version. Nodame managed to add in support for even more formats in the static builds and now both versions are a single simple dll.

The dllpath argument is dead!

So start testing. This should work and only be a minimal hassle to use now.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 12th August 2014, 07:01   #11  |  Link
alexxdls
Registered User
 
Join Date: Nov 2013
Posts: 26
Can this plugin read image sequence? I've tried
Code:
ext = '.png'
dir = r"F:\TEMP\50-SHADES_TRL-A_RU-XX_RU_51_1080P_UP_20140725_MPS_IOP_OV\REEL1/"
srcs = [dir + src for src in os.listdir(dir) if src.endswith(ext)]
v1 = core.imwri.Read(srcs)
like with previoous ImageReader, but it now outputs only the first image and all frames are equal. Checking the script gives
Code:
Script was successfully evaluated. Output video info:
Frames: 341 | Time: 0:00:14.208 | Size: 1920x1080 | FPS: 24/1 = 24 | Format: YUV444P10

Last edited by alexxdls; 12th August 2014 at 07:36.
alexxdls is offline   Reply With Quote
Old 12th August 2014, 07:52   #12  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by alexxdls View Post
Can this plugin read image sequence? I've tried
Code:
ext = '.png'
dir = r"F:\TEMP\50-SHADES_TRL-A_RU-XX_RU_51_1080P_UP_20140725_MPS_IOP_OV\REEL1/"
srcs = [dir + src for src in os.listdir(dir) if src.endswith(ext)]
v1 = core.imwri.Read(srcs)
like with previoous ImageReader, but it now outputs only the first image and all frames are equal. Checking the script gives
Code:
Script was successfully evaluated. Output video info:
Frames: 341 | Time: 0:00:14.208 | Size: 1920x1080 | FPS: 24/1 = 24 | Format: YUV444P10
Found the typo in the code. Will post a fixed version in a bit.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 12th August 2014, 21:25   #13  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
Does it read fps from DPX header?
Does read support same % mode as write, eg.
test_%03d.tiff for test_001, test_002, test_003,..... image sequence?

Last edited by kolak; 12th August 2014 at 21:28.
kolak is offline   Reply With Quote
Old 12th August 2014, 21:26   #14  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Quote:
Originally Posted by kolak View Post
Does it read fps from DPX header?
No, not yet at least.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 12th August 2014, 21:30   #15  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
What format are files decoded to, x bit RGB?
kolak is offline   Reply With Quote
Old 12th August 2014, 21:36   #16  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
IMPORTANT ANNOUNCEMENT
The test2 archive has been updated. It now handles reading lists of files properly. Before it would simply return the first image over and over again due to a typo. Get it from the first post.

Quote:
Originally Posted by kolak View Post
What format are files decoded to, x bit RGB?
Only 8-16 bit rgb for now. Going to try to add proper grayscale and yuv in a bit. Returning original subsampled data (such as 420 jpeg) is probably impossible with imagemagick.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 12th August 2014, 21:50   #17  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
RGB is good in this case, I assume.
kolak is offline   Reply With Quote
Old 12th August 2014, 21:55   #18  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Quote:
Returning original subsampled data (such as 420 jpeg) is probably impossible with imagemagick.
I never implemented this in Immaavs, but i always thought that this would be possible. Please let us know if that's not the case.
Wilbert is offline   Reply With Quote
Old 13th August 2014, 00:08   #19  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Now I've encountered another problem. I have no test images that are identified as being in a yuv-ish colorspace so I can't add support for reading them. Apparently jpeg images aren't considered yuv.

My own web hunt for this kind of image failed so sample images are requested.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 13th August 2014, 00:41   #20  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
Quote:
Originally Posted by Wilbert View Post
I never implemented this in Immaavs, but i always thought that this would be possible. Please let us know if that's not the case.
I did see that thread you made, but I see your last question was never answered. You'd have to mod coders/jpeg.c to change:
Code:
  i=(ssize_t) jpeg_read_header(&jpeg_info,TRUE);
  if ((image_info->colorspace == YCbCrColorspace) ||
      (image_info->colorspace == Rec601YCbCrColorspace) ||
      (image_info->colorspace == Rec709YCbCrColorspace))
    jpeg_info.out_color_space=JCS_YCbCr;
to:
Code:
  i=(ssize_t) jpeg_read_header(&jpeg_info,TRUE);
  if (image_info->colorspace == UndefinedColorspace)
    jpeg_info.out_color_space=jpeg_info.jpeg_color_space;
  else if ((image_info->colorspace == YCbCrColorspace) ||
      (image_info->colorspace == Rec601YCbCrColorspace) ||
      (image_info->colorspace == Rec709YCbCrColorspace))
    jpeg_info.out_color_space=JCS_YCbCr;
and then rebuild. Or just use your own code to detect it ahead of time.

There is a flag that IM doesn't use, jpeg_info.raw_data_out, that will give you non-upsampled pixels. Without it they're always upsampled with a bilinear filter. You'd have to write a bit of code to trick IM into working, since its routines won't work; you have to use jpeg_read_raw_data() instead of jpeg_read_scanlines() and fill the RGB buffers as you wish.

(I forgot how much of a migraine reading IM's source gives me.)
foxyshadis 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 13:21.


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