RawSource26

From Avisynth wiki
(Redirected from Yuvscan)
Jump to: navigation, search
Abstract
Author Chikuzen
Version 20160528 / v1.3.2
Download RawSource26-20160705.zip

AviSynth+
RawSourcePlus-1.3.2.7z

Category Source filters
License GPLv2?
Discussion Doom9 Thread


Contents

Description

Source filter plugin for loading raw video data from files. RawSource26 is an AviSynth 2.6 rewrite of RawSource by Ernst Pech.

Note: RawSourcePlus is only to be used with AviSynth+.

Requirements


*** vc_redist.x86.exe is required for RawSourcePlus-x86
*** vc_redist.x64.exe is required for RawSourcePlus-x64


Syntax and Parameters

RawSource opens a video file which contains 8bit YUV444, YUV422, YUV411, YUV420, Y8, or RGB video data. There are three ways how the positions of the video frame data are calculated:

  • a YUV4MPEG2-header is found, width/height/framerate/pixeltype/fieldorder is set according to the header data. Only fixed-length FRAME headers without 'm'tag are supported.
  • width, height and pixel_type is given as arguments. Then the positions are calculated assuming that only video data is in the file.
  • an "index" string (or file) is given together with width, height, pixel_type. The index string can contain all or partial positions of the frames.


RawSource (string "file", int "width", int "height", string "pixel_type", int "fpsnum", int "fpsden", string "index", bool "show")
RawSourcePlus (string "file", int "width", int "height", string "pixel_type", int "fpsnum", int "fpsden", string "index", bool "show", int "sarnum", int "sarden")


string  file =
Path to raw file; path can be omitted if the file is in the same folder as the AviSynth script (*.avs).
RawSourcePlus has the capability to read from a pipe by using "-". YUV4MPEG2-header is required. See usage examples here.


int  width = 720
int  height = 576
Dimensions of the raw file; Maximal width/height is 65536.


string  pixel_type =
Defaults to "YUY2" in RawSource and "YUV420P8" in RawSourcePlus.
Supported pixel_types are:
pixel_type AviSynth colorspace
"BGR", "BGR24", "RGB", "RGB24" RGB24
"BGR32", "RGBA", "RGB32", "ARGB", "ABGR" RGB32
"YUY2", "YUYV", "UYVY", "VYUY" YUY2
"YV24", "I444" YV24
"YV16", "I422" YV16
"YV411", "Y41B", "I411" YV411
"I420", "IYUV", "YV12" YV12
"NV12", "NV21" I420
"Y8", "GRAY" Y8
Additional colorspaces with RawSourcePlus and AviSynth+
RGB48, RGBA64, BGR48, BGRA64, ARGB64, ABGR64 RGB48 or RGB64
YUV444P9, YUV444P10, YUV444P12, YUV444P14, YUV444P16, YUV444PS YUV444P10/12/14/16/S
YUV422P9, YUV422P10, YUV422P12, YUV422P14, YUV422P16, YUV422PS YUV422P10/12/14/16/S
YUV420P9, YUV420P10, YUV420P12, YUV420P14, YUV420P16, YUV420PS YUV420P10/12/14/16/S
P210, P216 YUV422P16
P010, P016 YUV420P16
Y10, Y12, Y14, Y16, Y32, GREY16, GREYS Y10/12/14/16/32
GBRP, GBRP10, GBRP12, GBRP14, GBRP16, GBRPS RGBP/10/12/14/16/S
GBRAP, GBRAP10, GBRAP12, GBRAP14, GBRAP16, GBRAPS RGBAP/10/12/14/16/S
YUVA444, YUVA444P10, YUVA444P12, YUVA444P14, YUVA444P16, YUVA444PS YUVA444/P10/P12/P14/P16/PS
YUVA422, YUVA422P10, YUVA422P12, YUVA422P14, YUVA422P16, YUVA422PS YUVA422/P10/P12/P14/P16/PS
YUVA420, YUVA420P10, YUVA420P12, YUVA420P14, YUVA420P16, YUVA420PS YUVA420/P10/P12/P14/P16/PS


int  fpsnum = 25
int  fpsden = 1
The default value of framerate is 25fps, you can change it with specified 'fpsnum' and 'fpsden' if you need (e.g. for NTSC-material).


string  index = ""
See using an index-string.


bool  show = false
With show=true the actual byte position used for that frame is displayed, followed by:
  • K = position given in index is used
  • D = position by adding current delta is used
  • B = position by adding current big_delta is used


int  sarnum = 0
int  sarden = 0
Parameters for RawSourcePlus only.


Exported variables

  • FFSAR_NUM, FFSAR_DEN, and FFSAR.


Examples

The following example assumes there is a valid YUV4MPEG2-header inside. If not, default values are used: width=720, height=576, pixel_type="YUY2"

RawSource("d:\yuv4mpeg.y4m")


Decoding a 2VUY file. First download Test.rar, it contains a color bar video in NTSC format (720x486, 29.976fps, 120 frames).
If you open the Test.2VUY file in a hex editor you can see that it has a 1024 byte header. Also, each field is stored separately (720x243). So to correctly load this file we must do something like this:

RawSource(file="Test.2VUY", width=720, height=243, pixel_type="UYVY", fpsnum=30000, fpsden=1001, index="0:1024")
AssumeFieldBased()
Weave()


Using an index-string

You can enter the byte positions of the video frames directly.

RawSource("d:\yuv.mov",720,576,"UYVY", index="0:192512 1:1021952 25:21120512 50:42048512 75:62976512")

This is useful if it's not really raw video, but e.g. uncompressed MOV files or a file with some kind of header. It will work whenever the spacing of the frames is fixed or has at least two fixed intervalls (e.g. audio data interleaved with the video every 25th frame).
You enter pairs of framenumber:byteposition.
Internally there are two step values (for the byte positions): delta and big_delta.
delta is stored everytime when two adjacent framenumbers are given, the default value is width*height*bytes_per_pixel.
big_delta is stored, when three framenumbers with the same two intervals are given. The default value is 0 (meaning there is no useful big_delta present).
If those conditions are not met, the internal values of delta and big_delta is not updated, only the given byte positions in the index are used.
big_delta is reset to 0 if the resulting position would be behind the given one (see beyond).

Here are some possible cases:

  0:    0
frame 0 starts at byte 0, step to frame 1 is default = width*height*bytes_per_pixel
  0:10000
frame 0 starts at 10000
  0: 5000
  1:15000
frame 0 at 5000
frame 1 at 15000 (delta is set to 10000)
frame 2 at 25000 (using delta)
frame 3 at 35000 (using delta)
  0:  5000
  1: 15000



25:290000 50:590000 75:890000
frame 0 at 5000
frame 1 at 15000 (delta=10000)
frame 2 at 25000
...
frame 25 at 290000 (using entry instead of delta which would be at 255000)
frame 26 at 300000 (still using delta)
...
frame 50 at 590000 (using entry instead of delta)
>> because 25...50 = 50...75 now big_delta is set to 300000 (590000-290000)
frame 51 at 600000 (still using delta)
...
frame 75 at 890000 (using entry which is the same as using big_delta)
...
frame 100 at 1190000 (using big_delta)
frame 101 at 1200000 (using delta)
...
frame 125 at 1490000 (using big_delta)
  0:  5000
  1: 15000
 25:290000
 50:590000
 75:890000
100:950000
the same as in the previous example



frame 75 at 890000
>> because 890000 300000 > 950000 now big_delta is reset to 0.
frame 100 at 950000
frame 101 at 960000 (using delta)
...
frame 125 at 1200000 (there is NO big_delta)

The index string is treated as a filename, if there is an "." inside. The data is then read from that file, line breaks don't matter.

Finding those byte positions

With yuvscan.exe* you can try to analyze files which contain YUV-data with only valid luma and chroma data (~16-240). The program searches for big uninterrupted blocks without bytes < 16 or >240 and generates a "index.txt"-file, which can be used directly with RawSource (if you are really lucky, at least). It's only a command line version, you can change the default parameters. If you know the height and width of the data, the output will be much better.

* yuvscan.exe is included with RawSource_25_dll, hosted on the WarpEnterprises page of this site.

Usage:

yuvscan.exe filename triggerlength threshold round_by_bytes
triggerlength: how long must one frame be (in bytes) threshold: what are considered valid YUV data (default 10, which means 10 ... 255-10) round_by_bytes: as most data is stored at nice positions, the output can be rounded. default 9 which means 2^9 = $100


Changelog

  Version       Date            Changes
RawSourcePlus v1.3.2 2022/08/01 - Added support for pipe input. v1.3.1 2021/08/09 - Fixed the error message for supported formats. v1.3.0 2021/08/08 - Added pixel_types YUV422P10be, YUV422P12be, YUV422P14be, YUV422P16be. (DTL2020) v1.2.0 2021/08/03 - Added pixel_types UYVY12le, UYVY12be, UYVY14le, UYVY14be, UYVY16le, UYVY16be. v1.1.0 2021/08/01 - Added pixel_types UYVY10le and UYVY10be. (DTL2020) v1.0.1 2021/06/16 - Fixed frame properties _DurationNum and _DurationDen. v1.0.0 2021/02/08 - Used reserved frame property names. - Added parameters sarnum and sarden. - Set frame properties _SARNum and _SARDen. - Set variables FFSAR_NUM, FFSAR_DEN, FFSAR. v0.0.1 2020/05/15 - Set few frame properties 20200513 2020/05/13 - Changes by asd-g - Update to AviSynth+'s v8 interface - Fixed 10/12/14-bit input - Compiled with Microsoft Visual Studio C++ 2019 20160814 2016/08/14 - Update for AviSynth+. - Add new colorspace support. - Automatically registers as MT_SERIALIZED.
RawSource26 20160528 2016/05/28 - Add 64bit binary. 20130826 2013/08/26 - Compile for AviSynth 2.6 (Alpha 4 or greater). 20120831 2012/08/31 - Extend the size of read buffer to one frame at the maximum, and modify writing algorithm. 20110925 2011/09/25 - Change MAX_WIDTH to 65536. 20110614 2011/06/14 - Initial release (rewrite RawSource to support new features(pixel types) in AviSynth 2.6.
RawSource25 20110529 2011/05/29 - Change maximal width to 4096. - Add new parameters fpsnum/fpsden. 20110523 2011/05/23 - Add ABGR/NV12/NV21 support. - Fix parsing of YUV4MPEG2 stream header. - Fix processing of interlaced YUV4MPEG2. - Add support of ARGB / I422(YUV422planar) / YV411(YVU411planar) / YUV411planar. 20110112 2011/01/12 - added mono(Y8) colorspace suport on YUV4MPEG2.


Archived Downloads

Version Download Mirror
20130826 rawsource26-20130826.zip rawsource26-20130826.zip
20110529 RawSource_25_dll_20110529.zip RawSource_25_dll_20110529.zip


External Links

  • GitHub - RawSourcePlus source code repository.
  • GitHub - RawSource_2.6x source code repository.
  • GitHub - RawSource_2.5x source code repository.
  • Doom9 Forum - Uncompressed UYVY AVI fails to load in AviSynth




Back to External Filters

Personal tools