|
|
I've come across a problem where the async reader doesn't deliver all frames from a file. The file has an audio stream compressed with MS Audio codec and a video stream compressed with our proprietary codec. Also, there is a script stream with a single dummy sample in it (this is a workaround for playing the file on Vista's WMP).
In the DMO codec I see that at first every frame from the file is decoded. Then, suddenly, only key frames are being passed to the codec. A bunch of IMediaObject::Discontinuity are called between the key frames.
This is very puzzling. The file looks fine in the ASF viewer.
I'd appreciate any ideas.
Thanks, ..a
|
|
sasha wrote:
[Quoted Text] > I've come across a problem where the async reader doesn't deliver all > frames from a file. The file has an audio stream compressed with MS
Media player shows the same behavior as the reader.
But the GraphEdit and Movie Maker play the file fine. I'm at a loss trying to explain this...
..a
|
|
On Fri, 11 May 2007 09:16:45 -0700, sasha wrote:
[Quoted Text] > sasha wrote: >> I've come across a problem where the async reader doesn't deliver all >> frames from a file. The file has an audio stream compressed with MS > > Media player shows the same behavior as the reader. > > But the GraphEdit and Movie Maker play the file fine. I'm at a loss > trying to explain this...
First off, it's not the Async source filter as that is a fairly dumb filter. It just reads data as told by the parser, but I doubt you are even using that filter with ASF unless you have also installed an ASF parser (such as Geraint's sample).
There are different source filters being used under WMP. When reading from ASF WMP has it's own internal source that wraps the Format SDK interfaces.
-- http://www.chrisnet.net/code.htm [MS MVP for DirectShow / MediaFoundation]
|
|
From: "Chris P."
[Quoted Text] > First off, it's not the Async source filter as that is a > fairly dumb filter. It just reads data as told by the > parser, but I doubt you are even using that filter with > ASF unless you have also installed an ASF parser (such as > Geraint's sample). > > There are different source filters being used under WMP. > When reading from ASF WMP has it's own internal source > that wraps the Format SDK interfaces.
I think by "async reader" the OP means WMF's WMReader, which is async, as opposed to WMF's WMSyncReader. The WMReader is what's used in the stock WMASFReader and WMP's internal source filter.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
Alessandro Angeli wrote:
[Quoted Text] > I think by "async reader" the OP means WMF's WMReader, which > is async, as opposed to WMF's WMSyncReader. The WMReader is
Correct. I should've specified that I use my own code which uses WMF SDK. Shouldn't be posting so early (late?) :)
|
|
[Quoted Text] > I'd appreciate any ideas. > > Thanks, > .a
Another interesting thing I see is that the file is missing key frames! I suspect that the mux is dropping my samples due to the bit rate being too high. I'll experiment with bumping it up in the profile.
..a
p.s. I suspect the same thing happens with the WMP/reader - it doesn't decode frames that push the bit rate over what's specified in the file.
p.p.s. I see this problem only for the very quickly changing video data, i.e. a lot of updates.
|
|
On Fri, 11 May 2007 13:43:19 -0700, sasha wrote:
[Quoted Text] > Another interesting thing I see is that the file is missing key frames! > I suspect that the mux is dropping my samples due to the bit rate being > too high. I'll experiment with bumping it up in the profile. > > .a > > p.s. I suspect the same thing happens with the WMP/reader - it doesn't > decode frames that push the bit rate over what's specified in the file. > > p.p.s. I see this problem only for the very quickly changing video data, > i.e. a lot of updates.
More commonly this occurs on the encoding side, not the playback side. The interesting thing here is that you are getting different results with different playback applications.
-- http://www.chrisnet.net/code.htm [MS MVP for DirectShow / MediaFoundation]
|
|
Chris P. wrote:
[Quoted Text] > > More commonly this occurs on the encoding side, not the playback side. The > interesting thing here is that you are getting different results with > different playback applications. >
Well, I think I found the problem. You are quite correct - it's on the recording side. I looked at the AdvancedWriter's statistics and noticed that a lot of samples were dropped. So I increased the bitrate in the profile and it did help things a lot - according to stats no samples are dropped.
This has a result of WMP playing smoothly and reader not skipping any frames. At the cost of a much larger file :(
Thanks for the conversation,
..a
|
|
From: "sasha"
[Quoted Text] > AdvancedWriter's statistics and noticed that a lot of > samples were dropped. So I increased the bitrate in the > profile and it did help things a lot - according to stats > no samples are dropped. > This has a result of WMP playing smoothly and reader not > skipping any frames. At the cost of a much larger file :(
If you are creating a CBR file, I think the behavior you are observing is the expected one: drop frames if the peak bitrate goes above the target bitrate and pad the stream when it goes below. Which means that, to avoid dropped frames, you have to set the target bitrate higher than the max peak bitrate but that will waste a lot of space if the max is much higher than the average. In this case, you may switch to VBR, which should prevent frame dropping and padding.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
Alessandro Angeli wrote:
[Quoted Text] > If you are creating a CBR file, I think the behavior you are > observing is the expected one: drop frames if the peak > bitrate goes above the target bitrate and pad the stream > when it goes below. Which means that, to avoid dropped > frames, you have to set the target bitrate higher than the > max peak bitrate but that will waste a lot of space if the > max is much higher than the average. In this case, you may > switch to VBR, which should prevent frame dropping and > padding. > >
Thanks Alessandro.
I agree this is the expected behavior. It's still a little bit surprising that the reader/WMP skips frames too. It seems that the writer is a bit more tolerant than the reader?
I am thinking about switching to VBR, but not certain if it's possible for a proprietary video codec.
Setting a higher CBR results in all samples written to the file (stats show that) and the size ballons to a very high one.
Cheers, ..a
|
|
From: "sasha"
[Quoted Text] > I agree this is the expected behavior. It's still a > little bit surprising that the reader/WMP skips frames > too. It seems that the writer is a bit more tolerant than > the reader?
I the writer skipped frames, it will mark mark the rest as a discontinuity until you write the next keyframe, an the reader will skip frames marked as a discontinuity.
> I am thinking about switching to VBR, but not certain if > it's possible for a proprietary video codec.
It should work.
> Setting a higher CBR results in all samples written to > the file (stats show that) and the size ballons to a very > high one.
As I said, if your peak bitrate it much higher than your average bitrate, CBR muxing causes a lot of padding to be inserted.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
Alessandro Angeli wrote:
[Quoted Text] > I the writer skipped frames, it will mark mark the rest as a > discontinuity until you write the next keyframe, an the > reader will skip frames marked as a discontinuity. >
Ah, that's exactly what I'm seeing. Can ASF viewer show where the frame is marked as a discontinuity?
> > As I said, if your peak bitrate it much higher than your > average bitrate, CBR muxing causes a lot of padding to be > inserted. >
OK, I will report my results :)
Thanks for the help,
..a
|
|
From: "sasha"
[Quoted Text] > Ah, that's exactly what I'm seeing. Can ASF viewer show > where the frame is marked as a discontinuity?
Yes, if you know what to look for: ASF has no discontinuity flag in the data or the index, so I think the reader marks a discontinuity when it finds and invalid (-1, 0xFFFFFFFF) offset in an index entry.
Notice that the old WMSourceFilter does not use the WMReader and does not rely on the index so it may not skip the discontinuity like the source filters based on the WMReader do.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
Alessandro Angeli wrote:
[Quoted Text] > Yes, if you know what to look for: ASF has no discontinuity > flag in the data or the index, so I think the reader marks a > discontinuity when it finds and invalid (-1, 0xFFFFFFFF) > offset in an index entry. >
Well, I looked, but couldn't find that. What is the index entry?
> Notice that the old WMSourceFilter does not use the WMReader > and does not rely on the index so it may not skip the > discontinuity like the source filters based on the WMReader > do.
And that probably explains the behavior I see with the Movie Maker.
|
|
From: "sasha"
[Quoted Text] > Well, I looked, but couldn't find that. What is the index > entry?
It's an entry in the file index :-)
Simple Index Object / Stream [I] / Seek Point K / Packet P / Payload L, look at the Object Offset value on the right.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
Alessandro Angeli wrote:
[Quoted Text] > From: "sasha" > >> Well, I looked, but couldn't find that. What is the index >> entry? > > It's an entry in the file index :-) > > Simple Index Object / Stream [I] / Seek Point K / Packet P / > Payload L, look at the Object Offset value on the right. > > > >
OK, got it. I didn't see the -1 entries so far, but there are quite a few with zero.
Thanks, Alex
|
|
sasha wrote:
[Quoted Text] > > OK, I will report my results :) >
It appears that I can successfully use VBR with my proprietary codec.
I'm having a bit of an issue with using VBR with the screen codec streams. Profile configuration really wants to see the bitrate in the VIDEINFOHEADER, so I'm not sure how to reconcile the do. Also, the MSS2 stream is not marked as VBR (in ASFView).
Below is the code for those who care.
//================================================================================================== void markAsVBR( C_ComPtr <IWMStreamConfig> &streamConfig ) {
C_ComPtr <IWMPropertyVault> propertyVault; HRESULT hr; if ( FAILED( hr = streamConfig->QueryInterface( IID_IWMPropertyVault, (void**)&propertyVault ) ) ) { LOG_ERR( _T( "Failed to get IWMPropertyVault %x" ), hr ); }
BOOL vbrEnabled( TRUE ); hr = propertyVault->SetProperty( g_wszVBREnabled, WMT_TYPE_BOOL, (BYTE*)&vbrEnabled, sizeof( vbrEnabled ) ); if ( FAILED( hr ) ) { LOG_ERR( TEXT( "%s - failed to set VBR type 0x%x" ), EC_FUNCTION, hr ); } DWORD zero( 0 ); hr = propertyVault->SetProperty( g_wszVBRBitrateMax, WMT_TYPE_DWORD, (BYTE*)&zero, sizeof( zero ) ); if ( FAILED( hr ) ) { LOG_ERR( TEXT( "%s - failed to set max rate 0x%x" ), EC_FUNCTION, hr ); } hr = propertyVault->SetProperty( g_wszVBRBufferWindowMax, WMT_TYPE_DWORD, (BYTE*)&zero, sizeof( zero ) ); if ( FAILED( hr ) ) { LOG_ERR( TEXT( "%s - failed to set buffer window 0x%x" ), EC_FUNCTION, hr ); } }
|
|
sasha wrote:
[Quoted Text] > I'm having a bit of an issue with using VBR with the screen codec > streams. Profile configuration really wants to see the bitrate in the
Well, calling markAsVBR in a correct place (before AddStream(), actually) solved that problem. I now can have VBR MSS2 streams.
..a
|
|
|