hartvig.de

linux power!


N800streamer

with 2 comments

ffmpeg/mplayer script for streaming media files from a remote server to the Nokia N800 handheld device.

Download

Download N800streamer here

Requirements

  • A Nokia N800 and a Linux box running a ssh server, all connected through a (local) network.
  • xterm, python, netcat and mplayer install on the N800. You can find most of it here.
  • ffmpeg and netcat installed on the server. Use “sudo apt-get install ffmpeg netcat” or similar.
  • ssh keys exchanged between the N800 and the server. Exchange the keys by:
    • Replacing n800ip by the ip adress of the N800, run the following command on the server
    • ssh-keygen -t dsa ; ssh-copy-id -i ~/.ssh/id_dsa.pub user@n800ip
    • Replacing serveruser by your username on the linux server and serverip by it’s ip adress, run the following command on the N800
    • ssh-keygen -t dsa ; ssh-copy-id -i ~/.ssh/id_dsa.pub serveruser@serverip

Installation instructions

1) Download the script and put it in the /home/user folder on the N800.
2) Set the options for the server ip and login information in the “Settings” section.
3) Run the script by typing “python n800streamer.py” (without the quotes) in xterm on the N800.

Problems

If you encounter any problems or discover bugs, please drop me an email at hartvig [dot] mic [dot] dtu [dot] dk.

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Credits

Originally, the idea for N800streamer came from MoRpHeUz’s Blog.

Code


# Import libs
import os
import socket
import fcntl
import struct


# settings:
serverip='10.0.0.1'
serveruser='user'
serverdir='/home/user'
n800user='user'


# Declare functions
# Remove duplicates from list
def f5(seq, idfun=None):
# order preserving
if idfun is None:
def idfun(x): return x
seen = {}
result = []
for item in seq:
marker = idfun(item)
# in old Python versions:
# if seen.has_key(marker)
# but in new ones:
if marker in seen: continue
seen[marker] = 1
result.append(item)
return result


# Get local ip address for device wlan0
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])


# Get local ip address
n800ip=get_ip_address('wlan0')
# Get directory listing from remote server
serverdircommand1="ssh "+serveruser+"@"+serverip+" 'find $PWD -iname '*.avi' > filelist1.txt'"
serverdircommand2="ssh "+serveruser+"@"+serverip+" 'scp filelist1.txt "+n800user+"@"+n800ip+":.'"
os.system(serverdircommand1)
os.system(serverdircommand2)


# Load file list
f = open("filelist1.txt","rd")
f = [line[:-1] for line in f]
filelist = []
for line in f:
filelist.append(line)
# Sort files
filelist=f5(filelist)

# Main loop
# Clear screen
os.system('clear')


# Print welcome screen
print("============================================")
print("=============== NOKIA N800 Streamer =============")
print("=============== K. Hartvig Jensen 2007 ============")
print("============================================")

# List files

numfiles=len(filelist)
i=1
for file in filelist:


#if file[len(file)-4]==’.':
temp = `i`+” “+file
print(temp)
i = i+1


# Prompt user for file to watch
print("===================================================")
prompttext="Enter the number of the file you which to watch (1-"+`numfiles`+"): "
filenum=input(prompttext)
print(filenum)


# Mplayer and ffmpeg command lines
runmplayer="nc -l -p 5000 | mplayer -v 0 - &"
runffmpeg="ssh "+serveruser+"@"+serverip+ " ffmpeg -vcodec mpeg1video -r 25 -b 512 -i "+ filelist[filenum-1] +” -s 240×144 -f mpeg - | nc “+n800ip+” 5000″


#Run mplayer and ffmpeg
print("RUN MPLAYER")
print(runmplayer)
print("RUN FFMPEG")
print(runffmpeg)
os.system(runmplayer)
os.system(runffmpeg)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google

Written by admin

October 17th, 2007 at 6:05 pm

Posted in Uncategorized

2 Responses to 'N800streamer'

Subscribe to comments with RSS or TrackBack to 'N800streamer'.

  1. [...] To install N800streamer, lets first wget [...]

  2. Incredible work on the blog! :) I wish blogging was easy as getting ripped was for me! :(

    Get Shredded

    6 Feb 10 at 1:56 pm

Leave a Reply