Archive for ‘Linux’ Category

How to live transcode and stream HDV to MP4 using VLC and Linux

datePosted on 22:20, November 21st, 2007 by Many Ayromlou

I’ve been trying to figure out a way to do this on the cheap for a long time and I finally figured it out today. This process allows you to grab HDV from a HDV Camera via firewire, feed it into linux, transcode the 25Mb/s mpeg-ts stream to a 4 Mb/s mpeg4 stream (inside a TS). This mpeg4 stream in turn can be viewed at full resolution (1920×1080) on a remote client running just vlc. Here is the prerequisites:

  1. A decent machine with working Firewire port (anything from the past 2-3 years should do). Laptops might work as well although I have not tried it yet. My machine is a Athlon 4200+ w/ 2GB of RAM and a 512 MB NVIDIA 7900.
  2. Ubuntu 7.10 (Gutsy Gibbon) installation CD.
  3. 4-pin to 6-pin Firewire cable.
  4. HDV Camera with Firewire out (I use a Canon HV20).
Okay so here we go, follow the steps below to get setup:
  1. Get Ubuntu 7.10 installed on your machine. This should be standard installation from the Live-CD.
  2. Reboot, do all adjustments to your display, get network setup, install all the updates.
  3. Using synaptic package manager install the following extra packages: ubuntu-extras, ffmpeg, dvgrab 3 and VLC plus anything else you might want.
  4. Connect the firewire camera to the computer and check /var/log/messages to make sure it gets recognized.
Now that you have the chain setup, it’s time to do a quick test and see if the system is working. Issue the following command from a xterm, making sure that the camera is turned on and in “Camera” mode.

sudo dvgrab -f hdv -noavc -nostop -|vlc -
You have to use sudo under ubuntu to get proper access to the firewire device. The above command runs dvgrab with hdv format and makes sure that 1394 AV/Device control is turned off (this way you can be in Camera mode and get a live feed). The nostop switch prevents dvgrab from sending stop commands to the camera everytime you stop it via Ctrl-C, which I though was a good thing. The last dash forces dvgrab to output to stdout, which we’ll then pipe into vlc (the dash for vlc tells it to use stdin as input).

If this works you should get a vlc window and be able to see live video from your HDV camera. If you didn’t then stop here and make sure you get this working first.
So now that we have dvgrab working, lets grab that 25Mb/s HDV stream and squish it down to 4Mb/s mpeg4 stream using the following command:

sudo dvgrab -f hdv -noavc -nostop -|vlc - --sout '#transcode{vcodec=mp4v,vb=4096,acodec=mpga,ab=256,scale=0.5,deinterlace,width=1920,height=1080}:duplicate{dst=std{access=udp,mux=ts,dst=receiver_ip_address:1234}}'
This is one massive command, the first part we already discussed, so lets take a look at the second half:

  • –sout is our output chain.
  • #transcode tells vlc that we first want to transcode the input using parameters to follow
  • {} contains our transcoding parameters
  • vcodec=mp4v sets the video codec to mpeg4 video
  • vb=4096 sets the bitrate of the transcoded video (4Mb/s)
  • acodec=mpga sets the audio codec to mpeg audio (mp3)
  • ab=256 sets the bitrate of the transcoded audio (256 Kb/s)
  • scale=1 sets the scaling value
  • deinterlace sets guess what?
  • width=1920 sets the width of the transcoded video to 1920 pixels
  • height=1080 sets the height of the transcoded video to 1080 pixels
  • :duplicate tells VLC that we want to duplicate the transcoded signal and send a copy of it to our receiver machine.
  • dst is the destination string
  • access=udp specifies UDP protocol
  • mux=ts sets multiplexing to mpeg-2 Transport stream
  • dst=receiver_ip_address:1234 is the ip address and port number of the receiving machine
So now you should be able to open up vlc on the receiver machine, goto File/Open Network menu and select UDP/RTP and specify port number 1234. Once you press OK, you should see the video stream on your receiver machine. Audio works as well and is perfectly synced since it’s captured by the HDV camera at the source and travels together with the video at all time. The delay is about 3 seconds.
This is a great way to quickly setup a HD Video Conference between a couple of locations. You could even modify the network portion of the chain to let VLC multicast the HD stream onto your network…..lots of possibilities. Enjoy :-)
Share

Getting Samba to work properly with SuSE’s Firewall…

datePosted on 19:57, November 1st, 2007 by Many Ayromlou

Here we are again and I have to sadly say…..yet another OS (which I also love) that does not do what it promises. I know that you can do some major iptables kungfu under linux through command line, but when SuSE/Novell tries to sell you Yast as a graphical admin interface they should atleast check to make sure things are working properly.

Samba works under SuSE 10.x, and even with the firewall turned on the machine can act as a member of a Windows domain/workgroup. The problem though, is not with using Samba and having the firewall turned on. The problem is having Samba do more than just act as a member of the domain. We have a SuSE 10.1 machine that is part of our AD domain (spanning 3 subnets) and we also like it to be our local master and preferred master on the local subnet. It has one NIC active (ie: direct connection, with no NAT) and iptables firewall is active on that NIC. The problem is that the firewall rules that Yast2 creates are too restrictive (ie: if you just go to Yast2 and add Samba services as a allowed service). 
Here is how you can fix this with a bit more effort:
  • Setup the firewall with allowed services you like to punch through (ie: ssh, ftp and alike). Include Samba Server in the list as well under allowed services.
  • Start the Firewall, at this point the basic samba stuff is working (ie: you can browse), but you more than likely can not do anything more in terms of domain participation.
  • From the Yast2 interface go to System> /etc/sysconfig editor screen
  • Goto the section Network> Firewall> SuSEfirewall2
  • ADD the following service names to appropriate sections ONLY if they are missing
  • Under heading FW_SERVICES_EXT_TCP make sure you have the following:

microsoft-ds netbios-dgm netbios-ns netbios-ssn

  • Under heading FW_SERVICES_EXT_UDP make sure you have the following:

netbios-ns

  • Under heading FW_ALLOW_INCOMING_HIGHPORTS_TCP make sure you have the following:

microsoft-ds netbios-ns

  • Under heading FW_ALLOW_INCOMING_HIGHPORTS_UDP make sure you have the following:

microsoft-ds netbios-ns

  • Under heading FW_ALLOW_FW_BROADCAST_EXT make sure you have the following:

netbios-ns netbios-dgm

Now you’ve got the right holes punched through the firewall so click Finish and enjoy. You can now go back to the Samba config and make changes to become a serving member of your domain/workgroup.
Share

Tablet Puppy….

datePosted on 22:23, October 27th, 2007 by Many Ayromlou


For all the Nokia N800 fans out there……this is what happens if Nokia was sponsoring your High school :-) . Seriously though, this is a fantastic example of what kids (and adults) can do using the opensource N800 platform for robotics control. Now who’s gonna stick one of these things on a gas powered RC car…..Dibs on the Remote :-)

Share

Okay so this all started with our users not being able to share files on our webserver. We use SSH only for upload/download and interactive access (ie: no ftp). Through trial and error we found out that the default umask (under OSX Server) for sftp uploaded files are 0033 (ie: rwxr–r–) and directories are 0022 (ie: rwxr-xr-x). This creates a problem when one user uploads a file and another user downloads/modifies and tries to re-upload it — they simply can’t because the group permissions are wrong.

If we were using ftp (which we are not) there are some solutions on the net that allow you to modify the startup parameters for the ftp server so that the default umask for all files is 0013 — which would allow a group of people to share/overwrite each others files — but we are using ssh only.

So we came up with two other solutions — a shared upload account and/or a cron job that would modify the group permissions on the website directory to allow group sharing. We went with the second solution and that’s where I ran into so many problems that I decided to create this post. You see normally Unix users know that spaces (and strange characters) in filenames are a no-no. Well that’s not true for Windows and Mac users, they use spaces and other odd characters in their filenames/folders all the time.

I started writing — what I thought was — a simple “for loop” script to go through the website folder and change the group permissions. Of course on the first try things didn’t work nicely because of spaces, so I started compensating for that and came up with:
for i in `find /Path/to/www -type d -print0 |xargs -0 -n 1`
This kinda worked, but the for loop would still split the lines when it hit spaces in filenames. I tried to mess around with it and gave up. After RTFMing a bit more I tried:
for i in `find /Path/to/www -type d -exec echo \"{}\" \;`
The thinking behind this was that the exec would echo the filenames quoted and it should work….well it didn’t, the for loop still split the input lines at spaces.

Finally after a latenight RTFM session (and lots of cursing), I think I’ve found the ultimate file handling loop statement:
find /Path/to/www -type d ! -perm -g=wx -print0 | while IFS= read -rd $'\0' filename
Okay so this version uses “while” rather than “for” but it works like a charm and chews through spaces and all other kinds of weird chars and creates a output stream that’s ready to be used by your choice of commands (chmod in my case).

After trimming and optimizing the script a bit, here is the final product:
# The following find will search for
# all files under /Path/to/www, that
# are NOT symlinks, and do NOT have
# group write permission. The list is
# "\0" seperated and the while portion
# will loop around this character and
# ignore everything else in the path.
find /Path/to/www ! -type l ! -perm -g=w -print0 | while IFS= read -rd $'\0' filename
do
# We've found a directory with no group
# write permission, so fix it.
if [ -d "$filename" ]
then
chmod g+rwx "$filename"
# echo Directory changed
stat -l "$filename"
fi
# We've found a file with no group
# write permission, so fix it.
if [ -f "$filename" ]
then
chmod g+rw "$filename"
# echo File changed
stat -l "$filename"
fi
done

Hopefully you’ll find this code (or portions of it) useful for your own day-to-day hack-and-slash solutions to annoying problems. Let me know if you come up with an even better solution :-)

Share

is TV freed?

datePosted on 10:04, August 31st, 2007 by Many Ayromlou

Well, I’ll leave this one to you. You can decide on it’s Kosherness. The application is called TED and it can find all sorts of TV episodes you might have missed. From the homepage:

ted can find episodes of any TV show you like to watch. Just add your favorite shows to ted and he will search for the newest episodes and downloads them for you. ted uses bittorrent and RSS technology to get you the newest episodes as fast as possible! ted comes with a huge list of shows, all waiting for you to be watched. ted even displays a summary of each show, to help you choose shows you like.

ted requires Java 5 and a bittorrent client and is available for all platforms (Linux, Windows, Mac). Download here.

Share

Manage your Projects FREE….

datePosted on 09:44, August 31st, 2007 by Many Ayromlou

You all know my dislike for Microsoft and their products. Whenever possible I’ve tried to get away from having to use their software. Here is another opensource product that allows us to do our thing without them. From their overview page:

OpenProj is a free, open source desktop alternative to Microsoft Project. The OpenProj solution is ideal for desktop project Click to enlarge in a new windowmanagement and is available on Linux, Unix, Mac or Windows. OpenProj is a complete desktop replacement of Microsoft Project and even opens existing native Project files. OpenProj shares the most advanced scheduling engine in the industry with Project-ON-Demand. The OpenProj solution has Gantt Charts, Network Diagrams (PERT Charts), WBS and RBS charts, Earned Value costing and more.

You can get more detailed information on OpenProj or download now!

Share

iPhone keyboard done better on Nokia N800….

datePosted on 21:23, July 30th, 2007 by Many Ayromlou

Well they said it can’t be done. They said the secret of the apple sauce was only known to Steve. Looks like Gustavo Sverzut Barbieri has it figured out. 1340 lines of code and you’ve got the Apple’s Ubercool keyboard on the N800…..gotta love open platforms.

Share

Get down and dirty with Gumstix Goliath…

datePosted on 12:08, July 19th, 2007 by Many Ayromlou

We’ve been covering quite a bit of Opensource/Linux/Hack-your-own GSM phones (some even with GPS), but here is the ultimate phone for the N.E.R.D’s out there….From the Press Release:

“Portola Valley, Calif., July 10, 2007 – Gumstix, Inc, today announced its integrated, open source cellular communications platform: the GoliathTM line of expansion boards. The Goliath-vx board provides GPRS/EDGE function while the Goliath-GPS-vx board combines GPRS/EDGE and GPS. Each Goliath board attaches to a gumstixTM motherboard (verdex only) using a 60-pin connector and includes audio, LCD, touch screen, USB host, 3D-accelerometer, and battery management. General availability is planned for late July and the company will begin taking pre-orders at gumstix.com starting on 16 July.

The Goliath boards are by far the largest gumstix products at 105.5mm x 67.3mm, the same dimensions as the Samsung 4.3” LCD touch screens that Gumstix will also sell. Goliath gives verdex motherboards full-speed USB access to the Siemens MC75 GPRS/EDGE module, the u-blox NEO-4S GPS module, and one external USB device.”

For those of you who don’t know, Gumstix has been manufacturing a couple of different embedded platforms around the XScale processor family. Their boards runs an opensource embedded Linux exclusively. Recently they have branched out into building lots of expansion boards. These expansion boards when combined with their motherboards can truly allow you to create just about anything. Sounds like you’ve got everything you need to build the “real” Iphone :-)

Share

One for the Penguins….

datePosted on 11:40, July 19th, 2007 by Many Ayromlou

Right on the heels of our story on reconstructor, a tool that allows you to create custom Ubuntu distribution CD’s, here is APTonCD for Ubuntu. It’s basically a graphical tool that allows you to create a CD of all the applications you’ve installed on your Ubuntu system since you installed the system initially. This used to be a pain, if you had to take care of a lab of machines. The drill was: install the OS, add all the required software and then created a master image, followed by multiple image installs.

Well thanks to APTonCD you don’t have to do this anymore. You can install the base CD/DVD (or make your own using reconstructor), add all the extra software from the repositories and then run APTonCD. At which point you can instruct it to create a CD/DVD of all the extra packages you’ve installed. The application can also create a CD/DVD of all the software on a specific repository or download all official Ubuntu repositories onto removable media. Very handy if you’re doing a install without net connection.

One more thing you can do with this is to get all the Ubuntu official updates/patches/fixes on a CD/DVD, so that you download them only once (if you’re installing mutiple machines). As usual the install is a simple one-liner:

sudo apt-get install aptoncd

Share

So you like Ubuntu….

datePosted on 22:05, July 9th, 2007 by Many Ayromlou


Came across this the other day. Reconstructor is the new cool tool that allows you to grab you favourite ubuntu distro (desktop, alternate or server). Now you can have your Ubuntu and eat it too :-) . It’s free and runs on linux (yeah there is a bit of a chicken and egg problem here). Well, I’m off to build Mabuntu (aka Many’s Ubuntu)…..hehehe.

Share

Screencasts of Installing MythTV Via MythDora 4.0

datePosted on 00:30, May 30th, 2007 by Many Ayromlou

MythDora 4.0–Fedora Core 6.0 plus MythTV costumizations–is out. It is designed to format your hard drive and install everything needed for a fully functional MythTV System. MythPVR.com has created a three-part screencast of the installation process covering MythDora installation, configuration, and MythTV setup.

Share

HDHomeRun: Multicast

datePosted on 14:58, May 28th, 2007 by Many Ayromlou

Using hdhomerun_config command you issue the following (after tuning into the channel ofcourse):

1) hdhomerun_config set /tuner0/target none
2) hdhomerun_config set /tuner0/channel qam:
a) hdhomerun_config set /tuner0/streaminfo
3) hdhomerun_config set /tuner0/program
4) hdhomerun_config set /tuner0/target

MCast Address is in range of: 224.0.0.0 –> 239.255.255.255

Share

HDHomeRun: Monitoring Signal Strength from command line

datePosted on 14:56, May 28th, 2007 by Many Ayromlou

The Windows GUI version of hdhomerun_config will display the signal strength and signal quality updating every second.

Under linux or osx you can use “watch” with hdhomerun_config:
hdhomerun_config FFFFFFFF get /tuner0/channel 8vsb:
watch hdhomerun_config FFFFFFFF get /tuner0/status

(If you have more than one HDHomeRun then specify the device ID rather than FFFFFFFF)

Share

You use hdhomerun_config to manually configure HDHomeRun to stream video to a PC running VLC…

You will need:

VLC – http://www.videolan.org/vlc/
hdhomerun_config – http://www.silicondust.com/forum/viewtopic.php?t=1923

1) Discover HDHomeRun

Run “hdhomerun_config discover” to find the HDHomeRun units on the local network.

If you have more than one HDHomeRun on your network then replace the wildcard FFFFFFFF Device ID in the examples with the Device ID of the HDHomeRun you wish to control.

2) Run a channel scan

hdhomerun_config FFFFFFFF scan /tuner0

3) Set the channel

Antenna:
hdhomerun_config FFFFFFFF set /tuner0/channel 8vsb:
Cable:
hdhomerun_config FFFFFFFF set /tuner0/channel qam:

Note that the channel is the physical ATSC channel, not the channel advertised by the TV station. Antennaweb.org is a good site for determining which stations are nearby and what physical channels they operate on: http://www.antennaweb.org/aw/Address.aspx

Check the signal strength using the following command:
hdhomerun_config FFFFFFFF get /tuner0/status

4) Select the program number

hdhomerun_config FFFFFFFF get /tuner0/streaminfo

hdhomerun_config FFFFFFFF set /tuner0/program

5) Launch VLC and open network stream
From the command line:
vlc udp://@:1234

From the GUI:
Launch VLC
File -> Open Network Stream
Choose UDP/RTP, Port 1234

6) Set the target for the video stream

hdhomerun_config FFFFFFFF set /tuner0/target :1234

Note that the target setting is automatically cleared if the target machine is not listening on the specified port. ie if VLC is not running or you quit VLC.

Troubleshooting

Check the signal strength using the following command:
hdhomerun_config FFFFFFFF get /tuner0/status

Check the target using the following command:
hdhomerun_config FFFFFFFF get /tuner0/target

If it reports “none” then most likely the pc was not listening on the target port and the ip/port was automatically cleared. Double check the following and then set the target again:
- Check that VLC is running and is using “udp://@” or “udp://@:1234″.
- Check the IP address of the machine VLC is running on.
- Check that the port is not blocked by a firewall.

If the target is correct and the LED on the HDHomeRun indicates it is streaming video then the most likely problem is a firewall blocking the port (UDP port 1234 used in this example).

Share
1234Previous