Log in

No account? Create an account
AAC/AACplus/AACplusV2 streaming on Linux/Windows: hz Icecast/Shoutcast source client for Linux/Win32 - watcher of the skies — LiveJournal

> Recent Entries
> Archive
> Friends
> Profile
> My Website

October 9th, 2007

Previous Entry Share Next Entry
02:51 pm - AAC/AACplus/AACplusV2 streaming on Linux/Windows: hz Icecast/Shoutcast source client for Linux/Win32

hz - AAC/AAC+/AAC+V2 & MP1/MP2/MP3 Icecast/Shoutcast source client for Linux/Win32

What's the point?
hz is a small, portable and fast MPEG1/2/2.5 LayerI/II/III and
AAC/AACplus/AACplusV2 Icecast/Shoutcast source client. It is written
to be nice and easy to use. It is also scriptable in some way, so
you can script your playlist handling with Lua scripting language.

What does "hz" mean?
hz stands for "a h.. ego znaet". If you can understand this, I probably
shouldn't explain more. hz is also very antisocial.

Yes, it doesn't like you by default. Neither your mom and girlfriend.
The only thing it likes to do is to hang out together with its rubber

What is supported?
AAC/AACplus/AACplusV2 and MPEG1/MPEG2/MPEG2.5 LayerI/II/III files
can be streamed to a Icecast or Shoutcast server. All possible bitrates are
fully supported, even VBR, but gosh, VBR seems not to be a grand idea for
an internet radio, I suggest that you use CBR. But whatever...

Tell me more.
Well, here are some key features:

 - AACx and MPx files support. All possible bitrates and their variations, including VBR.
 - Pretty precise timing. You shouldn't get any client buffering ever.
 - Icecast and Shoutcast servers are fully supported.
 - Metadata updating supported. The metadata is read from ID3v1 and ID3v2 tags.
   It can also be read from cuesheets (.cue file with the same name as audio file).
 - You can write your own script routine to get the next file name to stream.
 - You can write your own script routine to format metadata.

What about MP4, MP4A files support? And Ogg Vorbis?
MP4 is a container, not a compression format. If your MP4 file
contains AAC compressed sound that you want to stream, you
have to extract it from MP4 first. You can do it with MPEG4IP
(http://www.mpeg4ip.net), for example.
Ogg Vorbis is not (yet) supported.

Is there to be a live source support, for example /dev/dsp?
Never. hz has been written to be small and fast, so you can run it even on
an old Pentium-166 and stream say perfect quality AACplusV2 without
any significant performance impact.

What platforms are supported?
Linux and Win32 at the moment. Want more? Then, err.. port it.

How do I compile it?

How do I configure it?
Read conf/hz.ini.dist. Tune it for your needs.
Prepare your static playlist or write your dynamic playlist handling
function in Lua scripting language. Do not ever mix files that have
different format (MPx/AACx) or different samplerate in one playlist. No,
hz will successfully survive this as well as Icecast, but your player
definitely won't. You've been warned.

How do I run it?
hz <hz ini.file>, i.e.:
./hz /etc/hz/rock.ini

Can it be run as daemon on Linux?

As service on Windows?
No. You'll need to use one of that 3rd party software to hide the
hz console window or to install it as service if you have to.

I've found a bug!
Yes, there should be some. Report them, if you care. Oh, and be descriptive
as possible. More details increase the chances for it to be fixed.
Provide no details and your message won't be answered.


v0.6 - Oct 5 2007

- MPEG1/2/2.5 Layer I/II/III files now supported!
- Daemon mode added, works on Linux.
- Some really nasty bugs fixed.

v0.5 - Jan 2007

- Extended Lua scripting. Essential hz configuration parameters are now available to Lua scripts. Added hz_onmetadata script function to override metadata, hz_formatmetadata to format metadata.
- Cuesheet support added. If hz finds a .cue file with the same name as currently playing .aac file, then tags are read from that .cue file. It makes it possible to stream .aac files that were captured by StreamRipper with correct metadata!
- New ConnectionAttempts ini parameter. If server is down, hz will try to reconnect up to ConnectionAttempts times before giving up.
- Rewrote net functions, and now hostnames can also be specified in the host ini parameter.
- Some net error checking added, now hz will tell you if it is being rejected by a server.
- Some minor improvements.

v0.4 - Autumn 2006

- Added Lua scripting. Now playlist handling can be done via cool and convenient Lua scripts. Why not Python and Perl then? Well, I don't like Perl, I like Lua. And Python... Hmm, maybe in next version :)
- Shoutcast server is now supported too. With metadata!
- Added logging to an external file.
- Proper CTRL-C handling.
- Nice and groovy Makefile :)
- Some minor bugs are fixed.
- Cleaned up code a bit.

v0.3 - Autumn 2006

- Metadata updating added. Supported tags are ID3v1 and ID3v2. If a file contains both ID3v1 and ID3v2, then ID3v1 has the priority. Unicode tags in ID3v2 are not supported yet. In fact, my entire ID3v2 implementation is a quick and dirty hack, so watch out, there may be problems. Yes, I'm evil. Bugoga.
- Send-ahead buffer is now configurable. Default is 3 seconds.
- If AAC file check fails, it causes hz to skip the erroneous file instead of bailing out.
- Playlist is now checked for non-existing files.
- Even more precise timing. Tested on a wide range of AAC files, appears to work with all tested CBR and VBR files, with bitrates from 24 to 320kbps.
- Handling of broken AAC files improved. Now hz tries to resync accurately to the next valid AAC frame if an error in AAC file is encountered.
- No more pause between tracks, as this parameter didn't make much sense but could break the timing.
- Some other bugfixes.

v0.2 - Summer 2006

- Now compiles on Linux and Win32
- Practically balls-on accurate timing. No more listener disconnects even after a long period of time. (Still needs some testing).
- Playlist file gets reloaded with each track change. Allows to change playlist dynamically without stopping the client.
- Random play mode is added
- Pause between tracks is now configurable

v0.1 - Summer 2006

First version. Sucked too much.


some mirror http://william.shallum.net/miscellaneous/hz

hz is written in FreePascal (I prefer not to code in C), so you'll probably need the compiler. Get it from http://freepascal.org.

aacPlus v2 encoder for Linux (courtesy of Matteo Croce) :

(53 comments | Leave a comment)


Page 1 of 2
<<[1] [2] >>
Date:August 30th, 2006 04:20 pm (UTC)


Как на счет добавить live source? aac+ народ портировал под unix way уже !...
[User Picture]
Date:August 30th, 2006 08:56 pm (UTC)

Re: aac+

а для линуха есть рабочая либа или кушающая данные со stdin тулза кодера аас+ v2?
ссылкой не поделитесь?
вообще если таковое появится, то поддержку аас+ и без меня быстренько добавят авторы многочисленных сорс клиентов.
у меня линух в наличии только на роутере (пень200), который вряд ли потянет рил-тайм перекодирование в аас+, так что мне даже экспериментировать не на чем. да и лень :) мне лив сорс не нужен, у меня и так старый пенек aac+ из файлов прекрасно броадкастит %)
Date:September 1st, 2006 09:16 pm (UTC)

Bad syncword

I'm getting "Warning: Bad syncword at frame # 1" messages at end of AAC+v2 files (HE-AAC, 48kbps).
Also, when i'm listening that stream, Winamp gets buffering (buffer underrun)...
And atm there is no configuration for buffer sizes, i guess hz is sending too slow data to server or something?
Otherwise, excellent software that i need for my radio replays.
[User Picture]
Date:September 2nd, 2006 02:50 pm (UTC)

Re: Bad syncword

1. Bad syncword warnings perhaps caused by ID3v2 tags in your AAC files. hz tries to skip them at the beginning of a file, so you can safely ignore those warnings.

2. Player buffering is strange, it should never occur. Make sure that:

- You are using the latest hz version from the link above. I use to make fixes to the code without any announcement and version change :)
- The network link between hz and icecast as well as between icecast and a player is fast enough to provide the necessary bandwith for your stream.

How often do you get buffering? I use to stream 24kbps AAC+ v2 files for weeks (hz and icecast are running on the same machine) without any problem. Can you put your AAC files somewhere on the web? I'd like to take a look at them.
I added the new "buffersize" option in the most recent version of hz. Try to play with it, maybe it will solve your problem.
Date:November 25th, 2006 11:48 pm (UTC)
Link doesn't work :( Please fix it.
[User Picture]
Date:November 26th, 2006 02:26 am (UTC)
(no subject) - (Anonymous) - Expand
(no subject) - (Anonymous) - Expand
Date:December 31st, 2006 04:45 pm (UTC)


Is it possible to make a .deb package for Debian/Ubuntu users!? :D
[User Picture]
Date:January 3rd, 2007 05:39 am (UTC)

Re: Ubuntu

Unfortunately, I don't run Debian, I run RedHat based Linux. Although I've made a precompiled hz version, if your platform is x86, chances are you'll be able to run it :)
Download here.
Date:January 18th, 2007 07:28 pm (UTC)

input /dev/dsp

Is it possible to get input from /dev/dsp?
[User Picture]
Date:January 20th, 2007 10:26 pm (UTC)

Re: input /dev/dsp

Currently there are no plans for that.
Re: input /dev/dsp - (Anonymous) - Expand
Problem with HZ - (Anonymous) - Expand
Date:April 28th, 2007 12:42 am (UTC)

how to setup the script

how setup the script sory i dont understand very much but i want to test it ,can somebody tell me please the most important steps to get streaming ?
Date:June 5th, 2007 07:03 pm (UTC)

Hz doesnt run

HZ does not run. I compiled hz in the UBUNTU, using freepascal 2.0.4, but when I run it, it eats 100% of cpu, and he does not connect, nao makes nothing. log is this.

[05-06-2007 15:24:53] INFO ---------------------------
[05-06-2007 15:24:53] INFO hz v0.5 started

Sorry my english and thank you for this work =D
Date:August 4th, 2007 06:39 pm (UTC)

Re: Hz doesnt run

Same to me.....

Running - but no connection

Re: Hz doesnt run - (Anonymous) - Expand
Re: Hz doesnt run - (Anonymous) - Expand
Re: Hz doesnt run - (Anonymous) - Expand
Re: Hz doesnt run - (Anonymous) - Expand
Re: Hz doesnt run - (Anonymous) - Expand
Date:October 23rd, 2007 09:13 am (UTC)

Read from stdin

Hi, thanks for this great icecast source!
Just wanted to know if it's possible to add the ability to stream from stdin (like in ezcast) so that a preencoded stream can just be sent out with proper timing?
That would be great...

also, not that it seems to make much difference, but the 0.6 source archive causes tar to complain about a lone zero block:

01:42:35 (45.15 KB/s) - `hz-0.6.tar.gz' saved [43238/43238]

me@computer:~] tar -xzf hz-0.6.tar.gz
tar: A lone zero block at 401

dunno what that means, but nothing seems corrupt
[User Picture]
Date:October 25th, 2007 09:11 am (UTC)

Re: Read from stdin

I'll think about reading from stdin... Maybe in next version

And I targzip on Windows, prolly it's not liked much by their Unix counterparts :)
Re: Read from stdin - (Anonymous) - Expand
Date:November 22nd, 2007 06:22 pm (UTC)
чювак, здорова! прикольно... целую неделю рылся в инете.. искал такой софт.. и вот я его нашёл!! =) спасибо большое!
интересно какой софт юзают на http://di.fm ...
Date:November 25th, 2007 09:20 pm (UTC)

AAC+ Encoder

I'm the AAC+ encoder author, I noticed about this page just now.
This is the page of my encoder: http://teknoraver.campuslife.it/software/mp4tools/
The one you use is rally outdated.
Also, the encoder is known to produce corrupted files when compiled in 64 bit, so you're warned..
It's free, I hope it will be usefull to you

Best Regards,
Matteo Croce
Date:November 25th, 2007 10:17 pm (UTC)

AAC+ website

You have some adblock plugins that corrupts the page, and then firefox complains. In fact the original page have this code:

<a href="http://validator.w3.org/check?uri=http://teknoraver.campuslife.it/software/mp4tools/">
<img src="/valid-xhtml11.png" alt="Valid XHTML 1.1" height="31" width="88" />

which your plugin detects as an ad and changes it to:

<FONT size=1>[AD]</FONT>
<AD- alt="Valid XHTML 1.1" height="31" width="88" />

that is invalid XHTML and then firefox complains.

[User Picture]
Date:November 25th, 2007 10:37 pm (UTC)

Re: AAC+ website

oh stupid me!
i'll update my post about aac+ encoder to make it refer to your updated encoder as well.
Date:February 1st, 2008 10:54 am (UTC)

server down

anyone got a mirror of the source file? server seems to be down ;(
[User Picture]
Date:February 1st, 2008 01:11 pm (UTC)
Where hz can be downloaded now?
Please, don't answer HZ :))
[User Picture]
Date:February 2nd, 2008 05:21 pm (UTC)
i was performing a hardware upgrade...
Date:February 6th, 2008 04:01 pm (UTC)


Is there a way to add the functionality of
sending signals to the process like

kill -NEXT PID (for jump to the next track)
kill -LAST PID (for jump to the last track)
kill -RELOAD PID (for reload the playlist to make shure to now restart hz and continue playling)

add a cue like the ices tool for scripting things like current time of playling track ;)

This would be really cool ;)
Date:February 19th, 2008 01:04 pm (UTC)


I have problem with 0.5 and 0.6 version on debian 4.0 and Redhat enterprise 4 :(

program hang's after file read.

write(1, "hzPlaylistRandom: 0\n", 20hzPlaylistRandom: 0
) = 20
write(1, "hzPlaylistUpdatemetadata: 1\n", 28hzPlaylistUpdatemetadata: 1
) = 28
access("/tmp/np.tmp", F_OK) = 0
open("/tmp/np.tmp", O_RDONLY|O_LARGEFILE) = 4
read(4, "\0\0\0\0", 4) = 4
close(4) = 0
access("/home/qba/hz/playlist.txt", F_OK) = 0
open("/home/qba/hz/playlist.txt", O_RDONLY|O_LARGEFILE) = 4
read(4, "/home/qba/hz/tracks/mp3.aac\n/hom"..., 1024) = 140
close(4) = 0
access("/home/qba/hz/tracks/mp3.aac", F_OK) = 0
access("/home/qba/hz/tracks/mp3.aac", F_OK) = 0
access("/home/qba/hz/tracks/mp3.aac", F_OK) = 0
access("/home/qba/hz/tracks/mp3.aac", F_OK) = 0
access("/home/qba/hz/tracks/mp3.aac", F_OK) = 0
rt_sigaction(SIGINT, {0x80948d0, [], SA_RESTORER|SA_ONESHOT, 0x805a880}, {SIG_DFL}, 8) = 0
time(NULL) = 1203424988
gettimeofday({1203424988, 151648}, NULL) = 0
time([1203424988]) = 1203424988
open("/tmp/np.tmp", O_RDWR|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 4
write(4, "\0\0\0\0", 4) = 4
close(4) = 0
access("/tmp/np.tmp", F_OK) = 0
open("/tmp/np.tmp", O_RDONLY|O_LARGEFILE) = 4
read(4, "\0\0\0\0", 4) = 4
close(4) = 0
access("/home/qba/hz/playlist.txt", F_OK) = 0
open("/home/qba/hz/playlist.txt", O_RDONLY|O_LARGEFILE) = 4
read(4, "/home/qba/hz/tracks/mp3.aac\n/hom"..., 1024) = 140
close(4) = 0
access("/home/qba/hz/tracks/mp3.aac", F_OK) = 0
access("/home/qba/hz/tracks/mp3.aac", F_OK) = 0
access("/home/qba/hz/tracks/mp3.aac", F_OK) = 0
access("/home/qba/hz/tracks/mp3.aac", F_OK) = 0
access("/home/qba/hz/tracks/mp3.aac", F_OK) = 0

and nothing else :/ i convert mp3 to aac

and there no sockets / ports / connection from that program.


i must have compiled and installed mp4tools with aacplusenc and amrenc

after make of hz 0.6 i get
/bin/mkdir -p units/i386-linux
/usr/bin/ppc386 -Fu/usr/lib/fpc/2.2.0/units/i386-linux/rtl -FE. -FUunits/i386-linux -di386 hz.pas
Free Pascal Compiler version 2.2.0 [2007/08/31] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Linux for i386
Compiling hz.pas
Compiling daemon.pas
Compiling ctrlc.pas
Compiling log.pas
Compiling config.pas
daemon.pas(43,3) Note: Local variable "rl" not used
Compiling net.pas
net.pas(42,8) Warning: Symbol "Socket" is deprecated
net.pas(65,10) Warning: Symbol "Connect" is deprecated
net.pas(77,6) Warning: Symbol "Send" is deprecated
net.pas(94,15) Warning: Symbol "Recv" is deprecated
net.pas(109,3) Warning: Symbol "Shutdown" is deprecated
Compiling aac.pas
aac.pas(106,3) Note: Local variable "protection_absent" is assigned but never used
Compiling mpx.pas
mpx.pas(41,3) Note: Local variable "frame_length" not used
mpx.pas(340,3) Note: Local variable "padding" is assigned but never used
Compiling playlist.pas
Compiling script.pas
Compiling luapas.pas
Compiling timing.pas
Compiling metadata.pas
Compiling tags.pas
tags.pas(109,26) Warning: Arithmetic "+" on untyped pointer is unportable to {$T+}, suggest typecast
tags.pas(110,26) Warning: Arithmetic "+" on untyped pointer is unportable to {$T+}, suggest typecast
tags.pas(111,26) Warning: Arithmetic "+" on untyped pointer is unportable to {$T+}, suggest typecast
Compiling cuesheet.pas
Compiling b64.pas
Linking ./hz
3793 lines compiled, 0.4 sec
8 warning(s) issued
4 note(s) issued

can you about that logs help me with my problem ?
[User Picture]
Date:February 19th, 2008 01:59 pm (UTC)

Re: help

your playlist should contain at least _2 different_ entries
it won't work with just one entry or two identical entries.

old bug, but i'm too lazy to track it down.
err that's exactly why i hate opensource :)

> Go to Top