Knots

= About Knots = Knots is a feature rich GPLv2 Video Streaming Application for Linux, FreeBSD and OS X by Janne Mäkinen. It's written in Ruby and uses VLC 0.9.8+ to do the transcoding. Knots consists of a server and client. The server can be configured to stream video files (any format/codec supported by VLC), DVB-broadcasts, custom playlists or any other media to a Knots client on a 770/N8x0 or to any other computer, via the Knots' Web-frontend.

Non-tableteers can access the Knots Web-Frontend from any plattform / location (including Windows). Firefox & Adobe's Flash Plugin 10 are suggested and work best. Knots will automatically transcode all streams to flv, so they can be watched directly in the browser.

It is also possible to use the Knots client without the server as a thumb friendly fronted for MPlayer. The client will scan your tablet for media files, and you can create & save custom playlists.

= Features =
 * Fully thumb driven intuitive GUI for the Nokia 770 / N8x0 tablets
 * Gesture support (for CPU frequency scaling, information and volume)
 * Stream videos with on-the-fly transcoding to a Knots client or to a remote computer via the web-frontend. Seeking is supported when possible.
 * Watch Live TV (DVB) with VLC directly or make Knots act as a VDR Streaming Client.
 * Stream VDR Live-TV and recordings, browse the EPG & adjust VDR recording timers from the client
 * Playlist support (WorldTV99, etc.)
 * Automatic subtitle fetching for movies, provided by http://subtitlesource.org
 * Automatic thumbnails for local clips using ffmpeg
 * Integrated search function
 * Thumb friendly MPlayer frontend with playlist editing (in offline mode) and gestures support
 * Remote play feature for playing videos on the server and controlling it with the client (doesn't work on OS X yet)
 * Additional info for movies, provided by http://themoviedb.org

= Knots Server =

Install
Knots Server can be installed on any *nix based OS like Gnu/Linux, BSD & OSX.

Ubuntu
This instructions are for Ubuntu Intrepid Ibex (8.10). Other Debian derivates might use slightly different package names, but the general concept of the install is the same for all distros.


 * Enable the Multiverse & Universe software sources, and add the Medibuntu repository (for ffmpeg), reload your Package information and open a root terminal (sudo -s), to install the Ruby Dependencies:

apt-get install ruby1.8

apt-get install unzip
 * install unzip for automatic subtitle download feature

apt-get install vlc-nox vlc-data libvlccore0 libvlc2 ffmpeg
 * get vlc and a 'unrestricted' ffmpeg build

If you have Xorg running on your Knots-Server you can also install the packages "vlc" and "vlc-plugin-pulse" to get a GUI and PulseAudio Output (default ubunu Sound Server) for the vlc Player.

now install these unrestricted ffmpeg libaries (they will remove the restricted builds, if installed) apt-get install libavcodec-unstripped-51 libavdevice-unstripped-52 libavformat-unstripped-52 libavutil-unstripped-49 libpostproc-unstripped-51 libswscale-unstripped-0


 * download and install Knots - Server

Still in the root terminal change to the directory where you want to keep the Server Files (in this example I use /opt/kserver, change the path accordingly) and download & extract Knots - Server : cd /opt wget http://nakkiboso.com/knots/dl.php?file=server tar xvzf knots_server.tar.gz chown -R youruser:yourgroup /opt/kserver

That's it! knots is installed under /opt/kserver. You still need to configure it though!

Mac OSX
OS X 10.5 (Leopard) comes with Ruby 1.8. Knots should also work on 10.4 (Tiger) if you install the latest Ruby from http://rubyosx.rubyforge.org. Download the latest VLC from http://videolan.org and install it to /Applications. Download and extract the Knots server to a directory of your choice. You should also install ffmpegX from http://www.ffmpegx.com to /Applications to enable the screenshots support. Then proceed to setup.

First run
Knots server keeps its config at the folder ~/.config/knots. It is located under the home directory of the user who runs the following setup script, so do NOT run ./scripts/setup from a root terminal !

su yourusername cd /opt/kserver ./scripts/setup

Setup script will ask you various questions about your installation and has reasonable default settings. So if you are not sure, accept the default settings.


 * Server name : enter a custom name for your Knots server
 * Select interface to bind to: choose the network interface Knots binds to
 * Is all your media under one directory? : if you keep all you video files under one directory answer yes here.
 * Full path to your media files: Full path to your video archive (e.g. /media/video)
 * Do you have the program Video Disk Recorder (VDR) with streamdev-plugin installed? : Knots can interact nicely with VDR. If you have a VDR running somewhere on your local home network, or on the same computer as knots, answer yes here . The next VDR specific questions are about the used VDR osd, file system charset (different from UTF-8 in VDR releases < 1.7) and you can also supply a directory where your local VDR recordings are stored.

You can accept the default values for any other questions asked by the setup script.

After the script has gathered the necessary info it shows you the location of the generated config.yaml file:

Configuration saved to /home/yourusername/.config/knots/config.yaml. You can edit this file with a text editor for more advanced settings. You can now start the server with './knots start'

Advanced Server Configuration
If you want to customize your configuration file, open it in a text editor. The full path to the configuration file was printed to the terminal when you ran './scripts/setup'

Configuration Options

 * cache: You can enable cache for one (or more) of your categories. Keep in mind that it's not wise to cache the "Latest Videos" or VDR categories. 100 directory contents are kept in memory by default. You can force a rescan by using the search.


 * vlc: This section configures VLC. You can customize the port_range used by VLC. Keep in mind that you need to forward those ports from your router (or firewall) to the Knots server if you want the Web-frontend to be remotely accessible.


 * vdr: You can connect as many VDR's as you wish to Knots. All you need to do is to add another vdr2, vdr3 ... section to your config file and adjust the IP - addresses, streamdev_ports & svdrp_ports to fit your configuration.


 * server: you can configure some general Server settings in this section. If you need more verbose logging, you can change log_level to 2 to generate much more debug output in the logfile.


 * media: adjust the streamable Media Container Formats, and the full patch to your ffmpeg installation


 * transcoding: Knots ships with some transcoding presets (Video Dimensions, target Bitrate, Codec), that should be optimal for your tablet (you can switch the preset on the fly from the client). If you want to use the Web-Frontend remotely, you might want to set smaller dimensions in the flash profile (see example configuration below)


 * categories: this Section lists your categories. Use these names in the 'cache' section above.

Example Configuration
~/.config/knots/config.yaml for Knots-Server 0.4.2 with local VDR 1.6.0 (VDR using german charset ISO-8859-1): --- cache: - Video - Recordings vlc: startup_wait: 5 tmpdir: /var/tmp remote_play_options: freetype-effect: 2 vout: xvideo freetype-fontsize: 12 volume: 100 fullscreen: "" path: /usr/bin/vlc resume_rollback: 5 port_range: 4214-4244 vdr: vdr1: timer_interval_before: 0 address: 192.168.1.100 streamdev_port: 3000 svdrp_port: 2001 disable_epg: false timer_interval_after: 0 charset: iso-8859-1 force_charset_conversion: false disable_streamdev: false server: log_level: 2 name: panta-rhei remote_auth: false port: 4212 os: linux ip: 192.168.1.100 bind: eth0 vdr_charset: iso-8859-1 service_discovery: 4212 force_update: false auth_timeout: 60 local_auth: false log_append: false media: extensions: avi,mpg,mpeg,wmv,vdr,img,iso,mkv,vob,flv,mov,nuv,sh ffmpeg_path: /usr/bin/ffmpeg subtitles: sub,srt avfs_extensions: tgz,gz,bz2,zip,rar,arj,uha,lha transcoding: N800: audio_format: mpga resolution: 400x240 audio_channels: 2 audio_bitrate: 128 video_bitrate: 900 video_format: xvid High: audio_format: mp3 resolution: 608x256 audio_channels: 2 audio_bitrate: 128 video_bitrate: 900 video_format: xvid Flash: stream_extension: flv audio_format: mp3 resolution: 400x300 audio_rate: 44100 audio_channels: 2 audio_bitrate: 128 video_bitrate: 1000 mux: ffmpeg{mux=flv} video_format: FLV1 categories: TV: - vdr1 Recordings: - /media/recordings/vdr Video: - /media/video

You can also make client specific categories. You can find your clients' ids from the log file after you have connected to the server:

[2009-01-11-15:02:08] Request: /scanner/scan?client_id=a5f225de12c2f4795cef627ae115afad&locale=fi_FI&dir=/ from 192.168.0.101:64940

You can see your client's id in bold above. After you know the id, edit your config like this:

categories: a5f225de12c2f4795cef627ae115afad: TV: - vdr1 Recordings: - /media/recordings/vdr Video: - /media/video default: Video: - /media/video

In above example your client would see the TV, Recordings and Video categories and others would only see the Video category.

Extras
./scripts/install_worldtv99 ./knots restart
 * install Worldtv99

Scan your channels with dvb-scan using the vdr-format and then create an xml-playlist from it. (dvb-)scan -o vdr /usr/share/doc/dvb-utils/examples/scan/dvb-t/your_city > /tmp/channels.conf ./scripts/create_dvb_playlist /tmp/channels.conf ./knots restart
 * Live-TV (DVB) on Linux without VDR

You may need to edit ~/.config/knots/dvb.xml to make it work with your dvb-card.

If you for example have german umlauts that are iso-8859-1 in your filenames, libxml fails to parse them. You can convert them to utf-8 easily (but use at your own risk): ./scripts/fix_filenames
 * Converting non-utf-8 filenames

Flash-video (flv) requires mp3 -support. Make sure your ffmpeg is compiled with libmp3lame-support.
 * Sound in Flash-video

Shell scripts
Knots can run shell scripts on server. It's not really streaming related, but you can use it as a simple remote to start programs like X.org if you want to use the remote play feature. Just put your scripts to a directory, add it to some category and make sure the scripts have a .sh extension.

External programs
You can also define external programs to be run for certain filetypes. You can for example make Knots extract rar files or use Knots as a frontend for PyKaraoke. Adding this to your config would run PyKaraoke when .cdg file is selected:

external: cdg: python /usr/share/pykaraoke/pycdg.py -w 1920 -h 1080 --hide-mouse @FILE_SPACE_ESCAPED

If you want to terminate the process, just select the file again.

= Knots Client =

Ruby for Maemo OS2008
Add Repository: Catalogue Name: Ruby1.8 for Maemo Web address: http://stage.rubyx.co.uk/maemo/ Distribution: diablo Components: user Open a terminal, change to root & run: apt-get install libhildon1-ruby1.8 libgconf2-ruby1.8 libconic-ruby1.8 ruby1.8 libosso-ruby1.8 wget http://stage.rubyx.co.uk/projects/ruby-maemo/packages/maemo4/armel/libxml2-ruby1.8_0.9.7-0maemo1_armel.deb dpkg -i libxml2-ruby1.8_0.9.7-0maemo1_armel.deb

Knots Client
Open a terminal, change to root and run: wget http://nakkiboso.com/knots/dl.php?file=client dpkg -i knots_*.deb rm -rf *.deb

Client Settings
Menu Functions:
 * Server Scan: Automatically search and connect to a Knots server in the local LAN
 * Manual Connection: Specify the IP and port of a Knots server manually
 * Offline Mode: Disconnect from a Knots server, and display local media files
 * Preferences: See below
 * Refresh: Reload current directory or refresh list of local files
 * Go to Root: Return to your categories menu
 * Switch Transcoding Profile: Use the next predefined transcoding profile
 * Switch Theme: Switch theme (no restart required)
 * Remote Playback: Play a media file directly on the server
 * Check for Updates: Searches for an update from the server and transfers and installs it if found

Client Preferences:
 * Language: Set application language (no restart required)
 * Language for Subtitles: Set Language for DVD subtitles. Also searches for subtitles from subtitlesource.org with this language
 * Cache: Buffer in KB. 128 is a good starting point for a stable wlan
 * Local Directories: Knots scans these directories for media in offline mode
 * Join split Videos: Automatically join split videos (e.g. 001.vdr & 002.vdr)
 * Show Screenshots: Generate random screenshots of your videos. Requires ffmpeg on server.

Usage
The Knots Client is designed to be totally thumb controlled, and is also including gesture-support. Most of it's functions are very intuitive to use and self - explaining. The Start Screen gives an Overview of you defined Categories and has an entry to show unfinished Videos as well as the 10 latest additions to the Server.

If you want to watch a video on the way, you can right-click on any video file in your Archive and Knots will put the file on a Transcoding List. If you change to this transcoding list (with a click on the left Cursor key) and hit the start button knots will automatically encode the video in the currently selected profile and transfer the file to your tablet. The save-location can be customized in the Client Preferences Window.

If you configured Knots to connect to a VDR, you can browse the Channellist (you also get the EPG), Stream Live-TV, watch your Recordings and add, activate, deactivate or delete Timers for VDR. This makes knots the most feature complete "streaming client" for VDR.

ToDo: much more usage tips :)

Offline Mode
In Offline Mode, the Knots Client is a thumb friendly mplayer frontend (with gestures support to change the volume, seek,ect ). Once switched to Offline Mode, the Knots - Client will automatically scan your tablet for media files, and display them in the GUI. You can add them to a playlist, or start playing them directly, with a long (2 sec) push on the play button while the desired Clip is selected. A short push will start to play the first entry in the Playlist.

The inbulid Playlist support in Offline Mode can also be used to load a VDR - streamdev channels.m3u Channel list to watch Live TV via VDR & mencoder (Externremux.sh needed) if no Knots Server is available.

You can sort Playlist entries with the up / down buttons. A long push (2 seconds) puts the selected entry to the beginning / end of the Playlist, and a long push on the play button will start the selected entry directly.

VDR Streaming Client
Knots can be configured to act as a VDR Streaming Client. VDR is an excellent & widespread DVB PVR Software in the Linux world. If you have a VDR with streamdev-plugin running on the same PC as the knots server (or somewhere in your home LAN ) answer the VDR relevant questions in the setup Script. To configure multiple VDR's open the server's config.yaml and add a vdr2 stanza to the vdr category: Example configuration for Knots Server connecting to multiple VDR's (VDR 1.6 runs with german charset iso-8859-1) vdr: vdr1: timer_interval_before: 0 address: 192.168.1.100 streamdev_port: 3000 svdrp_port: 2001 disable_epg: false timer_interval_after: 0 charset: iso-8859-1 force_charset_conversion: false disable_streamdev: false vdr2: timer_interval_before: 0 address: 192.168.1.101 streamdev_port: 3000 svdrp_port: 2001 disable_epg: false timer_interval_after: 0 charset: iso-8859-1 force_charset_conversion: false disable_streamdev: false


 * timer interval_before: start timer x min earlier
 * timer interval_after: stop timer x min later
 * address: IP address of the VDR Server
 * streamdev_port: Port used by Streamdev Plugin, as configured in the VDR OSD setup Default is 3000
 * svdrp_port: SVDRP is a simple transfer/ communications protocol used by vdr. Default is 2001
 * charset: set your VDR charset (only VDR development version 1.7 supports UTF-8)
 * force_charset_conversion: it seems VDR may still be using iso-8859-1 characters when using utf-8 (a bug?). Use this, if you get xml-parsing errors with utf-8.
 * disable_epg: disable the Electronic Program Guide
 * disable_streamdev: disable the Live-TV streaming part

The Knots Client enables you to browse the channels of your VDR, start live streaming, browse the EPG and set Recording Timers for VDR, Timer Management (enable, disable or delete Timers) and you can also stream VDR Recordings to your Tablet. You can also transcode and transfer live-TV with the transcoder, but you have to manually press the remove (minus) button as the stream length is unknown. Knots will then transfer the partially encoded file to tablet.

The VDR Live-TV Features can also be used with the Web Frontend. Knots will automatically use the Flash profile to transcode VDR streams and you can watch them inside your browser (Adobe Flash Plugin and VLC with libmp3lame support needed). Knots will also display EPG information for VDR Recordings and a screenshot of the clip (at a random playtime).

Movie Information
The Knots Client fetches additional Information for a selected Video from the open movie Archive http://themoviedb.org. The Service includes a movie poster, a short Plot Summary and a brief List of Actors, as well as user ratings. TheMovieDB is also used by other media Centers like XBMC, and has a continuously growing database. If your video is not available already, contribute by adding info about it to their wiki.

To query TheMovieDB for a title, press the Information button. Knots will display the 'closest' result, similar to googles 'i'm feeling lucky'. You can also browse multiple results if the first was a false hit. To create a custom search query, press the Information button for 2 seconds, and enter your query. Knots tries to clean up the filename as much as possible, but it's impossible to do it perfectly. If the name of the video has several widely used words in it, themoviedb will return results for all movies that have those words in their names. In such case you can press the esc/back hardware key to cancel the list fetching and only display the results fetched before the cancellation.

= Web Frontend =

Point your desktop's browser to the Knots server address, followed by it's port: http:// :4212

Check the the logfile (/home/yourusername/.config/knots/knots.log) or start the server with ./knots stick if you don't know them. It will print out the address & port on the first line.

Knots will automatically use the bundled Flash-profile, if it's accessed via the Web-Frontend. You need a decent Browser, like Firefox and adobe's flash plugin installed, to use flash streaming. You might want to reduce the dimensions for the flash profile if you intend to stream video to remote computers accessing the web - frontend. The flash profile in the Example Configuration causes a upstream of 60 k/s.

You can also select a different transcoding-profile in the Web-Frontend. Knots will print out a link to a Playlist that can be opened with your favorite video player on the remote Computer (e.g. mplayer with the "High" Profile).

Encoding Profiles & the Language of the Web - Interface can be changed on the fly.

Authentication
If you plan to access the Web-Frontend from remote locations, it might be wise to secure your installation by enabling Remote-Authentication for Knots.

Edit the main server configuration file ~/.config/knots/config.yaml and set auth_remote: true in the server section.

./scripts/auth add username password ./scripts/auth delete username
 * To Add / Remove a user:

./scripts/auth add client_id ./scripts/auth delete client_id
 * Add a client to / Remove client from whitelist

NOTE: You can find the clients id's in the logfile (~/.config/knots/knots.log)

Firewall / Router Configuration
If you want to enable remote access to your knots Server, open & forward the ports 4212 - 4250 from your Router to the IP of the Knots Server. You can adjust the default port range for vlc in the server configuration file ~/.config/knots/config.yaml.

If you use a software firewall on your server (like ufw or iptables) you might also need to open the port-range from 4212 to 4250 for Knots. See UbuntuFirewall for more information how to configure the default firewall shipped with ubuntu (uwf).

= Update Knots =

Server: ./knots stop ./scripts/update ./knots start

Client:

Connect to your Knots-Server and select 'Check for updates' from the menu. Knots will transfer the updated Package to your tablet automatically and start the Application Manager to install it.

= Links =


 * Knots Homepage: http://nakkiboso.com/knots/
 * Ruby for Maemo: http://blog.rubyx.co.uk/
 * Mplayer for Maemo: http://mplayer.garage.maemo.org/
 * VLC Media Player: http://www.videolan.org/vlc/
 * Video Disk Recorder (VDR): http://www.cadsoft.de/vdr/
 * VDR streamdev-plugin: http://streamdev.vdr-developer.org/