View Full Version : [REQUEST] Xvid Encoder Modification
fmagreed2
17th December 2010, 03:25
I need a relatively simple modification done to the xvid encoder (windows version, 32 bit), and was hoping someone would be able to do this for me since I lack the tools and experience.
All I need is for someone to let the encoder accept HDYC pixel format. This should be pretty simple, since all that needs to be done is aliasing this format with UYVY. Just making the codec think HDYC is UYVY.
Yes, I realize that there will be slight colorspace issues doing this, but it's not an issue for my usage, and it would mean some difficult coding. On the other hand I hope this will just require adding something like "|| HDYC" in a few places and won't take more than 10 minutes for someone to do.
So, is someone able to do this for me? I'll love you forever... or not, if that makes you uncomfortable.
If you curious why I need this:
I want to record using a Black Magic device in virtualdub, which output HDYC. Unfortunately the only codecs available for HDYC are huffyuv and mjpeg. I'm going to be recording lengthy clips and don't exactly want to spend $300 on hard drives.
yetanotherid
2nd January 2011, 03:38
I assume you're opening the capture device directly with VirtualDub? If so I guess you can't convert the colorspace using a VD filter or something like that?
If I had to get around your problem (and I'm really only replying because I can think of a possible way around it and nobody else has replied with a better idea) I'd probably try something like this (no guarantee it'll work as I've not done it myself, it's just a theory).
In theory you could open the capture device with VD and use it as a frameserver. I would assume that way the video VD frameserves will still be in the original colorspace. I don't recall if VD will frameserve a device it's opened and I don't have a capture device installed in this PC to check it, so if it doesn't my theory falls about here, and getting the VD frameserver to work can either be easy, or it'll leave you with permanent emotional scarring before it does, but that's another topic for another post. Once you do have it working, it should keep working every time. Assuming you've got the frameserver working....
You've opened the capture device with VD and you're frameserving it's output to an AVI file. Next you create a simple AVISynth script to open the framserved AVI using AVISynth (I'm assuming you have AVISynth installed). All the script needs to do is tell AVISynth to frameserve the VD AVI and to convert the colorspace while it's at it. For example you'd open notepad, type in something like this and save it with an avs extension instead of txt.
DirectShowSource("D:\MyVideo.avi")
ConvertToYV12(clip, interlaced=true)
(Leave the interlaced part in as it should be ignored if the video isn't interlaced). The whole theory might fall apart at this point. I guess it depends on whether AVISynth accepts the input colorspace, and I'm far from an AVISynth expert. However from the AVISynth help file:
"Huffyuv will act as the system YUY2 codec if there's no other codec installed, so if you install Huffyuv and uninstall all other YUY2 codecs, then you'll never need ConvertToRGB."
So if it's using Huffyuy as the system YUY2 codec, and if huffyuy supports your input colorspace..... I'm just working on theory... an alternative to the first script might be:
AVISource("D:\MyVideo.avi")
ConvertToYV12(clip, interlaced=true)
That, I think, will get AVISynth to open the frameserved AVI directly using a vfw codec rather than via DirectShow.
You may even be able to bypass using AVISynth to convert the colorspace though, as if you do open the frame served AVI with AVISyth, via DirectShow, then assuming you have ffdshow installed it will be decoding the capture device output and I'd be thinking there's a good change it'll accept your original input colorspace while outputting something more normal.
Which also makes me wonder....and sorry if this reads like I'm thinking out loud as I type but I'm thinking out loud as I type.....
Instead of using huffyuy as the output codec when converting the capture device output with VD originally, have you tried using the ffdshow encoder instead to see if it's able to cope with the original input colorspace? Because ffdshow includes the huffyuy decoder and encoder, or a variation of it.
Anyway, finally you'd open the AVS Script with a second instance of VirtualDub and use it to convert the AVISynth output to the format of your choice. Or you could even wrap the script into another AVI (MakeAVIS comes with the full ffdshow installation, or there's AVS2AVI 0.3) which would let you open and convert the AVISynth output with any program which can open AVI files... (for those which don't open AVISyth scripts).
If you try all that, let me know how it goes. As I said, it's just ideas for lack of any better suggestions.
fmagreed2
2nd January 2011, 19:08
Converting the colorspace using a VD filter doesn't seem to let you send the video stream to a different encoder.
This is pretty easy to test using ffdshow, if you're curious. In the VFW settings, set it to only accept YV12 (Input->Force Input Colorspace). Set it to capture a section of your desktop (which will be in RGB format). If you go to compression, ffdshow will be unavailable. Turn on the filter Convert Format and set it to YV12, then head back to compression. Ffdshow is still unavailable.
It doesn't look like virtualdub can frameserve from a capture device, so that's a no go. The option is only available if you've opened a file in non-capture mode.
Ffdshow was the first thing I tried. It doesn't support HDYC either. The only encoder's I've found that can handle it are the Black Magic mjpeg encoder and a modified version of huffyuv found here:http://forums.virtualdub.org/index.php?act=ST&f=6&t=16116.
The huffyuv build does nothing special. All I did was modify GetBitmapType to accept UYVY || HDYC.
Thank you for the response, though. I was starting to lose hope of any answer at all.
yetanotherid
4th January 2011, 08:20
Converting the colorspace using a VD filter doesn't seem to let you send the video stream to a different encoder.
This is pretty easy to test using ffdshow, if you're curious. In the VFW settings, set it to only accept YV12 (Input->Force Input Colorspace). Set it to capture a section of your desktop (which will be in RGB format). If you go to compression, ffdshow will be unavailable. Turn on the filter Convert Format and set it to YV12, then head back to compression. Ffdshow is still unavailable.
Yeah.... but going to Video/Select Custom Format and changing it to YV12 makes the ffdshow encoder appear again. ;-) According to the help file the main use for the convert format filter is for use when capturing, so maybe you got to set the output format to something the filter understands first, as it seems VD doesn't do it automatically in capture mode like it does in normal mode.
According to the help file when capturing, as VD doesn't automatically convert to the correct format for filters, if the filter isn't compatible with the input format it'll be disabled. To me that implies if you can set the color depth dialog to the required output format and you've still got filters to play with then your captured input is being converted by VD before it gets to the filter stage (maybe with the huffyuv codec helping there as mentioned in my previous post?) so the final output should be in the correct format too.
It's hard for me to try things because without a capture card I'm stuck in screen capture mode and I suspect the way VD processes the image is different than in normal capture mode and I don't have the same options to play with.
My understanding of the different re-compression options is either wrong or VD has changed since I last used it for anything serious, but anyway....
Do you still have the Video/Filter Chain menu when in normal capture mode? If so there's an option to stop VD converting the final output to RGB which might need to be enabled too.
I wish I could play around a bit more but unfortunately I can't run the program the same way without an actual capture device, so maybe I'm not posting anything useful....
GodofaGap
4th January 2011, 10:28
Yeah.... but going to Video/Select Custom Format and changing it to YV12 makes the ffdshow encoder appear again. ;-) According to the help file the main use for the convert format filter is for use when capturing, so maybe you got to set the output format to something the filter understands first, as it seems VD doesn't do it automatically in capture mode like it does in normal mode.
No that doesn't work at all. You can only set a custom format if the capture device itself supports the format.
It seems like a reasonable request for VirtualDub as I'm not sure if the current behavior is intended. That way you don't need modified versions of codecs all the time.
fmagreed2
4th January 2011, 18:55
As GodofaGap said, selecting a custom format only works if the capture device. It's more selecting the input format than doing any actual converting. Try selecting YV12 while doing a screen capture. You'll get an error. Nothing but RGB works for screen capture. It's a similar situation for the black magic cards. Nothing but HDYC.
Now that I think about it, the interaction between the filters and codecs is very odd. Information I can find implies that after filters you're left with an RGB24 video stream, unless you uncheck the option. Basically every codec around can handle RGB24, so you'd think simply enabling the filter chain would let you use any codec you'd like.
What codec virtualdub can output to seems to still be limited by the input format. Seems like it can convert the video stream for filters and such, so it strikes me as a design failing... I'll bring it up over on their forums.
Still stuck as it stands, unfortunately.
yetanotherid
6th January 2011, 07:21
As GodofaGap said, selecting a custom format only works if the capture device. It's more selecting the input format than doing any actual converting. Try selecting YV12 while doing a screen capture. You'll get an error. Nothing but RGB works for screen capture. It's a similar situation for the black magic cards. Nothing but HDYC.
Except that I was using the screen capture when I tried it. Admittedly I don't think any of the other input formats worked but YV12 did. Maybe it's the only alternative to RGB in screen capture mode.
Well it looks like all my ideas bombed out.
I think the original filter chain/RGB thing was because VD filters could originally only work with RGB so the minute you used a filter you were converting to RGB and the output was RGB regardless. These days I think it works differently and the way normal and fast recompress handle colourspace conversion is different but I'd have to go through the help files again to try to understand it properly.
fmagreed2
15th January 2011, 02:28
An update:
I posted over on the virtualdub forums concerning the strangeness of how virtualdub handles various formats (RGB conversion for filters vs encoders). It's been confirmed as a bug. If you're interested, here's the thread.
http://forums.virtualdub.org/index.php?act=ST&f=15&t=19566
yetanotherid
15th January 2011, 16:37
Ah.... well even if it doesn't work, it at least makes sense now.
Cheers.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.