Log in

View Full Version : YUV-Bitmap Import filter?


Pages : [1] 2 3

hanfrunz
6th December 2002, 00:57
Hello,

in our company we have a Abekas 8150 production switcher. It has a framestore option so you can save framegrabs to a .yuv file. The format of this file is very simple: (i can email a sample if someone wants it)
720x576 Pixel (PAL):
Y(8bit), U(8bit), Y(8bit),V(8bit)... and so on. As you can see its 4:2:2.

Now my question: is there a way to import these files (lets say i have 250 grabs = 10sec) into avisynth and serve it directly to tmpenc without any colorspace conversions and create a mpeg2 file?

There is also the possibility to save .y10 files witch are 10bit instead of 8! But i think mpeg2 is always 8bit (am i right?)

thanks
hans runz

WarpEnterprises
6th December 2002, 14:35
did you try ImageSequence.dll ?
It's the only plugin around to import image files.
Is there no way to change the output format?
(we have a similar task)

scmccarthy
6th December 2002, 16:26
The YUYV sequence is what the fourcc code YUY2 refers to. AviSynth can read that data if you have the right import filter.

Stephen

hanfrunz
7th December 2002, 00:42
Hello,

i tried ImageSequence.dll, but it is not working. :(
Can anybody code an import filter for me, that imports raw yuv2 files?

Hans Runz

scmccarthy
7th December 2002, 05:40
The fourcc code us YUY2.

If you attach a frame or if you can give more specific information about this raw data and how it is produced and someone might look at is out of curiousity, anonymously.

It is at least interesting as a question.

Stephen

hanfrunz
7th December 2002, 14:39
Hello,

@scmccarthy: i gave information about this format in my first question.

a PAL frame (720x576):

row1: Y001 U001 Y002 V001 Y003 U002 Y004 V002 ... Y719 U360 Y720 V360
row2: Y721 U361 Y722 V361 ...
etc.

it is produced with an Abekas 8150 production switcher (http://accom.com/products/abekas/8150/8150-frameset.html)

or with a photoshop in-/export plugin: ftp://ftp.accom.com/abekas/software/8150/win95-nt_plugin/psnt95.zip


Hans Runz

Marc FD
7th December 2002, 19:36
@ hanfrnz

it's very easy tocode. you just need to read YUY2 from yourfile and memcpy to new frames.

BTW, AFAIK, TMPEGEnc only works with RGB24 input. so you'll need a convertion.

if you attach a file with 2-3 320x240 frames i can code that in speed.

<EDIT>
not a good idea : i would't be able upload it :-/

so i've just 2 question :

- how are consecutive frames stored ? (behind eachother i thing)
- is there any header, or you need to enter size manualy.

hanfrunz
7th December 2002, 19:53
@ MarkFD
answer 1: each frame is stored in a seperate file! like t001.yuv, t002.yuv ...

answer 2: there is no header in these .yuv files and the resolution is always 720x576 (PAL) and 720x480 (NTSC)

is there a mpeg2 coder which uses yuv2 input? I always thought an mpeg2 file is yuv (4:2:0) or is it rgb???

<edit>
if you give me your email-adress i can send you a sample image. i tried to attach it to this reply, but is doesn work...

hans runz

Marc FD
7th December 2002, 20:02
>answer 1: each frame is stored in a seperate file! like t001.yuv,
>t002.yuv ...
>answer 2: there is no header in these .yuv files and the resolution is
>always 720x576 (PAL) and 720x480 (NTSC)

the source filter will need 4 args (path,maxframes,width,height) and will output YUY2. that's okay ?

>is there a mpeg2 coder which uses yuv2 input? I always thought an mpeg2
>file is yuv (4:2:0) or is it rgb???

MPEG is YV12 (4:2:0)
YV12 support is recent in Avisynth (2.5 alpha), before we needed to upsample YV12 to YUY2.

Marc FD
7th December 2002, 20:18
okay it's almost finished. you want it for Avisynth 2.07 or 2.5 alpha ? ^_^

hanfrunz
7th December 2002, 20:23
@ MarcFD

>the source filter will need 4 args (path,maxframes,width,height) and will output YUY2. that's okay ?

yep! that is exactly what i need! :-)
YV12 is 8bit/Y, 8bit/U and 8bit/V right?

Hans Runz

hanfrunz
7th December 2002, 20:37
>okay it's almost finished. you want it for Avisynth 2.07 or 2.5 alpha ? ^_^

hey cool, thats fast! i think 2.5alpha would be nice :-)

hans runz

scmccarthy
7th December 2002, 20:46
@hunfrunz

It wouldn't hurt to get the terminology right. Notice we are saying YUY2, not YUV2. YUV is the generic term we use for any color space that uses Y, U, and V samples. YUY2 uses 8-bit samples YUYVYUVY... I remember it by saying they replaced the V with a 2 in the name.

If your files use 10-bit samples, they can be truncated to 8-bit by dropping the two least significant bits.

@MarkFD

I posted a thread today, asking how to write a filter that does not take a clip as the first argument. GetGenericFilter needs a clip as an argument and once I remove it, I don't know what to replace it with.

The filter we are talking about here would make a good simple example of how that can be done. I can't write a filter like this yet, could you show me how?

Stephen

Marc FD
7th December 2002, 21:10
okay i've finished. Avsiytnh 2.5 is cool, because i don't want to switch back ^^.

rawYUY2load/rawYUY2save (to test the loader ^^)

i've some packaging to do.

it read path???.yuy2 files where path is user-defined and ??? is the frame number (001-002..) it's okay for you ??

@scmccarthy

just instansiate IClip, create a new VideoInfo, and fetch the functions.

hanfrunz
7th December 2002, 21:18
@Mark FD:
thank you very much!
>frame number (001-002..) it's okay for you ??

i think five or six digits would be better -> 000001-000002...

can you send it to me for testing ?

hanfrunz

Marc FD
7th December 2002, 21:19
OUPS !! 6 digits ??

shit i was going to release.

okay i'll do it.

Marc FD
7th December 2002, 21:22
6 digits.. done.

(attached "rawYUY2.zip")

hanfrunz
7th December 2002, 21:25
thanks again,

now i see the attachment... :-)

hans runz

hanfrunz
7th December 2002, 23:23
uuups i made a B-I-G mistake... :scared:

it's not YUY2, but UYVY!

i tested the filter with a byte-swapped file i created with a simple basic programm and then everything is fine!!

@MakrFD:
it would be very nice if you could add a RawUYVYload and RawUYVYsave (with file-extension .YUV) then it would be another perfect avisynthfilter!!!!

hans *very sorry* runz

Marc FD
7th December 2002, 23:58
(attached "raw422 beta 2.zip")

hanfrunz
8th December 2002, 16:46
Thanks a lot MarcFD, you are my hero!

will you release the source code, so everybody can learn how itīs done?

hans runz

Marc FD
8th December 2002, 17:06
it's ugly, sbasic (~150 lines) and i don't have time to release it, but if someone really want it, i'm an opensource coder after all ^__^

WarpEnterprises
8th December 2002, 22:43
Please, what's "sbasic" ?

scmccarthy
8th December 2002, 23:04
Mark FD -

I am definitely interested in seeing the code. Did you write it in a programming language other that C++? I finally figured out how to write a YUV version of colorbars(). Dividee told me how to handle the audio, so now it works. I am using the invert filter as a pattern. I need to compare that with simple filters that work entirely differently.

Stephen

Marc FD
9th December 2002, 13:06
>Please, what's "sbasic" ?

i wrote first : "simple", then i delete it simpl simp sim so s and i wrote basic => sbasic . it's a typo ^^

@stephen

i'll pack it a day with the sources if i write some new stuff.

scmccarthy
9th December 2002, 16:19
No, no, sbasic is really a neat new programming language!;)

If you can really write a filter in basic instead of cpp I'd like to see how that is done.

Stephen

Marc FD
9th December 2002, 16:48
quoting myself :
>i wrote first : "simple"

i didn't mean basic as a langage. "basic instinct" is not a film about computers ;)

hanfrunz
31st January 2003, 00:38
Hello MarcFD,

the new 2.5 beta is out and your fantastic filter is not running anymore :

"Plugin raw422.dll is not an AviSynth 2.5 plugin"

would be cool, if you had time to fix it.

Thanks again,
hanfrunz

WarpEnterprises
31st January 2003, 23:45
MarcFD has abandoned development and this filter has no source code.
Stick to 2.0 for this application (you can safely use two versions)

WarpEnterprises
15th February 2004, 22:17
I made a new version for importing YUV-files (WITH source code):

http://www.avisynth.org/warpenterprises/

RawSource(filename, width, height, pixeltype)

e.g.

RawSource("d:\src6_ref__625.yuv",720,576,"UYVY")

Change the framerate with AssumeFPS(30) if it is not 25fps.

"pixeltype" isn't the internal AviSynth-format, but the format in the YUV-file. This will be mapped correctly, without any resampling.
Supported types:
RGB, RGBA, BGR, BGRA, YUYV, UYVY, YVYU, VYUY

Remember, this plugin reads video files which contain many frames.
It works for reading ONE frame, but not for file sequences (they must be loaded separately).

sh0dan
16th February 2004, 09:26
Actually I think Richards ImageReader/ImageWriter supports YUV images by now (in ebmp mode).

Wilbert
16th February 2004, 10:30
@WarpEnterprises,

1) what do you use to make such a yuv clip?

2) No NTSC support?

ac-chan123
16th February 2004, 14:59
I have request a filter for using .yuv file in avisynth.
Sources of .yuv:
-VQEG (http://www.VQEG.org)
-xiph (http://medi.xiph.org)
-on the homepage of the most codec standardization group like mpeg and avc

AC-Chan(Robert Vincenz)

Wilbert
16th February 2004, 21:39
Sorry, I misread the docs. There is NTSC support.

I have one small request thought :) Could you add I420 and YV12 support?

The only free avi2yuv tool I could find:

http://www.ee.surrey.ac.uk/Personal/S.Worrall/dloads/

converts uncompressed RGB stuff (= tried XviD encoding, didn't work) to I420.

WarpEnterprises
16th February 2004, 23:04
I hate YV12 :-)

ac-chan123, your problems with the xiph videos come from that format.

It is a little more typing to add this and I have to download some frames first, but I will give it a try (which gives the answer to Wilbert, too).

WarpEnterprises
17th February 2004, 01:13
OK, get the new version with YV12 and I420 support.

@ac-chan: try

RawSource("d:\blue_sky.yuv",1920,1080,"YV12")

ac-chan123
17th February 2004, 03:33
@WarpEnterprises: i try it and it work realy good. but if i (Source) playback "YV12" yuv file per avs in VDMod v1.5.10.1, there change the color. when i go one frame after an other, the color is ok.

Richard Berg
17th February 2004, 06:26
Originally posted by sh0dan
Actually I think Richards ImageReader/ImageWriter supports YUV images by now (in ebmp mode).
This is true. Right now it uses a small custom RIFF header to set the image parameters, but these could be specified as filter arguments (to the Reader) if there was demand.

WarpEnterprises
17th February 2004, 23:04
@Richard:

- Is that ebmp == the custom RIFFed filed?
- ImageWriter: would it be possible to APPEND all written images to ONE file (without header), with this it would be possible to generate those YUV files, maybe useful for testing purposes.

It is clear that we (ImageReader/RawSource) have some overlapping functionality but I don't see how to combine it nicely.

Wilbert
21st February 2004, 01:30
I added YV12 support for you! Not bad for someone who can't program :)

I failed to add I420 (which is what I really want). I tried to add the code of SwapUV, but I couldn't get that to work. But there might be a simplier way.

Could you have a look at I420 support?

I420 clip (640x480, 25 fps):

http://www.geocities.com/wilbertdijkhof/raw.yuv

source+dll:

http://www.geocities.com/wilbertdijkhof/RawSource.zip

Note that if you open the clip as YV12, you will see that the output is correct except that the U and V channels are swapped. Thus YV12 input is correct since YV12 = I420 with swapped U and V.

sh0dan
21st February 2004, 13:24
Made a few changes to YV12, and added simpler I420 support.

Now tested (and working now)

http://cultact-server.novi.dk/kpo/avisynth/rawsource.zip

Wilbert
21st February 2004, 21:19
Forgot to add GetWritePointers ... Thanks :)

WarpEnterprises
21st February 2004, 23:06
really don't want to stop you from programming but my version (2004-02-17) already had YV12/I420 :confused:
However, it's a nice example to learn planar.

Wilbert
22nd February 2004, 21:43
Why didn't you say so ? I can't read your mind :)

1) If I put this plugin into the plugindir, WMP6.4 says 'Ran out of memory' when opening an arbitrary script. Do you have any idea why?

2) It's perhaps a nice plugin for the core?

3) Small programming questions:

What does the following line:

ret = _lseeki64(h_rawfile, bytes_per_line * vi.height * n , SEEK_SET);

Is this one necessary:

memset(rawbuf, 0, maxwidth * 4);

WarpEnterprises
22nd February 2004, 22:48
I did say (a post in this thread)

Which version exactly did you feed WMP?

_lseeki64 is a file-seek working for files>4GB. You need to seek if you have non-linear access (there are many file access layers - FILE, ifstream,.. - and I'm not sure which work >4GB, this does)

memset sets the buffer to 0 in case there is some read error you see it clearly and not some leftover from past frames.

Wilbert
22nd February 2004, 23:08
Which version exactly did you feed WMP?
Yours, and the one of Sh0dan.

WarpEnterprises
22nd February 2004, 23:28
works here. WMP6.4, W2K.
Does it show any frames or crash before displaying something?
Does VD work?

Wilbert
22nd February 2004, 23:54
Let me first say that it works if I keep it outside the plugindir.

If I put it in the plugindir, and I open an arbitrary script in WMP6.4 or vdub it doesn't show any frames. It just says: 'ran out of memory (WMP6.4)' and in vdubmod 1.4.13 / vdub:

Avisynth open failure:
AviSynth: script open failed!

If I just open vdubmod 1.5.10.1 itself, I get this message:

http://www.geocities.com/wilbertdijkhof/raw.jpg

W2K, Athlon XP

billou2k
21st May 2004, 15:10
Hi,
I've got a 4 minutes 422 (UYVY) raw PAL sequence in separate files (4500 files for a total of 3.47GB) (one file without headers for each frame).
I first tried using imagereader but I didnt manage to open the clip and I'm not sure I can as there is no way to specify the dimensions.

Then I concatenated all the files to try to open the video with "rawsource" plugin (as I think it only takes one file with all frames in it) It looked like it worked ok until frame 2589... which actually corresponds to the frame where the file reaches a size of 2GB...
Frome frame 2590 I ve got randomly either green frames or frames that have been displayed before and going back several times to the same frames display different things...

So I don't know where the problem occured: during the concatenation from my 4500 files into 1 single file or in rawsource...
Ideally I'd prefer to use a plugin that would access the 4500 files directly as I wouldnt need to play with an exrta 4G files...

Anybody got an idea to work around that problem?
Thanks a lot!

WarpEnterprises
24th May 2004, 12:54
I think I forgot some int64-casts in RawSource, so although it should work it doesn't above 2GB. I can fix it this week.