Month: November 2012

Run MPD as Windows service

We can use a Windows tool to install MusicPlayerDaemon as a Windows Service. The tool to use is the Service Controller Query Tool, which is part of the Microsoft Windows 2000 Resource Kit. Windows 2000 is long past its due date and the Resource Kit is no longer available for download on the Microsoft website. But it is still available on other websites. Download sc.zip and extract it to a folder where you can find it later, for example C:\Apps\. Execute the following command to install MPD as a service, the following assumptions are made:

  1. sc.exe has been extract to C:\Apps
  2. MPD has been extracted to C:\Apps\mpd
  3. mpd.conf is located at C:\Apps\mpd\mpd.conf sc create musicpd binpath= “C:\Apps\mpd\mpd.exe C:\Apps\mpd\mpd.conf” displayname=”Music Player Daemon”

This has been tested and confirmed to work on Windows 7. To test and configure the newly created service, run the command services.msc. A list of running services should be displayed, as in the image below (screenshot is in Dutch). From here you can start and stop the service. In the properties of the service it is possible to configure the service to be auto-starting, so that it starts when Windows starts:

This post is based on a post in the MPD Mailing List.

Leave a Comment

Decrease video file size using ffmpeg

Ever felt the need to decrease a video in size? Here’s how, using ffmpeg.
This blog post is explained using Windows, but can be performed under any OS using ffmpeg. First, download ffmpeg using the ffmpeg website. For Windows I’d recommend download the static 32 or 64 bit downloaded, depending on your computer.
Store it somewhere on your computer where you will be able to find it, let’s store it at C:\Apps\ffmpeg.

Getting information on the file

In this example we will use a video file and attempt to decrease its size by lowering the bitrate. All other parameters (resolution, audio, video format) we’ll leave intact.
First, we get the information on the video file using ffprobe. Open a command windows, cd to the folder where the video resides and execute the following command, where video.mpg is the filename of the video:

C:\apps\ffmpeg\bin\ffprobe video.mpg
C:\Apps\ffmpeg\bin\ffmpeg -i video.mpg -s 720x576 -b:v 2000k -vcodec mpeg2video -acodec copy video_smaller.mpg

Leave a Comment

Installing MPD on Windows

MPD is a music player which works a bit different than other music players. It uses a server – client architecture; which means that the music is played as an application, while another application (the client) is used to control the playback. This allows a user to use different clients to play the same music.
An example setup would be to have the server component running on a computer near your stereo, hooked up to it via a jack cable, and you can install a client on your phone, tablet or a different computer to control the playback. The only requirement is for the computers to be able to reach each other via the local network.

Downloading and installing the server component

  • Download the latest zip file from the mpd homepage, select the win32 binary for the windows version
  • Open the downloaded file and extract its contents to your desired location. I used the folder C:\apps\mpd, so that is what I will be using in this post. Simply replace this path with the path you extraced mpd to. I do not recommend installing in your Program Files folder, because you might run into windows UAC (User Account Control) problems.

Configuration

MPD requires a configuration file to work. Create the file mpd.conf in the folder where the mpd file was extracted. The following attributes are important:

  • music_directory: The location where your mp3 files can be found. All backslashes in paths must be replaced by forward slashes
  • log_file: File where mpd output is logged
  • db_file: MPD stores the meta information retrieved from the MP3 files in this database file
  • playlist_directory: folder where the playlists are stored by MPD
music_directory "C:/Music"
log_file "C:/Apps/mpd/mpd.log"
db_file "C:/Apps/mpd/mpd.db"
playlist_directory "C:/Apps/mpd/playlists"
audio_output {
    type "winmm"
    name "Speakers"
    device "Speakers (Realtek High Definition Audio)"
}
audio_output {
    type "httpd"
    name "My HTTP Stream"
    encoder "vorbis" # optional, vorbis or lame
    port "8000"
    # quality "5.0" # do not define if bitrate is defined
    bitrate "128" # do not define if quality is defined
    format "44100:16:1"
}

In order to make this configuration work do the following:

  1. Create the playlist folder (C:\Apps\mpd\playlists)
  2. Create the empty file C:\Apps\mpd\mpd.db, on the first start mpd will display an error, and replace the contents with the collected metadata
  3. Create the file C:\Apps\mpd\mpd.log and save it as an empty file

Starting MPD

You can start the MPD server with the following command:

C:\Apps\mpd\>mpd mpd.conf

This will start the mpd server and allow you to connect to it using an MPD client. In order to connect to the server in a client you need the IP address and the portnumber. The IP address is the local address on your computer running the server, the port number is the default, number 6600. If you have trouble accessing the server, check that the port is not blocked by your local firewall.
My preferred client is MPDroid, an excellent app for Android phones, which allows me the access my music from anywhere in my house.
In the example configuration file the MPD music is also accessible via http audio stream on port 8000; the url is http://[ip adress]:8000/stream.m3u.

Next steps

MPD is now running in a console window. Running it as a service on your windows PC is explained in this post.

Leave a Comment