Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

Pages: (3) [1] 2 3  ( Go to first unread post )
Mp4 Input Driver
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
SEt
Posted: Mar 2 2008, 01:48 AM


Newbie


Group: Members
Posts: 6
Member No.: 23164
Joined: 2-March 08



I've made MP4 Input Driver for VD: http://rain.ifmo.ru/~skakov/mp4inputdriver.7z

Current version (0.1) supports only video and works only with VD 1.8 (requires decompression in VD).

It would've worked well if not for 2 problems:

1) I need to pass 'decoder specific info' to decoder.

Under DirectShow you just need to append it after VIDEOINFOHEADER/MPEG2VIDEOINFO/... and include its len in cbFormat of AM_MEDIA_TYPE. But this method dosen't work here (i've tried to append it after VDXBITMAPINFOHEADER in IVDXStreamSource::GetDirectFormat and add its len to IVDXStreamSource::GetDirectFormatLen).

Without this info ASP is decoded fine except first keyframe and AVC isn't decoded at all in VD. After saving to avi in direct stream copy file plays fine in DirectShow players (both ASP and AVC, decoded by FFDShow) but again dosen't work in VD.

2) VD decoder dosen't support B-frames.

Example video stream: IPPBPB
samples in stream order: 012345
samples in presentation order: 013254

For frame 2 (sample 3) video decoder model requires samples 0 1 2 3 -1 (preroll is always false). Frame is displayed fine, decode buffer contans 2 decoded frames (first - frame3/sample2 and second - frame2/sample3).
After that for frame 3 (sample2) video decoder model immediately returns -1 - frame is already decoded and in buffer. But VD flushed decode buffers after previous step and can't display the frame.

So to support decoding streams with B-frames VD needs to be able to remember 1 extra frame in decode buffer in sequential decoding.

(I know both problems could be solved by writing IVDXVideoDecoder but it's quite a waste to write decoder for every input driver while VD is able do it.)


Some other questions:

1) Where can i find sources of DShowInputDriver-0.4 ? It has bug that i want to fix: CoreAVC returns image with nagative height and VD shows it upside down.

2) Why IVDXVideoDecoderModel::SetDesiredFrame called 'frame' while it gets 'sample'? Some other functions look strange too: for example, what is the point of getting sample position by IVDXVideoSource::GetSampleBytePosition and by IVDXVideoSource::GetSampleInfo ?

3) Is some kind of Output Driver interfaces planned? I'd like to write MP4 output plugin too.
 
     Top
Gromozeka
Posted: Mar 2 2008, 10:37 AM


Unregistered









I like idea about mp4 plugin output and input smile.gifsmile.gifsmile.gif
You will be helped by this program:
http://sourceforge.net/projects/mp4cam2avi
This program allows direct stream copy mp4 (avc too) save to avi container
 
  Top
rjisinspired
Posted: Mar 2 2008, 03:43 PM


Advanced Member


Group: Members
Posts: 1256
Member No.: 20008
Joined: 12-October 06



Thanks for that link. I had mp4cam2avi but it was an older copy from 2006. Now I can upgrade smile.gif
 
       Top
DarrellS
Posted: Mar 2 2008, 06:45 PM


Advanced Member


Group: Members
Posts: 567
Member No.: 1061
Joined: 28-November 02



I don't have any mp4 files with audio to check but Virtualdub 1.8.0 will open HDMOV files which are the same (H264 AVC1 / AAC), I assume with the help of ffdshow and the QT plugin. (I converted a 170MB HDMOV trailer to a 107MB HD-Divx/mp3 file).

Will having both the QT plugin and your mp4 plugin cause any conflicts? Do you have to use ffdshow with your plugin or does it have a built in H264/AVC1 decoder?
 
     Top
rjisinspired
Posted: Mar 2 2008, 07:32 PM


Advanced Member


Group: Members
Posts: 1256
Member No.: 20008
Joined: 12-October 06



I was able to open an h264 video with both plugins, qt and mp4 with no issues or conflicts. Right now I moved out the qtplugin and there are no problems at all.

Originally I had the mp4 input filter in the plugin32 folder, I had to replace it to the root of the folder or else the plugin doesn't get picked up.

The video file tested was a Cranky Geeks h264 video with John "I get no spam" Dvorak. Video plays fine on my end. Excellent job smile.gif
 
       Top
phaeron
Posted: Mar 3 2008, 12:31 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



QUOTE
1) Where can i find sources of DShowInputDriver-0.4 ? It has bug that i want to fix: CoreAVC returns image with nagative height and VD shows it upside down.


I've uploaded DShowInputDriver 0.4 source: http://www.virtualdub.org/beta/DShowInputD...ver-0.4-src.zip

Is the format RGB or YUV? Negative biHeight for YUV is a no-op.

QUOTE
So to support decoding streams with B-frames VD needs to be able to remember 1 extra frame in decode buffer in sequential decoding.


The biggest problem with supporting a frame delay in the decoder is knowing when the delay exists. How do you detect this?

QUOTE
2) Why IVDXVideoDecoderModel::SetDesiredFrame called 'frame' while it gets 'sample'?


A quirk of the way that the internal interface works -- it's generally more convenient to get the frame as a sample number, because generally this routine needs to look up in decode order and for plugins that do out-of-order decoding the sample order is usually more convenient. Note that the sample order is completely arbitrary -- typically plugins set it to decode order.

QUOTE
Some other functions look strange too: for example, what is the point of getting sample position by IVDXVideoSource::GetSampleBytePosition and by IVDXVideoSource::GetSampleInfo ?


GetSampleBytePosition() is mainly for UI purposes, although it can also be used for I/O optimization by the host. GetSampleInfo() is used during preview for frame dropping purposes, as it can identify frames that can be skipped.
 
    Top
SEt
Posted: Mar 3 2008, 02:42 AM


Newbie


Group: Members
Posts: 6
Member No.: 23164
Joined: 2-March 08



QUOTE (phaeron @ Mar 3 2008, 12:31 AM)
Is the format RGB or YUV? Negative biHeight for YUV is a no-op.

Format is RGB.

QUOTE (phaeron @ Mar 3 2008, 12:31 AM)
QUOTE
So to support decoding streams with B-frames VD needs to be able to remember 1 extra frame in decode buffer in sequential decoding.

The biggest problem with supporting a frame delay in the decoder is knowing when the delay exists. How do you detect this?

Decoder sometimes gets 2 frames instead of 1 requested: future P frame and than requested B frame. I.e. GetNextRequiredSample returns 2 sample numbers with is_preroll=false before it returns -1. Decoding buffer should become stack: on GetNextRequiredSample -1 it returns last decoded frame and remembers its state in sequential decoding, so when the time comes for P frame that was decoded earlier than needed for presentation GetNextRequiredSample immediately returns -1 and pops that frame from the stack. See the decoder model in my MP4 input driver.

In practice decoding stack size of 2 is enough for B frames, but if you want to write universal support - you can enlarge stack in realtime or ask input driver what max size it needs.

QUOTE (phaeron @ Mar 3 2008, 12:31 AM)
QUOTE
2) Why IVDXVideoDecoderModel::SetDesiredFrame called 'frame' while it gets 'sample'?

A quirk of the way that the internal interface works -- it's generally more convenient to get the frame as a sample number, because generally this routine needs to look up in decode order and for plugins that do out-of-order decoding the sample order is usually more convenient. Note that the sample order is completely arbitrary -- typically plugins set it to decode order.

I understand how it works and what it's more convenient this way. Just saying that the function name is incorrect for what it do.

QUOTE (phaeron @ Mar 3 2008, 12:31 AM)
QUOTE
Some other functions look strange too: for example, what is the point of getting sample position by IVDXVideoSource::GetSampleBytePosition and by IVDXVideoSource::GetSampleInfo ?

GetSampleBytePosition() is mainly for UI purposes, although it can also be used for I/O optimization by the host. GetSampleInfo() is used during preview for frame dropping purposes, as it can identify frames that can be skipped.

They may be different for host purposes, but they are equivalent for input driver (at least so it seems to me), so no reason to write exactly the same code twice in plugin when host can call single function for any purpose it needs.

VDXVideoFrameInfo::mTypeChar seems to me redundant too - no reason for input plugin to keep 'K'/' ' naming instead of more flexible 'I'/'P'. Yes, it provides a way to show a bit more information by using arbitrary symbols, but some kind of 'frame comment' field would be much better for that purpose.

I suggest to clean the API while it's still possible (there are few input drivers now).

QUOTE (DarrellS @ Mar 2 2008, 06:45 PM)
Will having both the QT plugin and your mp4 plugin cause any conflicts? Do you have to use ffdshow with your plugin or does it have a built in H264/AVC1 decoder?

There might be conflicts in autoselect mode - if one input driver accepted file but later failed to open it VD dosen't try other drivers. No conflicts if you select input driver you want.

No bult in decoder (should be obvious from the source size). ffdshow or any other that can work with VD will do.
 
     Top
SEt
Posted: Mar 3 2008, 02:57 PM


Newbie


Group: Members
Posts: 6
Member No.: 23164
Joined: 2-March 08



Bugfixes for DShowInputDriver: http://rain.ifmo.ru/~skakov/DShowInputDriverFix.7z

Also i've noticed that RGB565 works incorrectly in VD1.7.8 input plane (output is correct) and in VD1.8.0 in both input and output planes.
 
     Top
Gromozeka
Posted: Mar 3 2008, 03:56 PM


Unregistered









SEt
But why only source?
Хотя в любом случае спасибо! smile.gif
 
  Top
DarrellS
Posted: Mar 3 2008, 04:23 PM


Advanced Member


Group: Members
Posts: 567
Member No.: 1061
Joined: 28-November 02



After installing the mp4 input filter, I couldn't load mp4 or QT files. I got black panels without error messages.

Removed the mp4 input filter and all the files open again. Under File > File Information, it gives me the information of the files (H.264 avc1 - 48000Hz 5.1 16bit PCM mp4a). The file information window doesn't open with the mp4 input filter installed.
 
     Top
SEt
Posted: Mar 3 2008, 09:12 PM


Newbie


Group: Members
Posts: 6
Member No.: 23164
Joined: 2-March 08



Gromozeka, it's phaeron's filter so i think it's up to him to release new version.
If you want to have absolutely the latest build you can always build it yourself from sources - it builds without any problems.

DarrellS, have you read the first post? There described 2 current problems with decoding. It's not the final fully functional version yet.
 
     Top
phaeron
Posted: Mar 4 2008, 04:13 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



QUOTE (SEt @ Mar 2 2008, 07:42 PM)
QUOTE (phaeron @ Mar 3 2008, 12:31 AM)
QUOTE
So to support decoding streams with B-frames VD needs to be able to remember 1 extra frame in decode buffer in sequential decoding.

The biggest problem with supporting a frame delay in the decoder is knowing when the delay exists. How do you detect this?

Decoder sometimes gets 2 frames instead of 1 requested: future P frame and than requested B frame. I.e. GetNextRequiredSample returns 2 sample numbers with is_preroll=false before it returns -1. Decoding buffer should become stack: on GetNextRequiredSample -1 it returns last decoded frame and remembers its state in sequential decoding, so when the time comes for P frame that was decoded earlier than needed for presentation GetNextRequiredSample immediately returns -1 and pops that frame from the stack. See the decoder model in my MP4 input driver.

In practice decoding stack size of 2 is enough for B frames, but if you want to write universal support - you can enlarge stack in realtime or ask input driver what max size it needs.

Okay, I'm not quite sure what you're requesting here now: are you talking about the situation where the input plugin supplies the video decoder model and lets VirtualDub handle the video decoding? If so, that's a fairly weird situation.

QUOTE

Bugfixes for DShowInputDriver: http://rain.ifmo.ru/~skakov/DShowInputDriverFix.7z

Also i've noticed that RGB565 works incorrectly in VD1.7.8 input plane (output is correct) and in VD1.8.0 in both input and output planes.


Thanks for the fixes... I've integrated them into v0.5 -- see the DShowInputDriver thread for details. Also, if you have more info about the RGB565 issue, please post it there -- I tried to reproduce it and couldn't do so.


This post has been edited by phaeron on Mar 4 2008, 05:52 AM
 
    Top
SEt
Posted: Mar 7 2008, 12:42 PM


Newbie


Group: Members
Posts: 6
Member No.: 23164
Joined: 2-March 08



QUOTE (phaeron @ Mar 4 2008, 04:13 AM)
Okay, I'm not quite sure what you're requesting here now: are you talking about the situation where the input plugin supplies the video decoder model and lets VirtualDub handle the video decoding? If so, that's a fairly weird situation.

Yes, i want VD to do the decoding, but i need to supply custom decoder model because VD's internal IP could be put to work, but very slow (decoding P after B that depends on it works as redecoding all frames from I). And it would work well if internal decoder had stack of 2 decoded frames instead of 1 like now. Of cource it would be great to add mpeg-like IPB decoder model to VD too (in this model every sample depends on all previous samples from I; intermediate B samples should not be skipped as they could be references in AVC).
 
     Top
yawnmoth
Posted: Jul 16 2008, 04:05 AM


Member


Group: Members
Posts: 13
Member No.: 22025
Joined: 30-August 07



VirtualDub crashed when I was trying to edit a *.3gp file:

http://www.frostjedi.com/terra/virtualdub/...b/crashinfo.txt
 
     Top
ale5000
Posted: Dec 26 2008, 09:54 PM


Advanced Member


Group: Members
Posts: 1114
Member No.: 22180
Joined: 30-September 07



Has the crash fixed?

--------------------
New VirtualDub forum
VirtualDub AIO (All-in-One installer for VirtualDub and plugins)
Codec Toolbox RS (A tool to read/change merit of codecs and many other things)
Input plugins for VirtualDub / ACM codecs / VFW codecs
 
     Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
36 replies since Mar 2 2008, 01:48 AM Track this topic | Email this topic | Print this topic
Pages: (3) [1] 2 3 
<< Back to VirtualDub Filters and Filter Development