| Author |
Message |
raddog
Joined: 18 Dec 2005
Posts: 12
Location: Kansas City
|
Posted:
Sun Dec 18, 2005 5:15 pm Post subject:
Splitting an ASF into multiple ASFs |
|
|
My last of three questions.
Is there an easy way to split an ASF file? Supposing someone has been viewing it in WMP, and now they know they want to take a chunk out of the middle, is there a "standard" interface for what is in essence a "cut-n-paste" type function?
If not I'm thinking the way to do it is to figure out the beginning and ending marks (time offsets into the ASF clip). Then I'm thinking (hoping) there's a way to convert these time offsets into a file-seek location (starting time) and a number of bytes (ending_time - starting_time) in order to be able to:
// following is C++'ish psuedo code
CFile.Open("source.asf");
CFile.Seek(convert_time_to_lseekval(starting_time));
CFile.Create("target.asf");
//
// Wondering if I have to build the .ASF header or if there's a standard
// MFC (or other) module that does this for you?
//
CFile.WriteASFHeader("target.asf");
CFile.Read("source.asf", convert_time_to_cnt(ending - starting));
CFile.Write("target.asf", pDataJustRead);
CFile.Close("source.asf");
CFile.Close("target.asf");
Obviously not sytax valid, but hoping semantically it conveys the objective.
Can anyone help?
Thank you.
- john ferguson, kansas city, raddog58_AT_yahoo.com
|
|
| Back to top |
|
 |
Alessandro Angeli [MVP::D
Guest
|
Posted:
Sun Dec 18, 2005 9:30 pm Post subject:
Re: Splitting an ASF into multiple ASFs |
|
|
raddog wrote:
| Quote: | Is there an easy way to split an ASF file? Supposing
someone has been viewing it in WMP, and now they know
they want to take a chunk out of the middle, is there a
"standard" interface for what is in essence a
"cut-n-paste" type function?
[CUT] |
ASF files are structured files and quite complex so you can
not just read a piece from one and write it into another
(this is true for most chunked formats, like AVI or MOV).
The easiest way it to use the WMSyncReader object in the WMF
runtime (look at the WindowsMediaFormat SDK) to read the
data and the WMWriter to write a new ASF file.
When you create a new WMWriter, you need to configure it
with the profile you get from the WMSyncReader, then you
configure the WMSyncReader to deliver compressed samples on
every stream (IWMSyncReader::SetReadStreamSamples()) and set
the range you are intetested in (IWMSyncReader::SetRange())
and finally read from the reader
(IWMSyncReader::GetNextSample()) and write to the writer
(IWMWriterAdvanced::WriteStreamSample()). See the WMVCopy,
WMVAppend and WMSyncReader samples in the SDK.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net |
|
| Back to top |
|
 |
Alessandro Angeli [MVP::D
Guest
|
Posted:
Sun Dec 18, 2005 9:30 pm Post subject:
Re: Splitting an ASF into multiple ASFs |
|
|
raddog wrote:
| Quote: | Is there an easy way to split an ASF file? Supposing
someone has been viewing it in WMP, and now they know
they want to take a chunk out of the middle, is there a
"standard" interface for what is in essence a
"cut-n-paste" type function?
[CUT] |
ASF files are structured files and quite complex so you can
not just read a piece from one and write it into another
(this is true for most chunked formats, like AVI or MOV).
The easiest way it to use the WMSyncReader object in the WMF
runtime (look at the WindowsMediaFormat SDK) to read the
data and the WMWriter to write a new ASF file.
When you create a new WMWriter, you need to configure it
with the profile you get from the WMSyncReader, then you
configure the WMSyncReader to deliver compressed samples on
every stream (IWMSyncReader::SetReadStreamSamples()) and set
the range you are intetested in (IWMSyncReader::SetRange())
and finally read from the reader
(IWMSyncReader::GetNextSample()) and write to the writer
(IWMWriterAdvanced::WriteStreamSample()). See the WMVCopy,
WMVAppend and WMSyncReader samples in the SDK.
--
// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net
|
|
| Back to top |
|
 |
raddog
Joined: 18 Dec 2005
Posts: 12
Location: Kansas City
|
Posted:
Sun Dec 18, 2005 10:32 pm Post subject:
re:Splitting an ASF into multiple ASFs |
|
|
I glanced at the SDK documents you suggested, and this is going to help a LOT.
Thank you VERY much, Alessandro!
- john |
|
| Back to top |
|
 |
|
|
|
|