Account Options

  1. Sign in
Google Groups Home
« Groups Home
About obscurity of some extended attributes structures descriptions given in WMFSDK
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 38 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vincas Stepankevicius  
View profile  
 More options Oct 4 2004, 6:52 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt>
Date: Mon, 4 Oct 2004 13:52:03 +0300
Local: Mon, Oct 4 2004 6:52 am
Subject: About obscurity of some extended attributes structures descriptions given in WMFSDK
Hi all,
I wonder if anybody have tried to read/write WM file (wma,mp3)  extended
attributes, such as WM/Lyrics_Synchronised or WM/Picture.
 I tried to do this in VB.NET (many thanks to Robert Smith for help), using
WMFSDKWrapper.dll from WMFSDK, and had no problems, reading/writing simple
WM attributes of type
WMT_ATTR_DATATYPE.WMT_TYPE_STRING, .WMT_TYPE_DWORD, .WMT_TYPE_QWORD or
.WMT_TYPE_BOOL.
I'm even able to read all extended attributes, and show their values
(embeded pictures, lyrics and synchronised lyrics).
But here I'm running into problems, raised by some mismatch between
structures described in WMFSDK and those returned by
IWMHeaderInfo3.GetAttributeByIndexEx
Let's take attribute "WM/Lyrics_Synchronised".
WMFSDK states that it's data array must contain such structure:

typedef struct _WMSynchronisedLyrics{
  BYTE    bTimeStampFormat;           '(1 or 2 - depending on TimeStamp
format used)
  BYTE    bContentType;                   '(0-8 - ContentType dependant)
  LPWSTR  pwszContentDescriptor; '(Pointer to a wide-character
null-terminated string containing data from the encoding application;
app-dependant(?))
  DWORD   dwLyricsLen;                 '(length of the lyrics data in bytes)
  BYTE*   pbLyrics;                           '(Pointer to a BYTE array
containing the lyrics)

} WM_SYNCHRONISED_LYRICS;

, while dataArray, returned by GetAttributeByIndexEx, contains this (by zero
based position in array):

0(1-st byte) - bTimeStampFormat (2 in my case, meaning absolute time of the
lyric in milliseconds)
1(2-nd byte) - bContentType (1 in my case, meaning song lyrics)
2(3-6 bytes) - dword, with unknown meaning, let's name it dwA
6(7-10 bytes) - dword, corresponding to dwLyricsLen
10(11-14 bytes) - dword, with unknown meaning, let's name it dwB
14 - wide-character null-terminated string, containing description of
Synched lyrics attribute,
and after it goes pbLyrics-BYTE array containing the lyrics data (timestamps
& their strings) itself.

The most interesting thing is that dwords dwA and dwB are getting new,
absolutely random at first sight values on every GetAttributeByIndexEx call
on the same mp3 file!
I say 'at first sight' because it's not absolutely true: difference dwB-dwA
always remains the same for a file (but may differ for various files)!
It would be only interesting, if I only wanted to read synched lyrics - I
can simply ignore those dwA & dwB; and I do so, reading
WM/Lyrics_Synchronised.
But when you decide to update this attribute, you'll see, that you can't
ignore them, leaving zeroed or even filling with some values according this
strange 'constant difference' rule!
That's why I ask for your help. Of course, it would be ideal to see some VB
code sample for updating (IWMHeaderInfo3.ModifyAttribute), but I thank in
advance for any ideas in vb.net or c#:)

Here is the same mismatch for WM/Picture for example:
description in WMFSDK:

typedef struct _WMPicture{
LPWSTR pwszMIMEType;
BYTE bPictureType;
LPWSTR pwszDescription;
DWORD dwDataLen;
BYTE* pbData;

} WM_PICTURE;

structure, returned by GetAttributeByIndexEx:
0: - dword with unknown meaning
4: - bPictureType (Picture type (author, album cover, group etc.) )
5: - dword with unknown meaning
9: - dwDataLen 'Picture size
13: -dword with unknown meaning
17: -pwszMIMEType (wide-character null-terminated string, usualy
"image/jpeg" in my case)
then goes pwszDescription,
then goes pbData

So, please, all guru,  - help me to find a vb.net solution for WM attributes
update!

tia,
Vincas Stepankevicius

P.S.
One idea came into my head while writing these notes  - most likely those
'mystic' dwords means nothing else but addresses of pointers to data?
Nonetheless I don't know what can I do with such 'knowledge', - so you
remain my last hope :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
smith  
View profile  
 More options Oct 4 2004, 6:29 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "smith" <rcsTAKE...@smithvoiceTAKEOUT.com>
Date: Mon, 04 Oct 2004 22:29:54 GMT
Local: Mon, Oct 4 2004 6:29 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
I'll give a $10 prize (ten dollars US) via Paypal to anyone who can answer
this adequately using VB.Net or C# (without using UnSafe).

Code to this group please, Vincas being the judge of the result.

Robert Smith
Kirkland, WA
http://www.smithvoice.com

"Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt> wrote in message

news:e6pTwAgqEHA.3520@TK2MSFTNGP11.phx.gbl...

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
smith  
View profile  
 More options Oct 4 2004, 6:33 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "smith" <rcsTAKE...@smithvoiceTAKEOUT.com>
Date: Mon, 04 Oct 2004 22:33:46 GMT
Local: Mon, Oct 4 2004 6:33 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
Make that "The First Person"  with the adequate answer, judged by Vincas :)

-smith

"smith" <rcsTAKE...@smithvoiceTAKEOUT.com> wrote in message

news:C9k8d.2693$UP1.2180@newsread1.news.pas.earthlink.net...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Neil Smith [MVP Digital Media]  
View profile  
 More options Oct 5 2004, 4:18 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Neil Smith [MVP Digital Media]" <n...@nospam.com>
Date: Tue, 05 Oct 2004 08:18:31 GMT
Local: Tues, Oct 5 2004 4:18 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
I'll consider giving $10 to anybody who understands and can explain to
me a word he's on about Hehe. ;-)))

Cheers - Neil

On Mon, 04 Oct 2004 22:29:54 GMT, "smith"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincas Stepankevicius  
View profile  
 More options Oct 5 2004, 6:03 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt>
Date: Tue, 5 Oct 2004 13:03:44 +0300
Local: Tues, Oct 5 2004 6:03 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
Hi, Neil,

Of cource, you may be not so savy as I expected, but please be at least more
well-meant :)
If my terrible English (I'm Lithanian) is the only reason you can't answer
this question - it's not so bad ;)

In the simplest terms I just asked for a sample of VB.NET code for updating
extended binary attributes of media files...
If  you are still hazy about purport of my request - please, be so kind -
don't waste your time :)

thanks,
Vincas

"Neil Smith [MVP Digital Media]" <n...@nospam.com> wrote in message
news:o2n4m056oedn8v3bsausukcbtdngg5pe75@4ax.com...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alessandro Angeli [MVP::DigitalMedia]  
View profile  
 More options Oct 5 2004, 6:09 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net>
Date: Tue, 5 Oct 2004 12:09:20 +0200
Local: Tues, Oct 5 2004 6:09 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK

"Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt> wrote:
> One idea came into my head while writing these notes  - most likely
> those 'mystic' dwords means nothing else but addresses of pointers to
> data? Nonetheless I don't know what can I do with such 'knowledge', -
> so you remain my last hope :)

They are pointers and the difference is a constant because the data is
always laid out in th same way. You can access the data they point to using
methods in System.Runtime.InteropServices.Marshal like PtrToStringUni(),
PtrToStructure(), ReadByte(), ReadInt16()... I think there may be a more
elegant solution, but this should do.

--

Alessandro Angeli

MVP::DigitalMedia

a dot angeli at biosys dot net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alessandro Angeli [MVP::DigitalMedia]  
View profile  
 More options Oct 5 2004, 6:11 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net>
Date: Tue, 5 Oct 2004 12:11:46 +0200
Local: Tues, Oct 5 2004 6:11 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
"Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net> wrote:

> They are pointers and the difference is a constant because the data is
> always laid out in th same way. You can access the data they point to
> using methods in System.Runtime.InteropServices.Marshal like
> PtrToStringUni(), PtrToStructure(), ReadByte(), ReadInt16()... I
> think there may be a more elegant solution, but this should do.

Of course, you can use the inverse methods to write new data and get
pointers to your own structs and strings.

--

Alessandro Angeli

MVP::DigitalMedia

a dot angeli at biosys dot net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Iain  
View profile  
 More options Oct 5 2004, 6:55 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: Iain <Iain...@idcl.co.uk>
Date: Tue, 5 Oct 2004 11:55:17 +0100
Local: Tues, Oct 5 2004 6:55 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
Allesandro's comments are pertinent here.

It is also useful to know that the Lyrics fields are derived from the MP3
definitions for such things which are documented in in various places.

I haven't looked at them in detail so the following may be wrong.

It *may* be that in practive the pointers are effectively offsets into the
datablock so if you tread them as longs and see what is at point it may be
pertinent.

Iain


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincas Stepankevicius  
View profile  
 More options Oct 5 2004, 6:58 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt>
Date: Tue, 5 Oct 2004 13:58:06 +0300
Local: Tues, Oct 5 2004 6:58 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
Thanx, Alessandro,
I'll try it, while one question still remains: which structure must be used
in IWMHeaderInfo3.ModifyAttribute - structure described in SDK or one
returned by GetAttributeByIndexEx? They are different even considering your
explanation.

I'm glad to see that my English is not such bad as to be absolutely unclear
:)

thanks,
Vincas

Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net> wrote in
message news:O%23pfpNsqEHA.1644@tk2msftngp13.phx.gbl...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alessandro Angeli [MVP::DigitalMedia]  
View profile  
 More options Oct 5 2004, 7:23 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net>
Date: Tue, 5 Oct 2004 13:23:17 +0200
Local: Tues, Oct 5 2004 7:23 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK

"Iain" <Iain...@idcl.co.uk> wrote:
> It *may* be that in practive the pointers are effectively offsets
> into the datablock so if you tread them as longs and see what is at
> point it may be pertinent.

I don't think so. The data block where the pointers are embedded is
marshalled as an unstructured byte array so they are not interpreted and
hence must retain their valued in unmanaged code, where they are actual
pointers and not offsets.

--

Alessandro Angeli

MVP::DigitalMedia

a dot angeli at biosys dot net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alessandro Angeli [MVP::DigitalMedia]  
View profile  
 More options Oct 5 2004, 7:45 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net>
Date: Tue, 5 Oct 2004 13:45:14 +0200
Local: Tues, Oct 5 2004 7:45 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK

"Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt> wrote:
> I'll try it, while one question still remains: which structure must
> be used in IWMHeaderInfo3.ModifyAttribute - structure described in
> SDK or one returned by GetAttributeByIndexEx? They are different even
> considering your explanation.

Both methods do not use any specific structure so I'll assume you mean the
structure relative to a specific attribute type, for example
WM_SYNCHRONISED_LYRICS, in which case the structure is exactly the same for
both methods, no difference. Or maybe you meant that the buffer you get
filled by GetAttributeByIndexEx() doesn't look like a WM_SYNCHRONISED_LYRICS
structure? Since I do not have any file that contains such an attribute, I
can not investigate it (do you have a sample you can share?).

--

Alessandro Angeli

MVP::DigitalMedia

a dot angeli at biosys dot net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Iain  
View profile  
 More options Oct 5 2004, 9:05 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: Iain <Iain...@idcl.co.uk>
Date: Tue, 5 Oct 2004 14:05:46 +0100
Local: Tues, Oct 5 2004 9:05 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
On Tue, 5 Oct 2004 13:23:17 +0200, Alessandro Angeli [MVP::DigitalMedia]
wrote:

> "Iain" <Iain...@idcl.co.uk> wrote:

>> It *may* be that in practive the pointers are effectively offsets
>> into the datablock so if you tread them as longs and see what is at
>> point it may be pertinent.

> I don't think so. The data block where the pointers are embedded is
> marshalled as an unstructured byte array so they are not interpreted and
> hence must retain their valued in unmanaged code, where they are actual
> pointers and not offsets.

Yeah, but are you saying that the the WMFSDK knows enough to fix up these
pointers as it loads the header metadata block into memory?

It would seem a remarkably clever thing to get it to do.

Mind you if you actually have tried this then I'll shut up, since I have
not.  I found out just enough to reckon it wasn't worth my while!  A little
knowledge and all that!

Iain


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincas Stepankevicius  
View profile  
 More options Oct 5 2004, 10:39 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt>
Date: Tue, 5 Oct 2004 17:39:31 +0300
Local: Tues, Oct 5 2004 10:39 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
"Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net> wrote in
message news:e9wRWDtqEHA.3288@TK2MSFTNGP12.phx.gbl...
......
> Both methods do not use any specific structure so I'll assume you mean the
> structure relative to a specific attribute type, for example
> WM_SYNCHRONISED_LYRICS, in which case the structure is exactly the same
for
> both methods, no difference. Or maybe you meant that the buffer you get
> filled by GetAttributeByIndexEx() doesn't look like a

WM_SYNCHRONISED_LYRICS

> structure?

I agree, that *internal* structure is the same for both methods, but as you
can see from declaration of WMFSDKWrapper.dll method GetAttributeByIndexEx
inVB:
--
Public Overridable Function GetAttributeByIndexEx(ByVal wStreamNum As
System.UInt16,
    ByVal wIndex As System.UInt16, ByVal pwszName As String, ByRef pwNameLen
As System.UInt16,
    ByRef pType As WMFSDKWrapper.WMT_ATTR_DATATYPE, ByRef pwLangIndex As
System.UInt16, ByVal pValue() As Byte,
    ByRef pdwDataLength As System.UInt32) As System.UInt32
--
, this method returns attribute data as  as byte array pValue, and I must
decide myself what structure has data in it, depending on attr name &
type...

>Since I do not have any file that contains such an attribute, I
> can not investigate it (do you have a sample you can share?).

Of cource I have, but I don't know if this group is a proper place for
messages with audio files attached :)
If You have Windows Media player (ver 9 or 10), you can simply create such
attributes on any mp3 or wma file you have.
If not - let me know, and I'll try to make a mp3 or wma file as little as
possible, with required attributes set.
If I got it right, I can use your spelled e-mail for sending such file.
Correct me if I'm wrong.

Vincas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Neil Smith [MVP Digital Media]  
View profile  
 More options Oct 5 2004, 10:45 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Neil Smith [MVP Digital Media]" <n...@nospam.com>
Date: Tue, 05 Oct 2004 14:45:42 GMT
Local: Tues, Oct 5 2004 10:45 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
Not at all - I wasn't being nasty ! I'm a web developer so I'm more or
less clueless about what you were asking ;-)

The English was fine, it was the technical content that baffled me.
It's probably a very interesting question, I just have no idea what
the answer will be !

Hopefully, Alessandro has a few clues he can offer.

Kind regards - Neil

On Tue, 5 Oct 2004 13:03:44 +0300, "Vincas Stepankevicius"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincas Stepankevicius  
View profile  
 More options Oct 5 2004, 10:45 am
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt>
Date: Tue, 5 Oct 2004 17:45:35 +0300
Local: Tues, Oct 5 2004 10:45 am
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
"Iain" <Iain...@idcl.co.uk> wrote in message

news:1mtsmts0y3d6g.33wz6q9lcbg1.dlg@40tude.net...

> Allesandro's comments are pertinent here.

> It is also useful to know that the Lyrics fields are derived from the MP3
> definitions for such things which are documented in in various places.

> I haven't looked at them in detail so the following may be wrong.

> It *may* be that in practive the pointers are effectively offsets into the
> datablock so if you tread them as longs and see what is at point it may be
> pertinent.

> Iain

Alessandro is positively right: they are *not* offsets in datablock for one
simple reason: their values are just too big for that :)

Vincas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
smith  
View profile  
 More options Oct 5 2004, 12:05 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "smith" <rcsTAKE...@smithvoiceTAKEOUT.com>
Date: Tue, 05 Oct 2004 16:05:55 GMT
Local: Tues, Oct 5 2004 12:05 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
Would it be any eaiser for folks to get rolling if instead of
Lyrics_Synchronised we tried the struct for the image first?

As to the conversion of the sdk C# sample structures to VB.net a starter can
be had from http://www.smithvoice.com/downs/svmedia.zip

For a quick look at what that does without a download, just click on
http://www.smithvoice.com/wmediaattrib.htm

This does the simple types (Strings, Bools, Ints) and the question, as I
understand it, is how to use Set or Add/Modify on the binary types.

-smith


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincas Stepankevicius  
View profile  
 More options Oct 5 2004, 1:24 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt>
Date: Tue, 5 Oct 2004 20:24:51 +0300
Local: Tues, Oct 5 2004 1:24 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
Nice to see you here again, Robert :)

There is absolutely no difference, which attr you'll examine. Having
clearness with pic, you'll be done with slyr too and vice versa.

After visiting your site site thought that it would be nice to show you a
screenshot of my app I've told you about.
Unfortunately, I haven't any public website to publish it for you, so if you
agree, I'll send it by e-mail.
What app's doing:
    Attribute view/update (view - all attrs/update- all but those we are
talking about);
    displays all embeded pics, lyrics, synched lyrics;
    scrolls synched lyrics in a karaoke-style while playing;
    plus has a very simple & handy lyrics synchronising  interface (in
contrast to awkward WMP10 one)
So, the only thing I'm missing - binary attrs update (with simple ones, as
I've told, I had no problems).
That's why I'm here :)

Vincas

"smith" <rcsTAKE...@smithvoiceTAKEOUT.com> wrote in message

news:DDz8d.3343$UP1.809@newsread1.news.pas.earthlink.net...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alessandro Angeli [MVP::DigitalMedia]  
View profile  
 More options Oct 5 2004, 3:19 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net>
Date: Tue, 5 Oct 2004 21:19:42 +0200
Local: Tues, Oct 5 2004 3:19 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK

Vincas Stepankevicius wrote:
> If I got it right, I can use your spelled e-mail for
> sending such file. Correct me if I'm wrong.

Here is the sample code that dumps the synchronized lyrics:

---------------------------------------------
using System;
using System.IO;
using System.Runtime.InteropServices;
using WMFSDKWrapper;

public class slyr
{
 public static void Main(string[] args)
 {
  try {
   IWMMetadataEditor pEditor = null;

   WMFSDKFunctions.WMCreateEditor(out pEditor);
   pEditor.Open("x.wma");

   IWMHeaderInfo3 pHeader = (IWMHeaderInfo3)pEditor;

   ushort wStream = 0;
   ushort wCount = 0;

   pHeader.GetAttributeCountEx(wStream,out wCount);

   for(ushort i = 0; i < wCount; i++) {
    WMT_ATTR_DATATYPE dtType = 0;
    ushort  wLang = 0;
    string  szName = null;
    byte[]  pbData = null;
    ushort  wName = 0;
    uint   dwData = 0;

    pHeader.GetAttributeByIndexEx(wStream,i,szName,ref
wName,out dtType,out wLang,pbData,ref dwData);
    szName = new string('\0',wName-1);
    pbData = new byte[dwData];
    pHeader.GetAttributeByIndexEx(wStream,i,szName,ref
wName,out dtType,out wLang,pbData,ref dwData);

    if(szName != "WM/Lyrics_Synchronised") continue;

    MemoryStream pStream = new MemoryStream(pbData);
    BinaryReader pReader = new BinaryReader(pStream);

    uint ptr, end; string line; uint time;
    Console.WriteLine(">>> bTimeStampFormat .... =
{0}",pReader.ReadByte());
    Console.WriteLine(">>> bContentType ........ =
{0}",pReader.ReadByte());
    Console.WriteLine(">>> pwszContentDescriptor =
L\"{0}\"",Marshal.PtrToStringUni(new
IntPtr(pReader.ReadUInt32())));
    Console.WriteLine(">>> dwLyricsLen ......... = {0}",end
= pReader.ReadUInt32());
    Console.WriteLine(">>> pbLyrics ............ =
${0:X8}",ptr = pReader.ReadUInt32());
    for(end += ptr; ptr < end; ) {
     line = Marshal.PtrToStringUni(new IntPtr(ptr)); ptr +=
(uint)(2*(1+line.Length));
     time = (uint)Marshal.ReadInt32(new IntPtr(ptr)); ptr +=
4;
     Console.WriteLine(">>>\t [{0:d}:{1:d2}:{2:d2}.{3:d3}]
L\"{4}\"",time/1000/60/60,(time/1000/60)%60,(time/1000)%60,t
ime%1000,line);
    }
   }
  } catch(COMException ex) {
   Console.WriteLine(ex.ToString());
  }
 }

}

---------------------------------------------

--

// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincas Stepankevicius  
View profile  
 More options Oct 5 2004, 3:30 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt>
Date: Tue, 5 Oct 2004 22:30:50 +0300
Local: Tues, Oct 5 2004 3:30 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
I'm glad about my English and Alessandro - I consider you being indebted him
$10 ;-)
Vincas
"Neil Smith [MVP Digital Media]" <n...@nospam.com> wrote in message
news:cmd5m0hm53phv4m3510fk57s4rk05n5qjf@4ax.com...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincas Stepankevicius  
View profile  
 More options Oct 5 2004, 3:50 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt>
Date: Tue, 5 Oct 2004 22:50:23 +0300
Local: Tues, Oct 5 2004 3:50 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
Thanx, Alessandro, I must rush now to study & test your sample (regrettably,
I need some time to convert it Into VB)
But now I see some "light in the end of tunnel" :)
I'll be back tomorow,

regards,
Vincas

"Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net> wrote in
message news:u$$JOBxqEHA.3504@TK2MSFTNGP14.phx.gbl...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
smith  
View profile  
 More options Oct 5 2004, 3:54 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "smith" <rcsTAKE...@smithvoiceTAKEOUT.com>
Date: Tue, 05 Oct 2004 19:54:53 GMT
Local: Tues, Oct 5 2004 3:54 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
That's a nice looking app, Vincas.

I threw together a fast page so others can see what you're up to and maybe
get more help on this.

Here's your page:

http://www.smithvoice.com/vincas.htm

You'll have to let me know when you get a winner here, I don't have the
resources to make a redundant thread on my sitelett and keeping it to this
group will help far more people.

-robert smith
kirkland, wa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alessandro Angeli [MVP::DigitalMedia]  
View profile  
 More options Oct 5 2004, 4:27 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net>
Date: Tue, 5 Oct 2004 22:27:26 +0200
Local: Tues, Oct 5 2004 4:27 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK

Vincas Stepankevicius wrote:
> Thanx, Alessandro, I must rush now to study & test your
> sample (regrettably, I need some time to convert it Into
> VB)
> But now I see some "light in the end of tunnel" :)
> I'll be back tomorow,

Unfortunately, I don't enough VB.NET to provide samples in
that language in a short time. Here you are a better sample
which also supports WM/Picture:

--------------------------------------
using System;
using System.IO;
using System.Runtime.InteropServices;
using WMFSDKWrapper;

public class slyr
{
 public static void Main(string[] args)
 {
  try {
   IWMMetadataEditor pEditor = null;

   WMFSDKFunctions.WMCreateEditor(out pEditor);
   pEditor.Open("x.wma");

   IWMHeaderInfo3 pHeader = (IWMHeaderInfo3)pEditor;

   ushort wStream = 0;
   ushort wCount = 0;

   pHeader.GetAttributeCountEx(wStream,out wCount);

   for(ushort i = 0; i < wCount; i++) {
    WMT_ATTR_DATATYPE dtType = 0;
    ushort  wLang = 0;
    string  szName = null;
    byte[]  pbData = null;
    ushort  wName = 0;
    uint   dwData = 0;

    pHeader.GetAttributeByIndexEx(wStream,i,szName,ref
wName,out dtType,out wLang,pbData,ref dwData);
    szName = new string('\0',wName-1);
    pbData = new byte[dwData];
    pHeader.GetAttributeByIndexEx(wStream,i,szName,ref
wName,out dtType,out wLang,pbData,ref dwData);

    Console.WriteLine(">>> \"{0}\"",szName);

    MemoryStream pStream = new MemoryStream(pbData);
    BinaryReader pReader = new BinaryReader(pStream);
    uint ptr, end;

    if(szName == "WM/Lyrics_Synchronised") {
     Console.WriteLine(">>>\t bTimeStampFormat .... =
{0}",pReader.ReadByte());
     Console.WriteLine(">>>\t bContentType ........ =
{0}",pReader.ReadByte());
     Console.WriteLine(">>>\t pwszContentDescriptor =
L\"{0}\"",Marshal.PtrToStringUni(new
IntPtr(pReader.ReadUInt32())));
     Console.WriteLine(">>>\t dwLyricsLen ......... =
{0}",end = pReader.ReadUInt32());
     Console.WriteLine(">>>\t pbLyrics ............ =
${0:X8}",ptr = pReader.ReadUInt32());

     for(end += ptr; ptr < end; ) {
      string line; uint time;
      line = Marshal.PtrToStringUni(new IntPtr(ptr)); ptr +=
(uint)(2*(1+line.Length));
      time = (uint)Marshal.ReadInt32(new IntPtr(ptr)); ptr
+= 4;
      Console.WriteLine(">>>\t\t
[{0:d}:{1:d2}:{2:d2}.{3:d3}]
L\"{4}\"",time/1000/60/60,(time/1000/60)%60,(time/1000)%60,t
ime%1000,line);
     }
    } else if(szName == "WM/Picture") {
     Console.WriteLine(">>>\t pwszMIMEType .. =
{0}",Marshal.PtrToStringUni(new
IntPtr(pReader.ReadUInt32())));
     Console.WriteLine(">>>\t bPictureType .. =
{0}",pReader.ReadByte());
     Console.WriteLine(">>>\t pwszDescription =
L\"{0}\"",Marshal.PtrToStringUni(new
IntPtr(pReader.ReadUInt32())));
     Console.WriteLine(">>>\t dwDataLen ..... = {0}",end =
pReader.ReadUInt32());
     Console.WriteLine(">>>\t pbData ........ = ${0:X8}",ptr
= pReader.ReadUInt32());

     FileStream pFile = new
FileStream("picture"+i+".img",FileMode.OpenOrCreate,FileAcce
ss.Write);
     IntPtr bas = new IntPtr(ptr);
     for(int off = 0; off < end; off++)
pFile.WriteByte(Marshal.ReadByte(bas,off));
    }
   }
  } catch(COMException ex) {
   Console.WriteLine(ex.ToString());
  }
 }

}

--------------------------------------

--

// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Neil Smith [MVP Digital Media]  
View profile  
 More options Oct 5 2004, 4:50 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Neil Smith [MVP Digital Media]" <n...@nospam.com>
Date: Tue, 05 Oct 2004 20:50:44 GMT
Local: Tues, Oct 5 2004 4:50 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
On Tue, 5 Oct 2004 22:30:50 +0300, "Vincas Stepankevicius"

<vstepankevic...@vilnius.vmi.lt> wrote:
>I'm glad about my English and Alessandro - I consider you being indebted him
>$10 ;-)

Damn !

>Vincas

Oh, yeah I see what you;re doing from the screenshots now. I had some
similar problems to do an 'Export to Excel' (which was only partly
tested) but I did it in javascript. It mostly falls down on the XML
processing, and really needs to go client side :

http://www.windowsmediatv.com/wmprocessor/medialibrarytoexcel.html

The problem is, AFAIK the Excel ("Office Web Components") you can put
into a web page, don't read *native* OfficeXML format files :-P

Anyway - cheers & good luck with this.

========================================================
CaptionKit http://www.captionkit.com : Produce subtitled
internet media, transcripts and searchable video. Supports
Real Player, Quicktime and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alessandro Angeli [MVP::DigitalMedia]  
View profile  
 More options Oct 5 2004, 5:32 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net>
Date: Tue, 5 Oct 2004 23:32:26 +0200
Local: Tues, Oct 5 2004 5:32 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK

Vincas Stepankevicius wrote:
> (regrettably, I need some time to convert it Into VB)

Well, I couldn't sleep, so here you are the VB.NET version:

----------vb.bat------------
csc /debug+ /target:module WMFSDKFunctions.cs
vbc /debug+ /addmodule:WMFSDKFunctions.netmodule *.vb
----------------------------
----------slyr.vb-----------
IMPORTS System
IMPORTS System.IO
IMPORTS System.Runtime.InteropServices
IMPORTS WMFSDKWrapper

PUBLIC MODULE slyr
 SUB Main()
  TRY
   DIM pEditor AS IWMMetadataEditor

   WMFSDKFunctions.WMCreateEditor(pEditor)
   pEditor.Open("x.wma")

   DIM pHeader AS IWMHeaderInfo3 = pEditor

   DIM wStream AS UInt16
   DIM wCount AS UInt16

   pHeader.GetAttributeCountEx(wStream,wCount)

   FOR i AS Integer = 0 TO Convert.ToInt32(wCount)-1
    DIM dtType AS WMT_ATTR_DATATYPE
    DIM wLang AS UInt16
    DIM szName AS String = Nothing
    DIM pbData() AS Byte = Nothing
    DIM wName AS UInt16
    DIM dwData AS UInt32

pHeader.GetAttributeByIndexEx(wStream,Convert.ToUInt16(i),sz
Name,wName,dtType,wLang,pbData,dwData)
    szName = NEW String("0",Convert.ToInt32(wName)-1)
    REDIM pbData(Convert.ToInt32(dwData))

pHeader.GetAttributeByIndexEx(wStream,Convert.ToUInt16(i),sz
Name,wName,dtType,wLang,pbData,dwData)

    Console.WriteLine(">>> ""{0}""",szName)

    DIM pStream AS MemoryStream = NEW MemoryStream(pbData)
    DIM pReader AS BinaryReader = NEW BinaryReader(pStream)
    DIM _ptr, _end AS Integer

    IF szName = "WM/Lyrics_Synchronised" THEN
     Console.WriteLine(">>>   bTimeStampFormat .... =
{0}",pReader.ReadByte())
     Console.WriteLine(">>>   bContentType ........ =
{0}",pReader.ReadByte())
     Console.WriteLine(">>>   pwszContentDescriptor =
L""{0}""",Marshal.PtrToStringUni(NEW
IntPtr(pReader.ReadInt32())))
     _end = pReader.ReadInt32()
     Console.WriteLine(">>>   dwLyricsLen ......... =
{0}",_end)
     _ptr = pReader.ReadInt32()
     Console.WriteLine(">>>   pbLyrics ............ =
${0:X8}",_ptr)

     _end = _end + _ptr
     WHILE _ptr < _end
      DIM line AS String
      DIM time As Integer

      line = Marshal.PtrToStringUni(NEW IntPtr(_ptr))
       _ptr = _ptr + 2 * (1 + line.Length)
      time = Marshal.ReadInt32(NEW IntPtr(_ptr))
       _ptr = _ptr + 4
      Console.WriteLine(">>>
[{0:d}:{1:d2}:{2:d2}.{3:d3}]
L""{4}""",time\1000\60\60,(time\1000\60) mod 60,(time\1000)
mod 60,time mod 1000,line)
     END WHILE
    ELSE IF szName = "WM/Picture" THEN
     Console.WriteLine(">>>   pwszMIMEType .. =
{0}",Marshal.PtrToStringUni(NEW
IntPtr(pReader.ReadInt32())))
     Console.WriteLine(">>>   bPictureType .. =
{0}",pReader.ReadByte())
     Console.WriteLine(">>>   pwszDescription =
L""{0}""",Marshal.PtrToStringUni(NEW
IntPtr(pReader.ReadInt32())))
     _end = pReader.ReadInt32()
     Console.WriteLine(">>>   dwDataLen ..... = {0}",_end)
     _ptr = pReader.ReadInt32()
     Console.WriteLine(">>>   pbData ........ =
${0:X8}",_ptr)

     DIM pFile AS FileStream = NEW FileStream("picture" & i
& ".jpg",FileMode.OpenOrCreate,FileAccess.Write)
     DIM bas AS IntPtr = NEW IntPtr(_ptr)
     FOR off AS Integer = 0 TO _end-1
      pFile.WriteByte(Marshal.ReadByte(bas,off))
     NEXT off
    END IF
   NEXT i
  CATCH ex AS COMException
   Console.WriteLine(ex.ToString())
  END TRY
 END SUB
END MODULE

--------------------------------

--

// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincas Stepankevicius  
View profile  
 More options Oct 5 2004, 6:27 pm
Newsgroups: microsoft.public.windowsmedia.sdk
From: "Vincas Stepankevicius" <vstepankevic...@vilnius.vmi.lt>
Date: Wed, 6 Oct 2004 01:27:59 +0300
Local: Tues, Oct 5 2004 6:27 pm
Subject: Re: About obscurity of some extended attributes structures descriptions given in WMFSDK
Yep!
Great job, Alessandro!
Now it's too late(1:30)  to check your code but it seems for me that you
have allredy $20 from two Smith's - 10 from Robert + 10 from Neil ;)
Forgive me, that I cant propose you nothing else but my respect and
gratitude :)
I see now how my problems can be solved but I'd appreciate if you find time
to make an experiment with updating attrs ;)

My best regards,
Vincas

"Alessandro Angeli [MVP::DigitalMedia]" <nob...@nowhere.in.the.net> wrote in
message news:OSqWTLyqEHA.3428@TK2MSFTNGP11.phx.gbl...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 38   Newer >
« Back to Discussions « Newer topic     Older topic »