HDMI Capture Problem SOLVED - AviSynth RULES!

In a nutshell, no. At one point, the people at Atomos contacted me to explore the possibility of incorporating my script into the Ninja. The problem was the script requires AviSynth to run, and AviSynth requires Windows to run, and there simply isn't that type of computing power on board the Ninja. So, this must remain a post production process.

As for it being obsolete, well, that depends on the individual. The slightly different gamma of the HDMI produces a picture that "pops" more than the onboard recording.

I'm curious if Atomos conisdered perhaps making it a function of Stripper 1.0 or its own stand aalone peice of software.
 
I'm curious if Atomos conisdered perhaps making it a function of Stripper 1.0 or its own stand aalone peice of software.

Their original dream was to incorporate it onboard the Ninja. But. it was just a dream. There's no getting around the fact that you need an entire PC to run Avisynth. Still, it speaks well of Atomos that they wanted to please their customers.
 
Their original dream was to incorporate it onboard the Ninja. But. it was just a dream. There's no getting around the fact that you need an entire PC to run Avisynth. Still, it speaks well of Atomos that they wanted to please their customers.

What's the deal with Avisynth 3.0? I heard it was supposed to be OS independent and command line. Is it going to happen? If that's true couldn't they tailor it to their own OS?
 
From what I see, Avisynth 3.0 appears to be a dead project. I know you're grasping for any possibility, but realisticaly, it isn't going to happen onboard the Ninja. Sure, it would have been nice, but it isn't the end of the world. People have been removing 3:2 pulldown in post for years from various cameras. This is basically the same thing.
 
After much work, I have succeeded in extracting a clean 24P from GH2 HDMI captures.


First, a recap of the problem:

The GH2 sensor scans at 23.976P and embeds the picture in a 59.94i stream by adding 3:2 pulldown. Nothing unusual about that. But, when it sends this signal out the HDMI port, it adds in extra fields to make the signal a true 60.00i. These extra duplicate fields create havoc when attempting to remove the 3:2 pulldown. Plus, they throw the audio increasingly out of sync the longer the camera rolls.

But AviSynth comes to our rescue! The following script works for both NTSC and PAL cameras.

NOTE: This is an advanced script posted on April 24, 2011, and it superceeds the original script.

ADVANCED SCRIPT TO PROCESS 1080 24P FOOTAGE


Code:
avisource("Your HDMI movie.avi")

LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\TIVTC.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\FDecimate.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mvtools2.dll")

function filldrops (clip c)
{
**even = c
**super_even=MSuper(even,pel=2)
**vfe=manalyse(super_even,truemotion=true,isb=false,delta=1)
**vbe=manalyse(super_even,truemotion=true,isb=true,delta=1)
**filldrops_e = mflowinter(even,super_even,vbe,vfe,time=50)

**ConditionalFilter(even, filldrops_e, even, "YDifferenceFromPrevious()", "lessthan", "1.3")

}


# 3:2 Pulldown Removal
AssumeTFF()
trim(1,0)
TFM(mchroma=false)
FDecimate(threshold=0.5)
AssumeFPS(24000,1001)

# Chroma Fix
FixBrokenChromaUpsampling() 
converttoyv12()

# Fix Residual Duplicates
filldrops()

#Audio Delay
delayaudio(.07)

# Show the Metric for filldrops
# This is a diagnostic to determine the threshold "lessthan" in the ConditionalFilter
# To run, remove the # in the line below and put a # to the left of filldrops() 7 lines above
# ScriptClip(last,"Subtitle(String(YDifferenceToNext() ))" )


WHAT YOU WILL NEED

In order to run this script you need to install Avisynth and have TIVTC.dll, FDecimate.dll and mvtools2.dll inside your Avisynth plugins folder.

There are many versions of Avisynth available. Alpha 2.6.0 has been tested with Windows XP and works:
http://sourceforge.net/projects/avi.../AviSynth_090927.exe/download?use_mirror=iweb

However, I had some problems using it with Windows 7. Maybe it was just my machine. So, for Windows 7, I ended up using Avisynth 2.5.8. YMMV.

You can get TIVTC here.
http://bengal.missouri.edu/~kes25c/
It's about 3/4 the way down the page - TIVTC - 01/17/2008 v1.0.5

fdecimate is here:
http://neuron2.net/fdecimate/fdecimate.html

mvtools2 is here:
http://avisynth.org.ru/mvtools/mvtools2.html

You will also need a program to display the output from Avisynth and to render the processed footage. VirtualDub works fine.
http://virtualdub.sourceforge.net/
I recommend the 32-bit version.

**************************************************

PROCEDURE

One very important thing I must point out... you must set your capture device to record at 30fps, not 29.97. This is because the camera really is putting out 30fps. If you record at 29.97, the script won't work properly.

You also must record to a 4.2.2 codec. The script will not work well if you record to a 4.2.0 codec.
The following codecs have been successfully tested: UT 422 codec, Cineform, Blackmagic MJPEG codec.

I also recommend rolling the camera first, then starting the external capture. And stop the external capture before stopping the camera. This will give you the cleanest signal and avoid the discontinuity that occurs when the GH2 switches into and out of record.

The GH2 is truly a phenomenal camera. And the ability to record an uncompressed 24P HDMI signal makes it even more phenomenal!

**************************************************

SCRIPT NOTES


AUDIO with HDMI

The GH2 does not send audio through the HDMI, only picture. If your HDMI capture device has analog audio inputs, you can capture audio along with the picture, which is a desirable thing to do. However, there is a problem - the GH2 introduces a delay to the picture when it sends it out the HDMI, so the audio and picture will not be in sync. In the script, "delayaudio(.07)" fixes this. It delays the audio the precise amount to match the picture. The number .07 works with the Blackmagic Intensity board. Other capture devices may or may not require a different setting. So, be sure to test.



BATCH PROCESSING

If you use the script in a production environment, with hundreds and maybe thousands of clips, you're going to want to automate the process. Fortunately, someone has written a batch processing program for Avisynth scripts. Get it here:

http://www.hv20.com/showthread.php?25044-Batch-Intermediate-Creation-Utilities/page4

Scroll down the page to post #94 and download the 'Cosmetic Update to v1.6'.

There are actually four programs in the package, three of which basically do the same thing. I found VDub-BIC to be the most stable, and it's the one I use to batch process the scripts.



WORKING with ProRes

If your HDMI capture device records to ProRes (such as, the Atomos Ninja), you will need to modify the script and install additional software. In the very first line, replace "avisource" with "qtinput".

Download and install Quicktime and Apple's ProRes decoder for Windows.

Quicktime
http://support.apple.com/kb/dl837

Prores Decoder
http://support.apple.com/downloads/Apple_ProRes_QuickTime_Decoder_1_0_for_Windows

Next, download QTsource. This will enable Avisynth to directly open Quicktime movies.

http://www.tateu.net/software/

Put qtsource.dll in your Avisynth plugins folder, and you're good to go.



CHROMA FIX

When recording through the HDMI, the GH2 exhibits chroma jaggies in the red channel. Fortunately, Avisynth can correct this. These pictures are enlarged 2X for clarity. Thanks to GrgurMG for developing this section of the script.


Original


with Chroma Fix

The Advanced Script has a streamlined Chroma Fix that renders twice as fast as the original Chroma Fix.
The difference between the two Chroma Fixes is virtually imperceptible.

However, if you would like to run the original Chroma Fix, just replace the Chroma Fix section of the script with this:

Code:
#Original Chroma Fix
**FixBrokenChromaUpsampling() 
# Seperates the YUV channels. YV24 seems neccessary for the split and remerge to work.
**ConvertToYV24(chromaresample="spline36")
**Y = Tweak(sat=0, coring=false)
**U = UToY()
**V = VToY()
# Shifts the YUV channels individually. In this case subpixel(halfpixel) shifting.
**U = U.Spline36Resize(u.width,u.height,0.5,-0.5)
**V = V.Spline36Resize(v.width,v.height,0,-0.5)
**Y = Y.Spline36Resize(y.width,y.height,0,0.5)
# Manually squeezes the chroma down to 4:2:0 and back. Prevents further shifting.
**U = U.Spline36Resize(u.width,u.height/2)
**V = V.Spline36Resize(v.width,V.height/2)
**U = U.Spline36Resize(u.width,u.height*2)
**V = V.Spline36Resize(v.width,v.height*2)
# Recombines individual YUV channels.
**YToUV(U,V,Y)
# Depending on the source file you may need to convert from YV24 back to YUY2/YV12.

*************************************************
LOW LIGHT TRICKS for the GH2

Here's a useful link:
http://www.dvxuser.com/V6/showthread.php?237584-HDMI-Capture-Problem-SOLVED-AviSynth-RULES!/page55

*************************************************
FINAL NOTE


If you're coming here for the first time, be aware that you don't have to read through this lengthy thread. All the important information is right here in the first post. I have updated this post many times to incorporate the latest findings. If you do read through the thread, you're actually going back in time.

*************************************************
*************************************************
Technical Documentation


This section is for technical troubleshooting. Reading it is optional. You can skip this section and use the script just fine.

TESTING PROCEDURE

My testing procedure is to record a three minute clip with a head slate and a tail slate.
I place the MTS clip (that was recorded in camera) on the timeline in an editing program. This becomes my reference. Then I place the Avisynth processed clip on a track immediately above the MTS clip. Align the clips so the head slates match. Go to the end and see whether the tail slates match. Next, change the opacity of the Avisynth clip to 50%, which enables both clips to be seen at once. Then step through the timeline to make sure each frame is correctly aligned.

ABOUT THE THRESHOLDS

The advanced script has two thresholds in it. You probably won't have to adjust them, but for the sake of completeness, here is their documentation.

The first threshold is in fdecimate and it is important for the correct operation of the script. If you notice skipped frames or duplicate frames, the threshold might need adjustment. If the threshold is set too low, there will be duplicate frames. If the threshold is set too high, there will be skipped frames. The way to find the correct threshold is to turn on Metrics in fdecimate. In the script, temporarily replace fdecimate(threshold=whatever) with fdecimate(metrics=true). This will give you a numeric readout of the difference between each frame. The objective is to get rid of the duplicate frames. Run the script. As you step through the clip, make a note of the numbers associated with the duplicate frames. You want to set the threshold slightly higher than the largest of these numbers. In the script, replace fdecimate(metrics=true) with fdecimate(threshold=the number you found).

I found that a threshold of 0.5 works well if the footage has been recorded to a 4.2.2 codec at high quality.

You probably won't have to adjust the threshold, but if you do, be sure to run metrics first, so you have "hard numbers" to work with.

The second threshold is in the ConditionalFilter. It is the number to the right of "lessthan". If any duplicate frames manage to slip through fdecimate, the ConditionalFilter will catch them and interpolate inbetween frames usings mvtools2.

If you have any duplicate frames in the final output, I would examine this threshold before looking at the threshold in fdecimate, since this is where the problem is most likely to be. This threshold has a metric you can turn on to get a numerical readout of the difference brtween frames. The instructions are in the last four lines of the script. This threshold is currently set to 1.3. Duplicate frames should have a number less than the threshold and frames that are different should have a number greater than the threshold.

**************************************************
**************************************************

SCRIPT to PROCESS 1080 60i FOOTAGE

Here's a script designed to remove the extra fields from 1080 60i clips that have been captured through the HDMI.

This script is not perfect. The processed clip will occassionally fall one field behing the in-camera clip, and then catch up. I'm posting it for people who want to play around with it, but I would not recommend shooting "serious" footage with it.


Code:
aviSource("Your 1080 60i HDMI movie")

Load_Stdcall_plugin("C:\Program Files\AviSynth 2.5\plugins\yadif.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\FDecimate.dll")

Yadif(mode=1, order=1)
trim(1,0)

A=converttoyv12()

skip = 0 # no of frames skipped
pf = 0 # previous frame
A.Greyscale().FDecimate(rate=59.94, threshold=2.2)
ScriptClip("""
**GScript("
** *skip = current_frame < pf ? 0 : max(skip-2, 0)
** *while (current_frame+skip < Framecount(A) && LumaDifference(A.Trim(skip, 0)) > 0) {
** * *skip = skip+1 # skip decimated frame
** *}
**")
**pf = current_frame
**return A.Trim(skip, 0)
""")

delayaudio(.07)

AssumeFrameBased()
AssumeTFF()
SeparateFields()
SelectEvery(4, 0, 3)
Weave()
AssumeFPS(30000,1001)


In order to run this script, you need to have fdecimate.dll, yadif.dll and gscript.dll inside your Avisynth plugin folder.

You can download Yadif here:
http://avisynth.org.ru/yadif/yadif.html

Get Gscript here:
http://forum.doom9.org/showthread.php?t=147846
It's at the end of the first post - Attached Files
GScript_11.zip

fdecimate is here:
http://neuron2.net/fdecimate/fdecimate.html


**************************************************

SCRIPT NOTE 1: This script works by converting the footage into a 1080 60P stream in order to remove the duplicate fields. It then re-interlaces it at the end. However, there may be situations where it's desirable to not re-interlace and to output the 1080 60P stream. Such scenarios might include pulling blue or greenscreen keys, adding in computer graphics, motion tracking, and compositing in general.

If you wish to output the 60P stream, just delete this last section of the script:

AssumeFrameBased()
AssumeTFF()
SeparateFields()
SelectEvery(4, 0, 3)
Weave()
AssumeFPS(30000,1001)

SCRIPT NOTE 2: As with the 24P script, if you're recording audio through your HDMI device, be sure to run your own tests to determine the proper audio delay.

Very professional information, I think it seems to be difficult, but I can learn, the material is worth to collect. Tahnk you very much.
 
Last edited:
Very professional information, I think it seems to be difficult, but I can learn, the material is worth to collect. Tahnk you very much.

Yes, it seems complicated at first, but once you get over the learning curve, it's a totally automated process that you don't have to think about at all. Plus, learning how to use Avisynth is a valuable skill in it's own right. There's a tremendous amount of useful scripts and functions that have been developed for it over the years. You can do things with Avisynth that simply can't be done anywhere else, on any platform.
 
I just tested HDMI capture with Firmware 1.1 and can report that absolutely nothing has changed. You still need the Avisynth script to fix the video.
 
So I'm a little confused on how this works...

You record to an external recorder but have to manually ingest the footage with a capture card? Why? Why not just record to the external unit, import the media, and then go to AVIsynth?

Or when people are referring to a capture card, are they ingesting straight into a computer?
 
Last edited:
It's simple - ANY device that records an HDMI signal can be used - an external recorder, a capture card in a computer, etc.
If you use an external unit, all you have to do, as you say, is import the media, and then go to AVIsynth.
 
I just tested HDMI capture with Firmware 1.1 and can report that absolutely nothing has changed. You still need the Avisynth script to fix the video.

Sorry Ralph, I can see you're based in the US, so I suppose you've tested the NTSC version, right?

Can anyone confirm the HDMI signal that the PAL 1.1 firmware outputs on the new HBR 25p mode? Is it 25p encapsulated into a clean 50i signal or does it have extraneous fields? Are the chroma channels clean or still unfixed?

Thanks.
 
Can anyone confirm the HDMI signal that the PAL 1.1 firmware outputs on the new HBR 25p mode? Is it 25p encapsulated into a clean 50i signal or does it have extraneous fields? Are the chroma channels clean or still unfixed?

Thanks.

That's a good question. When I loaded the Firmware 1.1, I must have had a brain fart and did not test the new HBR modes through the HDMI. Forgive me, but I don't want to reload it because when I went back to Firmware 1.0, all my custom settings got wiped out. Perhaps someone else can answer the question for you.
 
Thanks Ralph.

I think this is big for many people and I find it strange that no one has tested this yet.

Someone with an Atomos and a PAL GH2, please test this!
 
Ralph,

Would it be possible for us to download a PRORES footage that was taken with GH2 + Ninja, but not processed through AviSynth? I would like to set up my laptop and practice with a footage before investing money to buy Ninja.

Also a question for you, Ralph. Why do you still use firmware 1.0? Is that to use a GH2 hack patch? If so, I am not sure why that is when you are shooting with Ninja?
 
Last edited:
Sorry bumkicho, but I don't have a Ninja. I use a Blackmagic Intensity board inside my Windows machine. Hopefuly somebody out there with a Ninja can upload an unprocessed file for you. I agree it's a good idea to practice before investing money in gear.
 
Sorry, tried to search the thread, but search seem to freeze. With using the AviSynth, to process a 30 minute recording, how long does that take?

Thanks
Doug
 
ADDITIONS TO THE FIRST POST

Today I added a section about whether the HDMI output is 4.2.2, and also added some Words of Encouragement.
 
Back
Top