Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 5th May 2012, 07:55   #1  |  Link
peacemaker69
Registered User
 
Join Date: Apr 2012
Posts: 7
Importing DNxHD to Avisynth

Is there any way I can use DNxHD codec (mov container) with Avisynth?

I am delivering DNxHD master files to tv station and I want to run a script that would detect black frames in a video.

thanks
peacemaker69 is offline   Reply With Quote
Old 5th May 2012, 09:29   #2  |  Link
Yellow_
Registered User
 
Join Date: Sep 2009
Posts: 378
ffmpegsource2

http://code.google.com/p/ffmpegsource/
Yellow_ is offline   Reply With Quote
Old 7th May 2012, 21:47   #3  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: UK
Posts: 2,324
There use to be a bug in ffmpeg and DNxHD 10bit decoding in ffmpeg, so I assume there is one in ffmpegsource. I thought it was fixed, but recently saw it in latest LAV filters, so I assume it's still in ffmpeg itself. Problem appears in high contrast areas and can be missed. If you want just detect black frames than it's not an issue in your case, but for decoding itself it can be.
Use QT input instead.
kolak is offline   Reply With Quote
Old 17th June 2012, 02:23   #4  |  Link
Keiyakusha
契約者
 
Keiyakusha's Avatar
 
Join Date: Jun 2008
Posts: 1,567
I just used mentioned FFMS2 and opened my 10bit DNxHD correctly. Did some tests to verify it and all was alright. You just need to make sure that DNxHD encoder doesn't set to scale levels and remember that it uses bt709 colorimetry but avisynth (and some other opensource stuff) works in bt601, so you will see wrong colors if you open script lets say in VirtualDub... Don't know about LAVfilters.

Back to business, opening DNxHD is not that hard, but how to do it while keeping it 10bit? As stacked or interleaved clip. Is there any ways? Anyone brave enough to compile fresh hacked FFMS2 to do it?

Last edited by Keiyakusha; 17th June 2012 at 06:53.
Keiyakusha is offline   Reply With Quote
Old 17th June 2012, 05:46   #5  |  Link
cretindesalpes
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
 
cretindesalpes's Avatar
 
Join Date: Feb 2009
Location: No support in PM
Posts: 610
SAPikachu built a few FFMS2 versions with stack16 output, although they are sporadically updated. Just add enable10bithack=true to the FFVideoSource parameters. It works wonders on AVC sources, but I don't know for other codecs.
__________________
dither 1.27.2 for AviSynth | avstp 1.0.3 for AviSynth development | fmtconv r19 for Vapoursynth | trimx264opt segmented encoding
cretindesalpes is offline   Reply With Quote
Old 17th June 2012, 08:10   #6  |  Link
Keiyakusha
契約者
 
Keiyakusha's Avatar
 
Join Date: Jun 2008
Posts: 1,567
Quote:
Originally Posted by cretindesalpes View Post
SAPikachu built a few FFMS2 versions with stack16 output, although they are sporadically updated. Just add enable10bithack=true to the FFVideoSource parameters. It works wonders on AVC sources, but I don't know for other codecs.
Thanks! I wonder how i missed that...
I just tested FFMS2 r656 on v210 stream in .mov container (Because I have something to compare it to. DNxHD is not lossless so its hard to compare it to something, but it behaves similar.)

So here is FFMS2 input, and here is readv210 of the same source.
Result is similar, which indicates that it works, but as you can see there is some difference. This is because v210 (same as DNxHD) have 4:2:2 chroma subsampling, but FFMS2 opens clips only as YV12.
On my screenshot ConvertToYV12() was used after readv210 input to make them even (maybe not the best idea).
I tried to add "colorspace=yuy2" switch to FFVideosource, but then it opens video without 10bit hack.
Should I configure something else or that's how it works right now? If latter, this is certainly step forward but unfortunately still not enough.
And this is how opened as YV12 DNxHD looks (110 mbps). And 4:4:4 profile for some reason kills libswscale ^__^

Last edited by Keiyakusha; 17th June 2012 at 21:36.
Keiyakusha is offline   Reply With Quote
Old 27th June 2012, 14:17   #7  |  Link
SAPikachu
Registered User
 
SAPikachu's Avatar
 
Join Date: Aug 2007
Posts: 218
Just built a new FFMS that supports 4:2:2 and 4:4:4 videos, you can download it at: http://nmm.me/kx

I tested this version using a DNxHD sample posted on this page. Seems it works correctly, the LSB part come out without problem. AvsP incorrectly reports the clip as YV12, subtitle("IsYV16: " + string(IsYV16)) shows the clip is actually YV16.

Hope this helps.
__________________
f3kdb 1.5.1 / MP_Pipeline 0.18

ffms2 builds with 10bit output hack:
libav-9a60b1f / ffmpeg-1e4d049 / FFmbc-0.7.1
Built from ffms2 6e0d654 (hack a9fe004)

Mirrors: http://bit.ly/19TwDD3

Last edited by SAPikachu; 27th June 2012 at 14:18. Reason: fix download link
SAPikachu is offline   Reply With Quote
Old 27th June 2012, 14:24   #8  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: UK
Posts: 2,324
Does it mean that we can import DNxHD at 10bit and dither to 8bit inside avisynth?

Please note: there is a bug in DNxHD 10bit decoder, which shows up on high contrast areas as a sort of halo/ringing. It has been reported long time ago to ffmbc developer and it's fixed there, but eg latest LAV filter still introduce this problem, so I'm not sure if it was ever fixed with ffmpeg.
kolak is offline   Reply With Quote
Old 27th June 2012, 14:35   #9  |  Link
SAPikachu
Registered User
 
SAPikachu's Avatar
 
Join Date: Aug 2007
Posts: 218
Yes, that's possible, and we can keep full 4:2:2 colorspace now.

I'm not sure whether the bug has been fixed either, maybe you can check change log of libav to see it.
__________________
f3kdb 1.5.1 / MP_Pipeline 0.18

ffms2 builds with 10bit output hack:
libav-9a60b1f / ffmpeg-1e4d049 / FFmbc-0.7.1
Built from ffms2 6e0d654 (hack a9fe004)

Mirrors: http://bit.ly/19TwDD3
SAPikachu is offline   Reply With Quote
Old 27th June 2012, 14:39   #10  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: UK
Posts: 2,324
I'm bit busy, but will check on some sample and report.
kolak is offline   Reply With Quote
Old 27th June 2012, 15:12   #11  |  Link
Keiyakusha
契約者
 
Keiyakusha's Avatar
 
Join Date: Jun 2008
Posts: 1,567
Quote:
Originally Posted by SAPikachu View Post
Just built a new FFMS that supports 4:2:2 and 4:4:4 videos, you can download it at: http://nmm.me/kx
...

Hope this helps.
Just tried and it works!
I try to use free alternative to professional software where possible. This is huge help, thanks! (^o^)

Last edited by Keiyakusha; 27th June 2012 at 15:22.
Keiyakusha is offline   Reply With Quote
Old 27th June 2012, 15:19   #12  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: UK
Posts: 2,324
Can you post your import script please, so I can quickly check if decoding is fine.
Please include whole script with dithering. Just looked at some source, which clearly shows problem in LAV filter.

Last edited by kolak; 27th June 2012 at 15:24.
kolak is offline   Reply With Quote
Old 27th June 2012, 15:23   #13  |  Link
Keiyakusha
契約者
 
Keiyakusha's Avatar
 
Join Date: Jun 2008
Posts: 1,567
What do you mean by import script? You don't need anything except ffms2 call to open file...

Edit:
Ffvideosource("Comp 1.mov",enable10bithack=true)
f3kdb_dither()

is this what you want?

can it be that ffmbc developer fixed it but didn't sent fix upstream to ffmpeg? If so, he really should.

Last edited by Keiyakusha; 27th June 2012 at 15:41.
Keiyakusha is offline   Reply With Quote
Old 27th June 2012, 16:10   #14  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: UK
Posts: 2,324
Yes- problem is there, so whoever is using it be careful!

Artefacts on high contrast areas, eg white text on black background. It creates sort of halo, contouring- something like mosquito noise on eg. mpeg2 encodes.

It's definitely fixed in ffmbc.





I resized and applied levels filter to make it more obvious.

Last edited by kolak; 27th June 2012 at 17:12.
kolak is offline   Reply With Quote
Old 27th June 2012, 16:27   #15  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: UK
Posts: 2,324
Quote:
Originally Posted by SAPikachu View Post
Yes, that's possible, and we can keep full 4:2:2 colorspace now.

I'm not sure whether the bug has been fixed either, maybe you can check change log of libav to see it.
As far as I understand it will work for ProRes also- yes?
kolak is offline   Reply With Quote
Old 28th June 2012, 00:58   #16  |  Link
SAPikachu
Registered User
 
SAPikachu's Avatar
 
Join Date: Aug 2007
Posts: 218
Quote:
Originally Posted by kolak View Post
As far as I understand it will work for ProRes also- yes?
Yes, it should support most formats that libav supports, seems libav can decode ProRes but I haven't tested it.

By the way, is there any patch for the bug? I can check whether it can be applied to current version.
__________________
f3kdb 1.5.1 / MP_Pipeline 0.18

ffms2 builds with 10bit output hack:
libav-9a60b1f / ffmpeg-1e4d049 / FFmbc-0.7.1
Built from ffms2 6e0d654 (hack a9fe004)

Mirrors: http://bit.ly/19TwDD3

Last edited by SAPikachu; 28th June 2012 at 01:09.
SAPikachu is offline   Reply With Quote
Old 28th June 2012, 12:11   #17  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: UK
Posts: 2,324
Tried 10bit ProRes and all seams to be fine Sometimes decoding is bit unstable during seeking, but during convert seams to be ok. Overall speed is also good- 2x faster than RT on my i7 990x on 24p HD source.

DNxHD 10bit decoding is fixed in ffmbc, so I assume it can be ported to ffmpeg.
kolak is offline   Reply With Quote
Old 28th June 2012, 14:47   #18  |  Link
SAPikachu
Registered User
 
SAPikachu's Avatar
 
Join Date: Aug 2007
Posts: 218
Just downloaded source code of ffmbc to have a quick check, their DNxHD decoder diverged from the one of official libav/ffmpeg, and they didn't provide any code history. So it's very hard to extract a patch from it and I don't have time to do that. Maybe someone can ask them for the related patch?
__________________
f3kdb 1.5.1 / MP_Pipeline 0.18

ffms2 builds with 10bit output hack:
libav-9a60b1f / ffmpeg-1e4d049 / FFmbc-0.7.1
Built from ffms2 6e0d654 (hack a9fe004)

Mirrors: http://bit.ly/19TwDD3
SAPikachu is offline   Reply With Quote
Old 28th June 2012, 16:29   #19  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: UK
Posts: 2,324
http://code.google.com/p/ffmbc/

Guy is responsive so you can ask him.
kolak is offline   Reply With Quote
Old 28th June 2012, 17:00   #20  |  Link
Keiyakusha
契約者
 
Keiyakusha's Avatar
 
Join Date: Jun 2008
Posts: 1,567
I asked but no response so far. Well it was only few hours ago so too early to say something.
Keiyakusha is offline   Reply With Quote
Reply

Tags
avisynth, black frames, detecting, dnxhd, mov

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:47.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.