| Author |
Message |
Joe
Guest
|
Posted:
Sun Sep 26, 2004 12:15 am Post subject:
Custom Writer Sink - Looking for class implementing INSSBuff |
|
|
I'm trying to write a custom writer sink for writing to files. The reason
I'm trying to do this is to be able to write to successive files without
losing frames while not interrupting broadcasting. I'd been using the
encoder sdk, but this doesn't seem possible. This also doesn't seem to be
possible using the format sdk without using multiple writers, which is a
performance hit I don't want to take. So if you think I'm taking the wrong
path or doing unnecessary work, please let me know.
My problem:
I've written my file sink. I'm writing the buffers I get back from OnHeader
and OnDataUnit to a file. When I open the file using Windows Media Player, I
get an error saying something like the format and the file extension don't
match. I assume this means that the header is invalid. So either the format
sdk is screwed up(not likely), my class that implements INSSBuffer is screwed
up(probably), or my understanding is wrong. Would someone be willing to
provide me with a complete C++ sample of a class that implements INSSBuffer,
so I can try to plug that in? I'd really appreciate it.
|
|
| Back to top |
|
 |
Alessandro Angeli [MVP::D
Guest
|
Posted:
Sun Sep 26, 2004 3:01 am Post subject:
Re: Custom Writer Sink - Looking for class implementing INSS |
|
|
Joe wrote:
| Quote: | files. The reason I'm trying to do this is to be able to
write to successive files without losing frames while not
interrupting broadcasting. I'd been using the encoder
[...]
I've written my file sink. I'm writing the buffers I get
back from OnHeader and OnDataUnit to a file. When I open
the file using Windows Media Player, I get an error
saying something like the format and the file extension
don't match. I assume this means that the header is
[...] |
Correct me if I'm wrong, but you'll only receive the header
once so that the files following the first one you write
will be ASF segments but not valid ASF files in themselves.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net |
|
| Back to top |
|
 |
Joe
Guest
|
Posted:
Sun Sep 26, 2004 3:48 am Post subject:
Re: Custom Writer Sink - Looking for class implementing INSS |
|
|
Right now, I'm just trying to get my sink to act like the standard file sink,
writing the header and all the data with no file switching. What I intend to
do is keep a copy of the header buffer. So for each file, I will write the
same header(this makes sense to me). I will lose no frames by switching to a
new file only when I find a data unit buffer which is a cleanpoint.
Suggestions? Still looking for a class implementing INSSBuffer.
"Alessandro Angeli [MVP::DigitalMedia]" wrote:
| Quote: | Joe wrote:
files. The reason I'm trying to do this is to be able to
write to successive files without losing frames while not
interrupting broadcasting. I'd been using the encoder
[...]
I've written my file sink. I'm writing the buffers I get
back from OnHeader and OnDataUnit to a file. When I open
the file using Windows Media Player, I get an error
saying something like the format and the file extension
don't match. I assume this means that the header is
[...]
Correct me if I'm wrong, but you'll only receive the header
once so that the files following the first one you write
will be ASF segments but not valid ASF files in themselves.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net
|
|
|
| Back to top |
|
 |
Alessandro Angeli [MVP::D
Guest
|
Posted:
Sun Sep 26, 2004 1:10 pm Post subject:
Re: Custom Writer Sink - Looking for class implementing INSS |
|
|
Joe wrote:
| Quote: | Right now, I'm just trying to get my sink to act like the
standard file sink, writing the header and all the data
with no file switching. What I intend to do is keep a
copy of the header buffer. So for each file, I will
write the same header(this makes sense to me). I will
lose no frames by switching to a new file only when I
find a data unit buffer which is a cleanpoint.
|
This should work but it will not produce correct ASF files:
the header contains fields like the file size which will be
wrong (unless the broadcast flag is set, but the reader
should recover from errors of this kind) and only the last
file will have an index (the WMASFReader filter is picky
when it comes to non-indexed or truncated files).
| Quote: | Suggestions? Still looking for a class implementing
INSSBuffer.
|
You could post your code so that everyone in here can take a
look at it and correct you if you made mistakes.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net |
|
| Back to top |
|
 |
Joe
Guest
|
Posted:
Sun Sep 26, 2004 9:15 pm Post subject:
Re: Custom Writer Sink - Looking for class implementing INSS |
|
|
Yeah, I had thought of the header having to be different for each clip. What
all would I need to change in the header buffer that I get in the first
OnHeader and how would I do this. Also, I imagine I would have to modify
time stamps within the data units to push the first data unit to time 0, etc.
How would I go about doing this? Does this seem like the right approach or
is there an easier way to accomplish what I am trying to do. As far as
indexing goes, I intended to use a thread using the basicedit object of the
encoder sdk to take care of this. What do you mean when you say that the
reader is picky about non-indexed files? This just means it won't be able to
seek to points within the file, right?
I'll try to post what code I have tomorrow when I go in to work.
"Alessandro Angeli [MVP::DigitalMedia]" wrote:
| Quote: | Joe wrote:
Right now, I'm just trying to get my sink to act like the
standard file sink, writing the header and all the data
with no file switching. What I intend to do is keep a
copy of the header buffer. So for each file, I will
write the same header(this makes sense to me). I will
lose no frames by switching to a new file only when I
find a data unit buffer which is a cleanpoint.
This should work but it will not produce correct ASF files:
the header contains fields like the file size which will be
wrong (unless the broadcast flag is set, but the reader
should recover from errors of this kind) and only the last
file will have an index (the WMASFReader filter is picky
when it comes to non-indexed or truncated files).
Suggestions? Still looking for a class implementing
INSSBuffer.
You could post your code so that everyone in here can take a
look at it and correct you if you made mistakes.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net
|
|
|
| Back to top |
|
 |
Alessandro Angeli [MVP::D
Guest
|
Posted:
Sun Sep 26, 2004 11:14 pm Post subject:
Re: Custom Writer Sink - Looking for class implementing INSS |
|
|
Joe wrote:
| Quote: | Yeah, I had thought of the header having to be different
for each clip. What all would I need to change in the
header buffer that I get in the first OnHeader and how
would I do this. Also, I imagine I would have to modify
time stamps within the data units to push the first data
unit to time 0, etc. How would I go about doing this?
|
You can read all (or at least what you need for this
project) about the ASF format in the official specification:
http://www.microsoft.com/asf/
Parsing the header is quite easy (besides, the global
informations that would be invalid are not errors that would
make the reader reject the stream). Parsing the packets and
payloads of the data chunk is a nightmare.
| Quote: | Does this seem like the right approach or is there an
easier way to accomplish what I am trying to do.
|
The easier (and suggested) way is to use multiple writers.
However, as you said, using multiple writers is less
efficient.
| Quote: | As far
as indexing goes, I intended to use a thread using the
basicedit object of the encoder sdk to take care of this.
What do you mean when you say that the reader is picky
about non-indexed files? This just means it won't be
able to seek to points within the file, right?
|
The old WindowsMediaSourceFilter didn't use the index and
was very slow when seeking. The newer WMASFReader filter is
faster since it uses the index, but it doesn't seek at all
when the index is missing or corrupted.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net |
|
| Back to top |
|
 |
Jeremy Noring
Guest
|
Posted:
Mon Sep 27, 2004 9:20 pm Post subject:
Re: Custom Writer Sink - Looking for class implementing INSS |
|
|
"Joe" <Joe@discussions.microsoft.com> wrote in message
news:FC2336D5-0421-4900-9D55-922140E55AFA@microsoft.com...
| Quote: | I'm trying to write a custom writer sink for writing to files. The reason
I'm trying to do this is to be able to write to successive files without
losing frames while not interrupting broadcasting. I'd been using the
encoder sdk, but this doesn't seem possible. This also doesn't seem to be
possible using the format sdk without using multiple writers, which is a
performance hit I don't want to take. So if you think I'm taking the
wrong
path or doing unnecessary work, please let me know.
|
Personally, I'd implement an additional thread that takes in the samples and
writes them to some sort of FIFO queue. When you read the samples, they get
put at the back of the queue. Whatever writer instance is running on the
other side takes samples from the queue:
source -> collection thread -> QUEUE -> (reading thread if needed ) -> WM
Writer
....this way, when you tear down a writer because you need to write another
file, the queue just grows. When the next writer comes on, it'll start with
the next sample at the front of the queue. Of course, there are keyframe
issues with this approach as well as possible performance issues if your
writer instances can't process data fast enough out of the queue, but with a
bit of trickery you should be able to work around those issues. The STL has
a good queue already made that you can use pretty easily.
Don't forget to use a mutex. ;)
--
Where am I going?
And why am I in this handbasket? |
|
| Back to top |
|
 |
|
|
|
|