DV Info Net (https://www.dvinfo.net/forum/)
-   3D Stereoscopic Production & Delivery (https://www.dvinfo.net/forum/3d-stereoscopic-production-delivery/)
-   -   Producing 3D files in AviSynth (https://www.dvinfo.net/forum/3d-stereoscopic-production-delivery/479703-producing-3d-files-avisynth.html)

 Adam Stanislav May 31st, 2010 08:21 PM

Producing 3D files in AviSynth

A while ago Pavel mentioned he had no tool to produce HDMI v.1.4a 3D files which consist of the left view on the top, the right view at the bottom, and a 45-line gap in-between.

I said I would add the ability of creating such files in Bororo 3D if I could find a reasonable way of doing that in a Sony Vegas plug-in. Well, to this day I have not found such a way.

Then I noticed people on the DVInfo Vegas forum talking about their use of AviSynth for things they cannot get done in Vegas. So I started writing an AviSynth plug-in to create the HDMI format files. This worked but some of it did not work right with MPEG files. And these days most of our videos are in the MPEG format.

A week later I learned more about AviSynth and realized I could accomplish the same result, but without the problems, by writing AviSynth scripts rather than plug-ins. So, I got to work, and today, another week later, got finished. I created a file called Pantarheon3D.avsi, which is a collection of AviSynth functions for creating 3D files. It can do things such as:

- Create classical, red/cyan, green/magenta, and yellow/blue anaglyphs;

- Create full and half-width left/right and cross-eyed files, including yt3d files.

- Create full and half-width top/down and down/top files.

- Create the aforementioned HDMI v.1.4a 3D files.

- Extract the left or the right view from all of the above except the anaglyphs (since they do not have all the necessary information).

- Convert from any of the above (except anaglyphs) to any of the above (including anaglyphs).

To give you an example, suppose you have a 29.97 fps yt3d video called yt3d.mpg and want to convert it into the HDMI format. Assuming you have an MPEG decoder (and who among us does not), it takes but one line in your AviSynth script:

Code:

DirectShowSource("yt3d.mpg", fps=29.97).Yt3DToHDMI
Yep, that simple.

Or if you have two videos, left.avi and right.avi, this is what it takes to make a yt3d file:

Code:

Yt3D(AviSource("left.avi", "right.avi")
Just like magic! :-)

I have not written the documentation for it yet, but have uploaded it, along with some sample AVS scripts to Pantarheon.org. This will be the link to the documentation page. Until the docs are there, you can click on msi (on that page) to get the Windows Installer version, or on zip to get it all in a .zip file.

Assuming you use the .msi version, it will install Pantarheon3D.avsi into your AviSynths "plugin" directory (assuming it was installed to its default directory). If you download the .zip version instead, just copy the file Pantarheon3D.avsi to the AviSynth plugins directory.

And of course you need AviSynth. It only comes in a 32-bit version but it works well.

 Pavel Houda June 1st, 2010 12:02 AM

Thanks Adam, you are the greatest. Pavel

 Adam Stanislav June 1st, 2010 07:59 AM

You're very welcome.

 Adam Stanislav June 1st, 2010 10:35 PM

I have just uploaded the first part of the documentation. I am too tired to work on the rest of it now, hopefully tomorrow. But this should get you started.

 Robert Martens June 2nd, 2010 01:39 PM

Quote:
 Originally Posted by Adam Stanislav (Post 1533516) And of course you need AviSynth. It only comes in a 32-bit version but it works well.
A 64 bit version of SEt's multithreaded build of version 2.5.8 is under continuing development, and quite a few external filters have also been ported: SEt's Avisynth 2.5.8 MT compiled for *X86_64*, Latest Build 4/16/2010 - Doom9's Forum

I don't have a 64 bit machine to test anything myself, but people seem to be having success with it.

 Adam Stanislav June 2nd, 2010 02:03 PM

Thanks, Robert. I am aware of it and, indeed, have it on my system, but so far it is for people who feel very comfortable tweaking the insides of their computers, so I am not officially recommending it.

Of course, my scripts work with it because all they use are built-in AviSynth functions. But it only works with AVI files, no MPGs (since the necessary plug-ins are not included in the 64-bit version), so its usefulness is quite limited. And the 32-bit version works very nicely, so there is really not much of a point in using the 64-bit version.

Now, if it let me open the .avs files directly in Sony Vegas, that would be very nice. But it does not.

 Adam Stanislav June 2nd, 2010 03:02 PM

Whew! I'm glad to say I finished the documentation for Pantarheon3D.avsi. Now I can take a break. :-)

 Adam Stanislav June 5th, 2010 02:50 PM

I have added a few functions that I somehow missed in the initial upload. I have uploaded the updated files as version 1.1.

 Serge Victorovich June 7th, 2010 12:19 AM

Adam, you are The Great Man! Thank you for your free tools!
Will be cool if youtube can accept *avs script as upload for their internal avc encoder:)

 Steve Shovlar June 7th, 2010 06:14 AM

I downloaded the program but it doesn't even have a user interface in windows. It's fine if you have an undertsanding of computer languages but way above the average video guys head. Even if I worked it out (highly unlikely) I still don't know how you would get this onto a blu-ray disk to show on a 3D TV.

And what about convergence/editing etc? Do you use Tim Daswoods plugin or do you need to buy the extortionate 3D Nero?

 Steve LaPierre June 7th, 2010 07:49 AM

I am curious if the format that is stored on disk is the same as the HDMI 1.4 specification or is that a function of the BD player to create that file format? Since a 3D movie should play in an old BD player my first thought is that the two video streams are separate on the BD but maybe the old player can read the new format file and only use the first video portion. Quite possibly this is a stupid question but it is something that I have not been able to understand with my limited exposure to Blu-ray, HDMI, and 3D.

 Adam Stanislav June 7th, 2010 08:51 AM

Quote:
 Originally Posted by Steve LaPierre (Post 1535788) I am curious if the format that is stored on disk is the same as the HDMI 1.4 specification or is that a function of the BD player to create that file format?
I would say it is the player that creates that format (not file format). The reason for it is that you cannot store that format in a 4:2:0 MPEG file because those files must have an even number of lines (or even a number of lines divisible by 4), but that HDMI format always has an odd number of lines, which is double the number of lines in each view plus 45.

 Adam Stanislav June 7th, 2010 09:17 AM

Quote:
 Originally Posted by Steve Shovlar (Post 1535750) I downloaded the program but it doesn't even have a user interface in windows.
Steve, it is not a program, it is an AviSynth script. AviSynth does not have a user interface. If you do not know how to use AviSynth, other solutions are available, such as Tim's plug-in for the Mac and my plug-in for Sony Vegas.

I wrote this script because Pavel was looking for a way of producing the HDMI format and because I did not find a way of incorporating frame size changes in Vegas plug-ins.

I would also strongly disagree that AviSynth is above the average video guy's head. Considering it can do things that are difficult to do with any other software, I would say it is something every video guy needs to learn. And most probably have.

All you've got to do is write very short and simple scripts, such as:

Code:

left = AviSource("left.avi") right = AviSource("right.avi") HDMI3D(left, right)
How hard is that? You just save it with the .avs extension and to the system it appears like an AVI file, so almost any video player and NLE that can open AVI files can open it.

And version 2.0 of the script will do even more (when I finish it, mind you), such as convert field-sequential files into other 3D formats. Yesterday I watched the field-sequential version of the Spy Kids 3D DVD in the yellow/blue format without needing to buy any 3D player!

All I needed was the upcoming version 2.0 of my script, the DVD, and a short script similar to the example above. I then opened Super, dragged my short script on it and it rendered it to an MPEG file for me (though I had to keep my computer running overnight for it).

 Steve Shovlar June 7th, 2010 02:08 PM

Hi Adam, I think I am understanding what you are saying. Not sure if this is any use for me as I am Mac based and have been playing with Tim Dashwoods plugin which is easy to use.

Still not sure how I can make a 3d file which can be burnt and shown in 3D on a 3D blu-ray player.

And a blu-ray player will not play 3D files. It has to be a 3D blu-ray player. Panasonic have one out right now which is HDMI 1.4. The PS3 is due an update at any time to show 3D, but it is HDMI 1.3.

 Pavel Houda June 7th, 2010 02:09 PM

Quote:
 Originally Posted by Steve LaPierre (Post 1535788) I am curious if the format that is stored on disk is the same as the HDMI 1.4 specification or is that a function of the BD player to create that file format? Since a 3D movie should play in an old BD player my first thought is that the two video streams are separate on the BD but maybe the old player can read the new format file and only use the first video portion. Quite possibly this is a stupid question but it is something that I have not been able to understand with my limited exposure to Blu-ray, HDMI, and 3D.
Steve, maybe there is an article will shed some light about the MVC format used by 3D BDs (we had some discussions in the past on this forum about the fact that the details are licensed and proprietary - and I don't want to start another complaining avalanche if that is right or wrong) and what the best way to get full res 3D would be until the right disc authoring S/W is available, supporting the MVC format generation as well as all the necessary headers, etc. for the 3D blu-rays to play correctly (as well as HDMI 1.4a players of course). For all that to work right, one needs the proper disc authoring S/W, 3D blu-ray player, and of course 3D monitor or TV. All this must start with two full res streams, L/R. Many post S/W outputs formats do not output half the pixels to fit to standard 2D frames (side-by-side, above/under, line interleave). Best way to get high quality self made video to the 3D devices are the Stereo Players running predominantly on PC's. Good description of all that is here: The Blu-ray 3D Format : Blu-ray 3D On The PC: The Tom's Hardware Review . Adam offered the help with his S/W because I needed a specific format for a test I was doing. You couldn't output it directly to blu-ray authoring software, there would be still lot more work needed if you were to generate standards compliant 3D BD's.

 Giroud Francois June 7th, 2010 02:51 PM

nokia is giving for free a MVC 3d encoder, you just need to compile it.
Mobile 3D Video | Nokia Research Center

 Steve LaPierre June 7th, 2010 04:13 PM

Quote:
 Originally Posted by Adam Stanislav (Post 1535815) I would say it is the player that creates that format (not file format). The reason for it is that you cannot store that format in a 4:2:0 MPEG file because those files must have an even number of lines (or even a number of lines divisible by 4), but that HDMI format always has an odd number of lines, which is double the number of lines in each view plus 45.
Thanks for your information and Pavel Houda's who I couldn't quote in my reply. I use Sony Vegas and had tried using it to combine a couple of files produced from A Fuji 3D camera to no avail. But the subject of the HDMI file format and what is encoded on a Blu-ray disc is of interest even though I know the authoring program is the one that would ultimately generate the proper code. Steve Shovlar's question seemed to be about the same overall topic so I was looking for some more clarity. I will take a look at Pavel's link and maybe a lot more will become clear. Thanks to both of you, especially Adam for pointing out the avisynth program.

 Adam Stanislav June 7th, 2010 05:24 PM

Quote:
 Originally Posted by Pavel Houda (Post 1535926) I don't want to start another complaining avalanche if that is right or wrong
Maybe you should! For a technology to be widely accepted, its specs should be available for anyone. BD may be cutting the branch it is sitting on by staying secret and proprietary.

Someone will come up with a public spec for a different technology accomplishing the same, and then it will be bye-bye bee dee!

 Steve LaPierre June 9th, 2010 09:00 AM

Pavel thanks for the link that was very informative and a surprisingly short read. For some reason your posts won't allow me to quote them but this is relative to the Tom's Hardware link on Blu-ray 3D. I can see where the authoring of a Blu-ray 3D would be quite complex to create that second view data.

 Pavel Houda June 9th, 2010 02:09 PM

Hi Steve, you are very welcome. The whole concept is not very hard, but the current standards need to be extended, because somehow they have to pump twice the # of pixels at the same frame rates, which taxes the hardware, and bandwidth of the existend delivery systems. That is why they either lose half the pixels or come with different, more efficient compression schemes, like the MVC, and then there is no inexpensive authoring and delivery systems for those schemes, at least not yet. It will take a while. I don't know why the system doesn't allow quoting me, maybe it is a hint for me to talk less.... :-)

 Adam Stanislav June 9th, 2010 09:32 PM

I have just added some illustrations to the documentation. This should make it easier to understand what the basic functions do.

 Pavel Houda June 9th, 2010 10:52 PM

Thank you Adam,you are the greatest!

 Adam Stanislav June 10th, 2010 06:58 AM

Quote:
 Originally Posted by Pavel Houda (Post 1536892) Thank you Adam,you are the greatest!
Oh, you're making me blush. http://img255.imageshack.us/img255/3...nroflol6fz.gif

Seriously, I am glad you find it useful.

 Seref Halulu December 10th, 2010 06:32 PM

Thanks for your tool but i couldn't try it.

I gave it a go with left, right-eye videos demuxed from some of my 3DBDs since i don't have my own 3D left, right videos for the time being. (i don't have 2 camcorders or any new gen. 3D camcorder to shoot yet.)

First i created left avs and right avs.

left.avs:
DirectShowSource("C:\test\left_v.h264", fps=23.976, audio=false)

right.avs:
DirectShowSource("C:\test\right_v.h264", fps=23.976, audio=false)

And final avs:

Import("C:\Program Files\Pantarheon\Pantarheon 3D AviSynth Toolbox\Pantarheon3D.avsi")

lv = DirectShowSource("left.avs").ConvertToYUY2
rv = DirectShowSource("right.avs").ConvertToYUY2

HDMI3D(lv, rv)

And when i tried to open the final avs with MeGui i got this popup:

"Left and right clips must be of the same size!"

I checked out and i met:

Same duration,
Same frame numbers,
but right video is always shorter than the left video as file size!

Weird.

What am i missing?

EDIT: OK, i've found i have to re-encode right-video before processing.

 Adam Stanislav December 11th, 2010 09:02 AM

Quote:
 Originally Posted by Seref Halulu (Post 1597243) EDIT: OK, i've found i have to re-encode right-video before processing.

 Seref Halulu December 11th, 2010 07:29 PM

Thanks but not sure since i haven't been able to re-encode the right-eye video as for now.

 Adam Stanislav December 11th, 2010 10:50 PM

OK, I have received your email and I think you are misinterpreting the "same size" here. It refers to the size of the image. Both have to be the same, that is have to have the same dimensions. So, for example, if the left view is 1920x1080, the right view has to be 1920x1080 as well. But the files do not have to have to have the same number of bytes in them because image compression is highly unlikely to give you that.

 Seref Halulu December 12th, 2010 03:10 PM

Thanks for the clarification.

Now i got the right_out.264 file and tried lots of permutations on command line.
But i always got 25 fps instead of 23,976. Here is one of them:

"C:\H264StereoSource_a2>x264 --level 4.1 --crf 20 --tune film -I 24 --b-pyramid none --sar 1:1 --aud --rc-lookahead 24 -o right_son out.avs

avs [info]: 1920x1080p 1:1 @ 25/1 fps (cfr)
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
x264 [info]: profile High, level 4.1
An unintentional loss of pictures occurs! Exitb/s, eta 0:00:12
A gap in frame number is found, try to fill it.
RefPicList0[ 2 ] is equal to 'no reference picture'
RefPicList0[ 2 ] is equal to 'no reference picture'
RefPicList0[ 2 ] is equal to 'no reference picture'
RefPicList0[ 2 ] is equal to 'no reference picture'
RefPicList0[ 2 ] is equal to 'no reference picture'
RefPicList0[ 2 ] is equal to 'no reference picture'
"
Anyway i converted it to 23.976 back while remuxing with TSMuxer.

And tried to open my final avs with MeGui:

"Import("C:\Program Files\Pantarheon\Pantarheon 3D AviSynth Toolbox\Pantarheon3D.avsi")

lv = DirectShowSource("left.avs").ConvertToYUY2
rv = DirectShowSource("right.avs").ConvertToYUY2

HDMI3D(lv, rv) "

And i got the same popup:

"Avisynth Script Error:
Left and right clips must be of the same size,
bla,bla..."

This is why MeGui doesn't accept MVC or can i open and re-encode this frame-packed stuff in Premiere CS5 or Sony Vegas?

 Adam Stanislav December 12th, 2010 08:03 PM

Quote:
 Originally Posted by Seref Halulu (Post 1597806) can i open and re-encode this frame-packed stuff in Premiere CS5 or Sony Vegas?
You can open pretty much anything in Vegas. And as of v.10, it can handle 3D natively, so you do not even need to go through AviSynth at all. And previous versions of Vegas can handle 3D through my Bororo 3D plugin. It is much easier to use Vegas than to use AviSynth because you get to see what you are doing while you are doing it. You just import your left view and your right view and Vegas will combine them for you.

 Seref Halulu December 13th, 2010 02:53 PM

Thanks but most of the hobbyists need a free MVC encoder and i think your tool + avisynth script + free MVC encoder would be great.
I used to uıse Premiere CS2 in the past but i mostly needed to use avisynth and Cineform.

 Adam Stanislav December 13th, 2010 07:14 PM

Yes, such an encoder would be nice. And someday someone will release one. But it is still too new.

 Seref Halulu December 13th, 2010 08:14 PM

At least there are some open source codes nowadays and i hope somebody -or a team will implement MVC encoder soon. Thanks for your assist btw.

 Adam Stanislav December 14th, 2010 10:02 AM

Perhaps the VLC encoder is the step in the right direction.

 Seref Halulu December 20th, 2010 03:58 PM

Hi,

I wanted to share my test results.

For the time being i sticked with x264's frame-packing capabilities; it puts some flags and you everytime have to select "side-by-side" or "top-bottom" options on player's settings according to the source file.
Yesterday i made some trials and i found "TopDown3D"/ "LeftRight3D" is only working with TMT5 in 3D mode.

So for now the best solution is to use "-reduced" option. (IMO)

Here are some scripts: (Created x264 files with those scripts and packed into m2ts /mkv containers work flawlessly in 3D mode with both TMT 5 and PDVD 10 .) And you can open them with MeGui and re-encode to x264 as frame packed... (you may use any desired preset too...)

(Sample avisynth scripts are written for left-right frame packing, you may change "LeftRight3DReduced(lv, rv)" line with "TopDown3DReduced(lv, rv)" )

With DGNVTools of Don.(you need to have a compatible nVidia card and the application of course.):

lv = DGSource("C:\xxx\left.dgi")

rv = DGSource("C:\xxx\right.dgi")

LeftRight3DReduced(lv, rv)

ConvertToYV12()

Or without DGNVTools:

either:

lv = FFVideoSource("C:\xxx\left.m2ts")

rv = FFVideoSource("C:\xxx\right.m2ts")

LeftRight3DReduced(lv, rv)

ConvertToYV12()

or:

lv = directshowsource("C:\xxx\left.m2ts")

rv = directshowsource("C:\xxx\right.m2ts")

LeftRight3DReduced(lv, rv)

ConvertToYV12()

EDIT: btw there are no options here like bold, code, quote, etc. Why? I'm a new boot here; is this the reason?

 Adam Stanislav December 20th, 2010 07:14 PM

You're quite welcome. As for bold and such, just use regular BBCode tags (see https://secure.wikimedia.org/wikipedia/en/wiki/BBCode for details). Those work on most web-based fora, including this one.

 Seref Halulu December 21st, 2010 05:02 PM

 Seref Halulu January 14th, 2011 04:45 PM

I found left video is extracted as 1088p, so i left DGNVTools to crop the left movie and i used this aviscript:

Quote:
 LoadPlugin("C:\DG\DGDecodeNV.dll") LoadPlugin("H264StereoSource.dll") lv = DGSource("C:\H264StereoSource_a2\left.dgi") rv= H264StereoSource("decoder.cfg",64140) lv = lv.ConvertToYUY2 rv = rv.ConvertToYUY2 HDMI3D(lv, rv)
And used:
Code:

 C:\blabla>x264 --fps 24000/1001 --level 4.1 --sar 1:1 --aud -o adam.264 adam.avs avs [info]: 1920x2205p 1:1 @ 24000/1001 fps (cfr) resize [warning]: converting from yuyv422 to yuv422p resize [error]: resolution 1920x2205 is not compliant with colorspace i420
And?

 Seref Halulu January 18th, 2011 05:00 PM

FYI those are working:

Quote:
 SetMemoryMax (64) LoadPlugin("C:\DG\DGDecodeNV.dll") LoadPlugin("H264StereoSource.dll") lv = DGSource("C:\blabla\left.dgi") rv= H264StereoSource("decoder.cfg",*****) LeftRight3D(lv, rv) ConvertToYV12()
Quote:
 SetMemoryMax (64) LoadPlugin("C:\DG\DGDecodeNV.dll") LoadPlugin("H264StereoSource.dll") lv = DGSource("C:\blabla\left.dgi") rv= H264StereoSource("decoder.cfg",*****) TopDown3D(lv, rv) ConvertToYV12()

 Adam Stanislav January 18th, 2011 05:26 PM

Yes, sometimes 1080 decodes as 1088 because certain formats have to be divisible by 16. Nothing I can do about it. You may want to try cropping it after you convert it to YV12.

 Seref Halulu January 18th, 2011 05:41 PM

But i have tried with ffVideoSource too; FFVideoSource always perceives it as is; 1080...

Quote:
 LoadPlugin("H264StereoSource.dll") lv= FFVideoSource("C:\H264StereoSource_a2\left.m2ts") rv = H264StereoSource("decoder.cfg",64172) HDMI3D(lv, rv)
Same result...

Should i still crop after converting to YV12?

All times are GMT -6. The time now is 02:25 AM.

DV Info Net -- Real Names, Real People, Real Info!
1998-2021 The Digital Video Information Network