Log in

View Full Version : How to prevent auto colourspace conversion with OpenDMLSource?


fvisagie
4th September 2009, 10:43
Dear All,

In order to render overlay subtitles during encoding with FFmpeg I'm frame serving the DV AVI Type 2 input with Avisynth and TextSub. For frame accuracy and to maintain sync with subtitles I'm using OpenDMLSource (the input file is 36GB, too large for AVIFileSource).

The DV AVI video format is YV12 and when I'm not adding subtitles and using FFmpeg directly, it processes that beautifully. Therefore I'd prefer for AVS to read and directly output YV12 without any conversion.

However, when using AVS the video format FFmpeg receives is rawvideo BGRA.

This creates a couple of problems:
* the colourspace conversion seems to halve the speed of processing compared to using DirectShowSource
* the output video is flipped (I notice in mpeg2dec3.htm: "#YV12->BGR24 convertion natively flips image")
* to correct that I need to add FlipVertical() which slows down processing even further
* all together, be it due to the colourspace conversion and/or FlipVertical(), the output quality is noticeably inferior compared to DirectShowSource

The obvious answer seems to be to call OpenDMLSource with pixel_type="YV12".

However, that produces the error message:

the video decompressor couldn't produce YV12 output

How can I prevent this forced colourspace conversion away from YV12, or is there some other way of by-passing the problems it creates?

Many thanks,
Francois

Gavino
4th September 2009, 11:38
Install the Cedocida DV codec, which allows you to choose the format output by the decompressor.

fvisagie
4th September 2009, 12:26
That's just brilliant. Cedocida DV was installed, but YV12 output was disabled. :)

I wasn't aware that AVS' OpenDML would also attempt external codecs. VDub does, of course, except it can be configured to try internal ones first. Do you know what AVS OpenDML behaviour is with respect to selecting external vs internal codecs?

A quick test shows your suggestion works beautifully. YV12 input to FFmpeg, colour saturation is equivalent to DirectShow's and sharpness is actually slightly better. Probably because the (default) DirectShow output to FFmpeg in this scenario gets converted to yuyv422. That could probably be improved upon, but then my aim is to use OpenDML anyway.

OpenDML is still around 20% slower than DirectShow, but this is with a low-quality test encode which runs at 34fps with DirectShow and 27fps with OpenDML. Previously the high-quality encode would run at 3fps with or without AVS inputting, so I'm sure once again FFmpeg will become the bottleneck with the high-quality encode.

Thanks for again helping me out so brilliantly!

TheFluff
4th September 2009, 13:21
Avisynth doesn't have an internal DV decoder like Vdub does.

fvisagie
4th September 2009, 13:24
Avisynth doesn't have an internal DV decoder like Vdub does.

Many thanks.

fvisagie
8th September 2009, 08:10
Hey Guys,

Although it may not appear like much, this information was the final key to a nine-month-long project that culminated (with your help here) in a beautiful encode! Crisp colours, sharp definition, pin-point accurate inlay subtitles rendered by AVS and encoded by FFmpeg.

Your help is sincerely appreciated.

Kind regards,
Francois

foxyshadis
11th September 2009, 05:47
AviSource is actually just a call to OpenDMLSource when the file is over 2 gb or otherwise an OpenDML avi. So you may as well be using AviSource, and they're both quite similar internally. Just an FYI, I know you got things taken care of.

henryho_hk
11th September 2009, 07:15
No matter it's PAL or NTSC DV, you can't go wrong with Cedocida DV codec. To ensure a sharp output for DVD, XviD or H.264, remember to choose "MPEG4" in its YV12 output config. Or you can set pixel_type="YUY2" (some ppls prefer it for NTSC DV) in the AVISource() call to force YUY2 and then apply your favourite filter function.

I highly recommend mdegrain() for home DV productions too. It's a wonderful denoiser. And with it (and its slowness), you will never need to worry about the speed of the source functions. ^_^ Not to mention TempGaussMC_beta1mod(), an excellent bobber with built-in mdegrain().

fvisagie
11th September 2009, 07:51
AviSource is actually just a call to OpenDMLSource when the file is over 2 gb or otherwise an OpenDML avi. So you may as well be using AviSource, and they're both quite similar internally. Just an FYI, I know you got things taken care of.

For the sake of consistent behaviour and results I wanted (and want) to invoke OpenDML explicitly, but many thanks for the kind suggestion.