FFMpeg with Lame MP3 and streaming for the Arduino Yun

So, I've been trying to stream audio off of a USB microphone connected to an Arduino Yun.
Looking into it online I found some examples using ffserver & ffmpeg, which sounded like they could do the trick.
However right from the start I've had many problems with playing the streams on Android and iOS devices.
Seems Android likes a certain list of codecs (http://developer.android.com/guide/appendix/media-formats.html) and iOS like a different set of codecs (Link here), but they do have on codec in common - good ol' MP3.
Unfortunately, the OpenWRT on the Arduino Yun has an ffmpeg build which does not provide MP3 encoding... it does have the MP3 muxer/container format, but streaming anything other then MP3 in it (for example MP2, which the Yun-ffmpeg does have) simply doesn't work on the Android/iOS.
From experiments streaming from my PC a ffmpeg/libmp3lame MP3 stream, it looks like the mobile devices are quite happy with it - so I will need to recompile ffmpeg with Lame MP3 support to be able to stream it.
Continue reading "FFMpeg with Lame MP3 and streaming for the Arduino Yun"

Share

Tailing the output of multiple files in Linux

This is a quick post to show a trick to tail multiple files, while showing the filename in the beginning of the line

What I needed was a way to grep multiple logs for an exception. But doing "tail -f *.log | grep exception" only let me see the exception, but I didn't know which log file to look in

I have found this guide, and altered the script and added

  1. Printing the file name in the beginning of each line
  2. Padding spaces after the file name (you can alter the minimal length in the ALIGN variable

Anyway - here's the script. Hope you find it useful

#!/bin/bash
 
# When this exits, exit all back ground process also.
trap 'kill $(jobs -p)' EXIT
 
ALIGN=31
 
# iterate through the each given file names,
for file in "$@"
do
        LENGTH=`echo ${file} | wc -c`
        PADDING=`expr ${ALIGN} - ${LENGTH}`
        PAD=`perl -e "print ' ' x $PADDING;"`
 
        # show tails of each in background.
        tail -f $file | sed "s/^/${file}${PAD}:/g"  &
done
 
# wait .. until CTRL+C
wait
Share

A Creative way to bypass Pattern lock on Android

Let me start putting everything on the table – this post will describe how I eventually managed to unlock an unrooted, non-Google account linked Samsung Galaxy Mini Plus (GT-5570I) device without ADB support. There are a lot of guides on how to bypass this pattern lock on Android (and I will provide some links), but the purpose of this post is to show how looking for creative ways to do this can come handy

So a friend gave me a locked device. This device had no Google account linked to it (which prevented me from bypassing the lock with that account), there was no root or ADB access via recovery, and the USB debugging option was disabled.

I found this guide here, which states some commands you can type in ADB shell and should deactivate the pattern lock. So – How do I get ADB access on that phone? Continue reading "A Creative way to bypass Pattern lock on Android"

Share

Reading a directory in C++ (Win32 & Posix)

Just a snippet of code if someone out there needs it. I keep coming back to it, so I thought why not share it...

#include <iostream>

#ifndef WIN32
#include <dirent.h>
#endif

using namespace std;

void open_imgs_dir(char* dir_name, std::vector<std::string>& file_names) {
	if (dir_name == NULL) {
		return;
	}

	string dir_name_ = string(dir_name);
	vector<string> files_;

#ifndef WIN32
//open a directory the POSIX way

	DIR *dp;
	struct dirent *ep;     
	dp = opendir (dir_name);
	
	if (dp != NULL)
	{
		while (ep = readdir (dp)) {
			if (ep->d_name[0] != '.')
				files_.push_back(ep->d_name);
		}
		
		(void) closedir (dp);
	}
	else {
		cerr << ("Couldn't open the directory");
		return;
	}

#else
//open a directory the WIN32 way
	HANDLE hFind = INVALID_HANDLE_VALUE;
	WIN32_FIND_DATA fdata;

	if(dir_name_[dir_name_.size()-1] == '\\' || dir_name_[dir_name_.size()-1] == '/') {
		dir_name_ = dir_name_.substr(0,dir_name_.size()-1);
	}

	hFind = FindFirstFile(string(dir_name_).append("\\*").c_str(), &fdata);	
	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			if (strcmp(fdata.cFileName, ".") != 0 &&
				strcmp(fdata.cFileName, "..") != 0)
			{
				if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				{
					continue; // a diretory
				}
				else
				{
					files_.push_back(fdata.cFileName);
				}
			}
		}
		while (FindNextFile(hFind, &fdata) != 0);
	} else {
		cerr << "can't open directory\n";
		return;
	}

	if (GetLastError() != ERROR_NO_MORE_FILES)
	{
		FindClose(hFind);
		cerr << "some other error with opening directory: " << GetLastError() << endl;
		return;
	}

	FindClose(hFind);
	hFind = INVALID_HANDLE_VALUE;
#endif
	
	file_names.clear();
	file_names = files_;
}

Enjoy
Roy.

Share

Useful ImageMagick and FFmpeg shortcuts for Win SendTo menu

Hello

Quickly sharing some useful scripts I've "developed" over the summer to cope with some image resizing / video ripping / transcoding, etc.
Instead of using some specialized GUI software for transcoding I thought why not simply put useful options in the Windows file browser "Send To..." context menu. That way I can right-click the file I want to work with and just send it to some tool to do the job.

Here it is...
Continue reading "Useful ImageMagick and FFmpeg shortcuts for Win SendTo menu"

Share

The Raspberry Pi is Here

A few months back I placed an order for a raspberry pi. For those who don't know what it is, it is a really cool project which is basically a computer for 35$ (Shipping for me almost doubled it, but that's to be expected). It is a board, which as 256MB Ram, SD-Card slot, 2 USB Slots, an RCA Slot for analog video, and a headphone jack for analog audio.

It is originally a project for schools, to help today's kids get started with (python, but not only) programming.

To be exact with what the project guys are describing it:

The Raspberry Pi is a credit-card sized computer board that plugs into a TV and a keyboard. It's a miniature ARM-based PC which can be used for many of the things that a desktop PC does, like spreadsheets, word-processing and games. It also plays High-Definition video.
Here are some FAQs

The OS of this board is stored on an SD Card. I have bought a class 10 16gb SD Card off of eBay for this purpose.

So few days ago, the board arrived! I finally found myself playing with it, and it's so much fun

Here are some common suggestions for usages: Continue reading "The Raspberry Pi is Here"

Share

Bootloading an ATmega88 for Arduino [w/ code]

Just wanted to put up a small tut on how to put an Arduino bootloader on an ATmega88.

I very roughly followed: 
http://www.ladyada.net/learn/avr/avrdude.html
And 
http://itp.nyu.edu/physcomp/Tutorials/ArduinoBreadboard (Although they make it way too complicated)
And ATMEL's datasheet for ATmega88 is also very good to have open at all times: 
http://www.atmel.com/Images/2545s.pdf

First, put everything on a breadboard: (This took me a while... Thanks D.Mellis and M.Feldmeier!!)

(Fritzing is awesome)
Continue reading "Bootloading an ATmega88 for Arduino [w/ code]"

Share