Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th August 2008, 03:36   #1  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Any wma2wav CLI tool ???

Hi!

Is there any simple tool available which is able to take a .wma file as input and produce an uncompressed .wav as output? Please note that I need a CLI tool to integrate into my own GUI application. Therefore GUI tools or Winamp plugins are useless here. Also I don't want to use MPlayer.exe/MEncoder.exe or ffmpeg.exe, because they are far to bloated for this speicifc task. Furthermore note that I do not want to support DRM'd WMA files. Last but not least the CLI tool should not depend on any external DLL's. So far I found simple CLI decoders like that for all audio formats I had been looking for. But I failed to find anything suitable for damn WMA. There seems to be a CLI tool called "wma2wav" in existence, which basically is a stripped down version ffmpeg. Unfortunately all links I found were broken/down...

I'd need a Win32 binary that works like that:
wma2wav.exe --input "c:\Foobar.wma" --output "c:\decoded.wav"

Any advice would be welcome


[UPDATE]

I finally took the opportunity to create a simple "wma2wav" tool from the scratch:



The latest version of thr 'wma2wav' tool can be found in this post:
http://forum.doom9.org/showthread.ph...57#post1524857
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 15th January 2015 at 23:26.
LoRd_MuldeR is offline   Reply With Quote
Old 14th August 2008, 16:55   #2  |  Link
Sharktooth
Mr. Sandman
 
Sharktooth's Avatar
 
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
avisynth, directshowsource with avs2raw or bepipe....
Sharktooth is offline   Reply With Quote
Old 14th August 2008, 17:24   #3  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Dependency on Avisynth and on DirectShow filters -> Not suitable for my "self-contained" application

I'd need something in the tradition of OggDec or FAAD ...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 15th August 2008, 10:02   #4  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Think I found a solution

http://forum.doom9.org/showpost.php?...&postcount=148
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 15th August 2008, 20:42   #5  |  Link
Snowknight26
Registered User
 
Join Date: Aug 2007
Posts: 1,429
Does this include WMA Lossless?
Snowknight26 is offline   Reply With Quote
Old 15th July 2011, 22:08   #6  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Today I finally took the opportunity to create a simple wma2wav tool from the scratch.

It's based on the Windows Media Format SDK, so it's Windows only. Also currently only output to a "raw" PCM file and output to stdout is possible.

(I will add a Wave file writer soon).
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 16th July 2011 at 23:59.
LoRd_MuldeR is offline   Reply With Quote
Old 16th July 2011, 14:32   #7  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Some improvements, including proper command-line argument parser.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 16th July 2011 at 21:46.
LoRd_MuldeR is offline   Reply With Quote
Old 16th July 2011, 16:15   #8  |  Link
Midzuki
Unavailable
 
Midzuki's Avatar
 
Join Date: Mar 2009
Location: offline
Posts: 1,480
Many thanks , a.s.a.p. I will check whether it does respect the ASF audio timestamps or not
Midzuki is offline   Reply With Quote
Old 16th July 2011, 16:26   #9  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Midzuki View Post
Many thanks , a.s.a.p. I will check whether it does respect the ASF audio timestamps or not
It certainly does not. It just dumps the samples as they pop out of the WM reader

Since Wave Audio does not have any concept of time stamps (it's basically a simple header in front of "raw" PCM data stream), I don't know how this could be done.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 16th July 2011, 17:05   #10  |  Link
Midzuki
Unavailable
 
Midzuki's Avatar
 
Join Date: Mar 2009
Location: offline
Posts: 1,480
Would it be terribly difficult to "disk-write" the .WAV as the WMA stream is being "played back" ?
Just like Vorbis, Windows Media Audio does not use a constant frame duration
Midzuki is offline   Reply With Quote
Old 16th July 2011, 17:29   #11  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Midzuki View Post
Would it be terribly difficult to "disk-write" the .WAV as the WMA stream is being "played back" ?
Just like Vorbis, Windows Media Audio does not use a constant frame duration
Please explain to me!

What I get from the WM reader is "raw" PCM data. I also get one WAVEFORMATEX per stream (not per sample or frame!), telling me the sampling rate of the (whole?) stream.

Consequently I have to assume that the sampling rate is constant. Anything else wouldn't fit into a Wave file anyway, as the Wave header defines a single sampling rate.

Actually, unlike variable frame rate, where you simply vary the duration that you display the frame, I can hardly imagine how a variable sampling rate would be supposed to work

What I also do get from the WM reader is the timestamp and duration (in seconds) as well as the size (in bytes) of each "chunk" of audio data that I read from the ASF file.

Actually I don't use the timestamp and the duration (except for displaying the progress) at all. I simply write one sample after another into the file. All samples I got from WM reader.

The only thing that is (or might be) "variable" is the number of samples (bytes) that I receive per GetNextSample() call. And that's no problem at all...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 17th July 2011 at 00:09.
LoRd_MuldeR is offline   Reply With Quote
Old 16th July 2011, 17:58   #12  |  Link
Midzuki
Unavailable
 
Midzuki's Avatar
 
Join Date: Mar 2009
Location: offline
Posts: 1,480
Sorry, I'm unable to explain , I only know that, unless I used Winamp's Disk Writer plugin, or Avisynth's BassAudio, many WMA streams generated WAV files which were shorter than their sources The consequence: video and audio would go out of sync, of course
Midzuki is offline   Reply With Quote
Old 16th July 2011, 18:13   #13  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Midzuki View Post
Sorry, I'm unable to explain , I only know that, unless I used Winamp's Disk Writer plugin, or Avisynth's BassAudio, many WMA streams generated WAV files which were shorter than their sources The consequence: video and audio would go out of sync, of course
Well, the only situation that I can think of is:

If the timestamp of chunk N+1 does not exactly match the "end" (timestamp+duration) of chunk N, then there is either a "gap" or an "overlap".

An "overlap" doesn't make much sense to me! For a "gab" we might need to compensate with null samples, if such gaps really exists in real WMA/WMV files.

I re-uploaded today's version with a consistency check for timestamps, which will throw a warning if any non-negligible "gaps" or "overlaps" are found!

(for my test files this did never happen though)
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 16th July 2011 at 18:15.
LoRd_MuldeR is offline   Reply With Quote
Old 16th July 2011, 19:54   #14  |  Link
Midzuki
Unavailable
 
Midzuki's Avatar
 
Join Date: Mar 2009
Location: offline
Posts: 1,480
Hmmm, the new build of your wma2wav seems to be working as it should, at last
Code:
[C:\ASFBIN]
=>wma2wav -r -i zzoutput.wma -o zzzz9999.raw
wma2wav - Dump WMA/WMV files to Wave Audio [Jul 16 2011]
Copyright (c) 2011 LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.
Released under the terms of the GNU General Public License.

Input file: zzoutput.wma
Output file: zzzz9999.raw

Opening input file... OK
Analyzing input file... OK

[Audio Properties]
wFormatTag: 1
nChannels: 2
nSamplesPerSec: 48000
wBitsPerSample: 16
fDuration: 44:28.1
nMaxSampleSize: 17208

Opening output file... OK

Inconsistent timestamps: expected 41.002, but got 41.
The samples "overlap" for 0.002 seconds!

Inconsistent timestamps: expected 234.151, but got 235.
There is a "gap" of 0.849 seconds between the samples!

Inconsistent timestamps: expected 639.01, but got 639.
The samples "overlap" for 0.01 seconds!

Inconsistent timestamps: expected 713.965, but got 714.
There is a "gap" of 0.035 seconds between the samples!

Inconsistent timestamps: expected 1213.17, but got 1213.
The samples "overlap" for 0.167 seconds!

Inconsistent timestamps: expected 1817.54, but got 1818.
There is a "gap" of 0.457 seconds between the samples!

Inconsistent timestamps: expected 2191.16, but got 2192.
There is a "gap" of 0.838 seconds between the samples!

[100.0%] 44:27.8 of 44:27.8 completed, please wait...

All done.
and
Midzuki is offline   Reply With Quote
Old 16th July 2011, 20:05   #15  |  Link
b66pak
Registered User
 
b66pak's Avatar
 
Join Date: Aug 2008
Location: The Land Of Dracula (Romania - EU)
Posts: 934
@LoRd_MuldeR thanks a lot...this is a huge help...
_

L.E. i done a test and i got this:

Quote:
wma2wav -i FFXIII_Demo_Cutscene_720p_part4.wmv -r -o FFXIII_Demo_Cutscene_720p_part4.raw
wma2wav - Dump WMA/WMV files to Wave Audio [Jul 16 2011]
Copyright (c) 2011 LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.
Released under the terms of the GNU General Public License.

Input file: FFXIII_Demo_Cutscene_720p_part4.wmv
Output file: FFXIII_Demo_Cutscene_720p_part4.raw

Opening input file... OK
Analyzing input file... OK

[Audio Properties]
wFormatTag: 1
nChannels: 2
nSamplesPerSec: 44100
wBitsPerSample: 16
fDuration: 4:43.4
nMaxSampleSize: 17208

Opening output file... OK

Inconsistent timestamps: expected 0, but got 0.11.
There is a "gap" of 0.11 seconds between the samples!

Inconsistent timestamps: expected 30.035, but got 31.036.
There is a "gap" of 1.001 seconds between the samples!

[100.0%] 4:43.3 of 4:43.3 completed, please wait...

All done.
i had to fix the gaps myself or the output is oos...i was under the impression that this tool will do it by itself...
_
__________________
if you ask a question and somebody give you the correct answer don't forget to leave a "thank you" note...
Visit The Land Of Dracula (Romania - EU)!

Last edited by b66pak; 16th July 2011 at 20:41.
b66pak is offline   Reply With Quote
Old 16th July 2011, 21:03   #16  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by b66pak View Post
@LoRd_MuldeR thanks a lot...this is a huge help...
_

i had to fix the gaps myself or the output is oos...i was under the impression that this tool will do it by itself...
Nope, not yet. But now that I know they exist in some "real" files, I will implement the required padding.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 16th July 2011 at 23:35.
LoRd_MuldeR is offline   Reply With Quote
Old 16th July 2011, 21:44   #17  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Okay, here is a new version which will compensate "timestamp gaps" by padding with zero bytes. Also it supports Wave/RIFF output now.

By default it tries to avoid padding for small gaps, because I think padding is bad for audio-only files. But I also added a more "aggressive" compensation mode.

(BTW: If somebody could provide me with a sample file that contains "gaps" in the audio stream, this would be helpful for me).
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 17th July 2011 at 13:13.
LoRd_MuldeR is offline   Reply With Quote
Old 17th July 2011, 05:02   #18  |  Link
Midzuki
Unavailable
 
Midzuki's Avatar
 
Join Date: Mar 2009
Location: offline
Posts: 1,480
^ Mea culpa I had checked only that the resulting .WAV had the same length as the WMA source, not whether it remained "in synch" with the respective video track :uglylol: Anyway, the "aggressive padding" generates a .WAV longer than its WMA source, therefore...

Also, after running wma2wav (which IMHO really should be renamed to wmadec or somethig) , the CLI window does not execute .BAT files anymore

P.S.: As for the requested sample file, I've PM-ed you.
Midzuki is offline   Reply With Quote
Old 17th July 2011, 12:31   #19  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Midzuki View Post
^ Mea culpa I had checked only that the resulting .WAV had the same length as the WMA source, not whether it remained "in synch" with the respective video track :uglylol: Anyway, the "aggressive padding" generates a .WAV longer than its WMA source, therefore...
Well, as long as the "standard" compensation mode works okay. The "aggressive" mode is more an experimental mode.

I noticed that the timestamps/durations almost always do NOT match up exactly, which maybe is due to rounding errors or something like that.

Trying to compensate even for very small gaps (like aggressive mode does) will result in stuttering audio. Actually it gives an interesting kill-switch effect ^^

That is why the "standard" mode will ignore tiny gaps. And it's probably the best we can do...

Quote:
Originally Posted by Midzuki View Post
Also, after running wma2wav (which IMHO really should be renamed to wmadec or somethig) , the CLI window does not execute .BAT files anymore
Strange. I cannot reproduce.

Maybe it is because I set the console output CP to UTF-8, which is required to correctly print Unicode (UTF-8) characters.

Will add code to restore the "original" CP on program exit...

Quote:
Originally Posted by Midzuki View Post
P.S.: As for the requested sample file, I've PM-ed you.
Thanks

That file has some "overlaps", i.e. the timestamp of the "sample" (chunk of audio samples returned by the WM reader) is actually before the end (timestamp + duration) of the previous "sample". I don't think this should ever by the case (timestamps should be strictly none-decreasing!), so maybe the file is fishy...

Anyway, with the standard compensation mode, wma2wav will produce a Wave file of duration 44:27.959, the original WMA had a duration of 44:28.098 (according to Foobar 2000).

I think less than 0.2 seconds difference for a 45 minutes samples is pretty much okay
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 17th July 2011 at 12:40.
LoRd_MuldeR is offline   Reply With Quote
Old 17th July 2011, 13:12   #20  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Yet another update. Will now restore the previous codepage on exit. Also fixed a bug where padding zero bytes would also zero out the next samples!
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 17th July 2011 at 17:04.
LoRd_MuldeR is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:19.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.