Monday, July 27, 2009

ffmpeg perfect mp4 recipe?

We use the flowplayer flash player to display all of the videos on a site we built. The player can play h264 videos and this is the recommended recipe/formula for ffmpeg.

Original Post: http://flowplayer.org/forum/7/12671
ffmpeg -y -i trailerTest.mov -acodec libfaac -ar 44100 -ab 96k -coder ac -me full -me_range 16 -subq 5 -sc_threshold 40 -vcodec libx264 -s 1280x544" -b 1600k -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -i_qfactor 0.71 -keyint_min 25 -b_strategy 1 -g 250 -r 20 87.mp4
Make sure and read the post as there is a lot of information in there about different setups.

Saturday, July 25, 2009

php/javascript rotating image with flare

I am going through the rebranding of our corporate website and wanted to stay away from flash as much as possible to make things universal. I was looking for a very easy rotator and found one with a cool Javascript overlay. Here is the original person who I started with and then modified the code.

http://www.lawnydesigns.com/2009/07/how-to-add-jquery-image-slider-to-your.html

Here is my final code which works great as well. I used the same JS files.

<strong>HEAD INFORMATION</strong>
<pre lang="HTML" line="1"><!-- JavaScripts-->
<script type="text/javascript" src="includes/jquery.js"></script>
<script type="text/javascript" src="includes/s3Slider.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#s3slider').s3Slider({
            timeOut: 5000
        });
    });
</script>
</head>

<strong>BODY</strong>
<!-- begin photo slider -->
<div id="s3slider">
     <ul id="s3sliderContent">
          <li class="s3sliderImage">
               <img src="images/splash-1.jpg" />
               <span class="right"><strong>Right test</strong>
               <br />Consectetuer adipiscing elit.</span>
          </li>
          <li class="s3sliderImage">
               <img src="images/splash-3.jpg" />
               <span class="bottom"><strong>Bottom</strong>
               <br />Consectetuer adipiscing elit.</span>
          </li>
          <li class="s3sliderImage">
               <img src="images/splash-0.jpg" />
               <span class="left"><strong>Left test</strong>
               <br />Consectetuer adipiscing elit.</span>
          </li>
          <li class="s3sliderImage">
               <img src="images/splash-2.jpg" />
               <span class="top"><strong>Top test</strong>
               <br />Consectetuer adipiscing elit.</span>
          </li>
          <div class="clear s3sliderImage"></div>
     </ul>
</div>
<!-- end photo slider -->
Notice that the span left, right, top, bottom - This is how it appears, this is all pretty cool, you have to play with the CSS a bit to make it look perfect. Here is my CSS.
/* slider CSS */
#s3slider { 
   width: 820px; /* important to be same as image width */ 
   height: 350px; /* important to be same as image height */
   position: relative; /* important */
   overflow: hidden; /* important */
}

#s3sliderContent {
   width: 820px; /* important to be same as image width or wider */
   height: 350px;
   position: absolute; /* important */
   top: 0; /* important */
   margin-left: 0; /* important */
}

.s3sliderImage {
   float: left; /* important */
   position: relative; /* important */
   display: none; /* important */
}

.s3sliderImage span {
   position: absolute;
 font: 10px/15px Arial, Helvetica, sans-serif;
    padding: 10px 13px;
    width: 724px;
    background-color: #000;
    filter: alpha(opacity=70);
    -moz-opacity: 0.7;
 -khtml-opacity: 0.7;
    opacity: 0.7;
    color: #fff;
    display: none;

   /*
       if you put
       top: 0; -> the box with text will be shown at the top of the image 
       if you put
       bottom: 0; -> the box with text will be shown at the bottom of the image
   */
}

.s3sliderImage span strong {
    font-size: 14px;
}

.clear {
   clear: both;
}

.top {
 top: 0;
 left: 0;
}
.bottom {
 bottom: 0;
    left: 0;
    height: 40px;
}
.left {
 top: 0;
    left: 0;
 width: 110px !important;
 height: 330px;
}
.right {
 right: 0;
 bottom: 0;
 width: 130px !important;
 height: 332px;
}

Wednesday, July 22, 2009

Ubuntu Bonding 2+ NICs

I had problems with trying to get two independent NIC on the same network so I thought I would use bonding and it seems to work well. Here are the instructions for setting it up on Ubuntu 8.10, yes I know reverting back to 8.10 after so much invested in 9.04. I think the problem here is that 9.04 changed so much with the network that it has become a bit more tricky to get things working. This should work fine with 9.04 but I know 8.10 is stable with ServerOS and it should make a better NAS box for me. Anyways here are the instructions:

Install the bonding enslave programs
apt-get install ifenslave
Shutdown any active network interfaces you intend to use with bonding
sudo -s
ifdown eth0
ifdown eth1
Comment out the ethernet configurations from /etc/network/interfaces
#auto eth0
#iface eth0 inet dhcp
Add in the bonding configuration into /etc/network/interfaces
auto bond0
iface bond0 inet dhcp
     slaves all
     bond-mode 4
     bond-miimon 100
Bring up the interface
sudo ifup bond0
Bonding modes: mode=0 (balance-rr) Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.

mode=1 (active-backup) Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.

mode=2 (balance-xor) XOR policy: Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.

mode=3 (broadcast) Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.

mode=4 (802.3ad) IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.

Pre-requisites: Ethtool support in the base drivers for retrieving the speed and duplex of each slave. A switch that supports IEEE 802.3ad Dynamic link aggregation. Most switches will require some type of configuration to enable 802.3ad mode.

mode=5 (balance-tlb) Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.

Pre-requisite: Ethtool support in the base drivers for retrieving the speed of each slave. mode=6 (balance-alb) Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.

Testing results - I ran a simple ping from another machine and then while running unplugged each NIC and plugged it in while leaving at least (1) NIC attached rotating through all of the NIC which proves it switched between them and ping never stopped. Then I felt brave and used a FTP client and transferred a 12GB file from a laptop to the server doing the same rotating of pulling NIC wires. All worked flawlessly. I also rebooted and checked it again running through everything to make sure it kept the settings.

Check this site out for more information: http://blog.brightbox.co.uk/posts/howto-do-ethernet-bonding-on-ubuntu-properly

UPDATED: I got a script for the Cisco Switches to get this working
enable
configure terminal
interface <intf name> <intf number>
channel-group <group number> mode active
no shut
interface port-channel <group number>
no shut
end
write

Tuesday, July 21, 2009

Ubuntu Networking Commands

Found a couple of useful command for trouble shooting networking problems on Ubuntu I thought I would share.

show all network adaptors
lshw -C network
show all network configurations
ifconfig -a
Turn ON or OFF the network adaptor
ifconfig eth1 up
ifconfig eth1 down

Monday, July 20, 2009

Ruby on Rails compile mysql gem

I ran into this little problem of compiling mysql gem on a centOS box and thought I would share this.

NOTE: updated January 2010
If you don't have the mySQL development libraries installed then you might want to install them.
apt-get install libmysqlclient*-dev
Make sure you have the DEV libraries installed on the linux box and then run this command
gem install mysql --no-rdoc --no-ri -- --with-mysql-config=/usr/bin/mysql_config
It work for me on CentOS 5.3 just today.

Ubuntu 9.04 NFS fstab problems

I had a problem with the new release of Ubuntu 9.04 server not mounting remote shares upon boot. Turns out that the network service starts up after fstab now. An easy fix was to edit the /etc/rc.local file here is what I changed/added

/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#mount the NFS Shares
mount -a

exit 0
Above just added the "mount -a" just before the exit 0. Hope this helps everyone who is having the same problem. Seems to work perfect for me.

Sunday, July 19, 2009

Ubuntu Linux Header

So in some cases you need the linux headers installed on the machine in order compile new software

To find out what version of linux you are running run this
uname -r
You will get your version, example:
2.6.15-27-386
Then try to write this command:
apt-get install linux-headers-2.6.15-27-386
You can also try this..
apt-get install linux-headers-$(uname -r)

Saturday, July 18, 2009

Free Zipcode Database

I am working on a project for looking up distances from zipcodes. I found an open source database and some other information for making this happen. I will post more on this when I get it completed.

http://zips.sourceforge.net/

Also take a look at this site.

http://www.populardata.com/ (you can find the Canadian DB from there)

Good luck and I will post a bunch of information on this page when I am finished.

Wednesday, July 15, 2009

Quicktime codec for FFmpeg

I am working on a project with QuickTime movies and found that adding the extra library when compiling the system
apt-get install libquicktime-dev
I wasn't able to compile the ffmpeg with this but please go back and take a look at the recently updated ffmpeg build I revised.

Tuesday, July 7, 2009

FLVtool2 for Flash and FFmpeg

In order to get pseudostreaming/streaming of flash you will need to either setup this in your ffmpeg system or go back and use a tool to build a meta file to enable streaming. I found an easy tool that should help make the process much easier on Linux systems. Using ubuntu it is very easy.

installing flvtool2
apt-get install flvtool2
Simple command line for making the META file
flvtool2 -U <video_file>.flv
Also you should add in the "g-" into your ffmpeg scripts. Here is an example
ffmpeg -i UncompressedMov.mov -sameq -g 1 OutputFile.flv
In ffmpeg the number of keyframes is controlled by the g- flag. A smaller value leads to more keyframes and a larger file size. With small video files (less than 10Mb) a value such as 30 should be fine.

Wednesday, July 1, 2009

Network repair when switching NIC

So recently I have a VMware image go down and needed to move it to another machine. I had problems with the NIC when it was moved. Here I what I did.

In terminal under root I typed
dmesg | grep eth0
You will probably get an error that the eth0 was changed. Take the new name for the eth0 and edit the..
nano /etc/networking/interfaces
I changed the 0 to 1 and then rebooted the machine and everything seemed to work fine.

Other command that I did where
modprobe e1000
or
modprobe pcnet32

Raspberry Pi Zero W - Wireless Configuation

create the file under "boot" folder wpa_supplicant.conf country=GB ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev u...