ImageWriter

From Avisynth wiki
Revision as of 16:02, 9 May 2013 by Admin (Talk | contribs)

Jump to: navigation, search

ImageWriter(clip clip, string file = "c:\", int start = 0, int end = 0, string type = "ebmp", bool info = false)
ImageWriter(clip clip, string file = "c:\", int start = 0, int -num_frames, string type = "ebmp", bool info = false)

ImageWriter (present in limited form in v2.51, full functionality from v2.52) writes frames from a clip as images to your harddisk.

file: default "c:\": is the path + filename prefix of the saved images. The images will have filenames as such: [file]000000.[type], [file]000001.[type], etc. In v2.60 support for printf formating of filename is added. The default reflects the old behaviour (file="C:\%06d").

start and end are the start and end of the frame range that will be written. They both default to 0 (where end=0 means last frame). If end is negative (possible since v2.58), it specifies the number of frames that will be written.

type default "ebmp", is the filename extension and defines the format of the image.

The supported values for type, are:

(e)bmp, dds, ebmp, jpg/jpe/jpeg, pal, pcx, png,
pbm/pgm/ppm, raw, sgi/bw/rgb/rgba, tga, tif/tiff

info default false: optionally overlay progress information on the video clip, showing whether a file is being written, and if so, the filename (added in v2.55).

Format "ebmp" supports all color formats. The "ebmp" files written from the RGB or Y8 color formats are standard BMP files; those produced from YUV formats can probably only be read by AviSynth's ImageSource. This pair of features allows you to save and reload raw video in any internal format.

For all other formats the input colorspace must be RGB24, RGB32 (when the alpha channel is supported by the format and you want to include it) or Y8.

Note that frames are not written to the output file until they are actually rendered by ImageWriter. Therefore, output is produced only for rendered frames, and there will be no output at all if the result of the filter does not contribute to the final result of the script.

Examples:

# Export the entire clip in the current native AviSynth format
ImageWriter("D:\backup-stills\myvideo")
# Write frame 5 to "C:\000005.PNG"
ImageWriter("", 5, 5, "png")
# Write frames 100 till the end to "F:\pic-000100.JPEG", "F:\pic-000101.JPEG", etc. and display progress info
ImageWriter(file = "F:\pic", start = 100, type = "jpeg", info = true)
# Write a jpg as greyscale (note the luma range should be [0,255], not [16,235])
ImageSource("F:\TestPics\GoldPetals.jpg")
ConvertToY8(matrix="PC.601")
ImageWriter("F:\TestPics\GoldPetals-8bit-avs", type = "png")
# Write a jpg as YV24 ebmp (note the luma range should be [0,255], not [16,235])
ImageSource("F:\TestPics\GoldPetals.jpg")
ConvertToYV24(matrix="PC.601")
ImageWriter("F:\TestPics\GoldPetals-24bit", type = "ebmp")
# Write all frames to "F:\00.bmp", "F:\01.bmp", ..., "F:\10.bmp", "F:\11.bmp", ..., "F:\100.bmp", ... (thus adding zeros filling two digits)
ImageWriter(file="F:\%02d.bmp")

Notes:

Saving as greyscale bmp doesn't work correctly, both for bmp (where DevIL is used) and ebmp (internal parsing).

Changelog:

v2.58 added end=-num_frames
v2.60
  • ebmp supports all formats; greyscale added for all formats.
  • add support for printf formating of filename string, default is ("%06d.%s", n, ext).
Personal tools