FreeBSD USB keyboard stalled in single user mode

Trying to recover a root password in an old FreeBSD box (that has been working flawlessly for many years), after selecting single user boot in Beastie menu the keyboard stop responding…. oh well the USB support in old versions is somewhat buggy… just before i was going into the LiveCD route i found a thread in FreeBSD lists with this info:

1) From Beastie menu, escape to loader prompt.
2) set hint.atkbd.0.flags=”0x1″
3) boot -s

and it did the work. Afterward it was a child’s game to change the root password. All the credits to the freebsd lists.

Linux video and audio encoding and decoding

The last weeks, due to some stars alignment i had to do a lot of work with video files. Convertions of formats/containers, codecs, sound adjustments, the works…. first i tried some GUIs in M$ Windows, spent more time than i wanted in installation, testing, de-installing of messy software, and always the overall final results where nothing short of horrible. Then i remember to try in my Linux box ffmpeg, this is a pure command line utilty (no GUI in the middle, but there are some out there), and everything worked out rather good.

So, for my records, before all these commands get lost in history (man history):

Getting info about a file
ffmpeg -i filename.ext

Extracting video
ffmpeg -i inputfilename.ext -vcodec copy outfilename.ext

Extracting audio
ffmpeg -i inputfilename.ext -acodec copy outfilename.ext

Convert aac audio do mp3 (-ar freq in Hz -ab bitrate in bit/s), ex: convert at 44100Hz, 128Kbits
ffmpeg -i filename.aac -ar 44100 -ab 131072 audio.mp3

Convert aac audio do mp3 with volume adjust, good if sound is too high/low, -vol switch (256=normal), ex: 512 two times louder, 128 half sound
ffmpeg -i filename.aac -ar 44100 -ab 131072 -vol 512 audio.mp3

Convert raw avi to M$ compatible vanilla installation (no codecs) of Windows Media Player (-b switch for bitrate quality), example at 10Mb/s (good quality)
ffmpeg -i filename.avi -vcodec msmpeg4v2 -b 10000000 filename.avi

Convert raw avi to M$ compatible vanilla installation (no codecs) of Windows Media Player with frame rate adjust, example to 24 frames per second
ffmpeg -i filename.avi -vcodec msmpeg4v2 -b 10000000 -r 25 filename.avi

Convert raw avi to M$ wmv at 24 fps with the same quality settings of the original file
ffmpeg -i filename.avi -vcodec wmv1 -sameq -r 25 lfilename.wmv

Convert mp4 to avi, with the same quality settings
ffmpeg -i filename.mp4 -sameq filename.avi

Convert flv to mp4, keeping the same quality. Check if the flv audio and video stream is supported by your device. If it is, no need to re-encode, just change the container to mp4
ffmpeg -i filename.flv -c copy -copyts output.mp4

Some files had some kind of problems, and ffmpeg couldn’t parse them spitting some errors, so i give it a try in mencoder, and the son of a gun worked like a charm.

Extract video from file
mencoder infile.ext -ovc copy -nosound -o outfile.ext

Adjust the sound to lower volume
ffmpeg -i file.flv -acodec copy -vn audio.aac
ffmpeg -i audio.aac -ar 44100 -ab 131072 -vol 128 audio.mp3
ffmpeg -i file.flv -i audio.mp3 -map 0:0 -map 1:0 -vcodec copy -acodec copy file2.flv

This is just a scratch in the surface off ffmpeg and mencoder, and many more formats, options, conversions, codecs are supported, so this post can be updated anytime with new info.

Thank you Open Source for saving the day (yet again)!

Updates:

19/10/2013: i downloaded (sorry, bought on iTunes…) a mkv file with built-in subtitles and Dolby DTS sound. My TV Player didn’t like the audio (not supported) nor the built-in subtitles… time to fix this. Install mkvtoolnix and mkvtoolnix-gui

sudo apt-get install mkvtoolnix
sudo apt-get install mkvtoolnix-gui

Get information about file with mkvinfo

mkvinfo file.mkv

Example output (the relevant part):

| + A track
|  + Track number: 1 (track ID for mkvmerge & mkvextract: 0)
|  + Track UID: 1
|  + Track type: video
|  + Lacing flag: 0
|  + MinCache: 1
|  + Codec ID: V_MPEG4/ISO/AVC
|  + CodecPrivate, length 46 (h.264 profile: High @L4.1)
|  + Default duration: 41.708ms (23.976 frames/fields per second for a video track)
|  + Video track
|   + Pixel width: 1196
|   + Pixel height: 720
|   + Display width: 1196
|   + Display height: 720
| + A track
|  + Track number: 2 (track ID for mkvmerge & mkvextract: 1)
|  + Track UID: 1682142618
|  + Track type: audio
|  + Codec ID: A_DTS
|  + Default duration: 10.667ms (93.750 frames/fields per second for a video track)
|  + Language: jpn
|  + Audio track
|   + Sampling frequency: 48000
|   + Channels: 3
| + A track
|  + Track number: 3 (track ID for mkvmerge & mkvextract: 2)
|  + Track UID: 2244222851
|  + Track type: subtitles
|  + Lacing flag: 0
|  + Codec ID: S_TEXT/UTF8

so, 3 tracks. Track number 1 video in h.264, 2 audio in DTS with 3 channels and track 3 subtitles. So first thing, extract audio and subtitles (note that first track is track 0 and so on for mkvextract):

mkvextract tracks file.mkv 1:audio.dts
mkvextract tracks file.mkv 2:subtitles.srt

And there, all done about the subtitles, tbe .srt outputted works as is, no mores fuss with this. Now, the DTS audio not supported must be converted to another format, AC3 works fine with my TV so i converted DTS to AC3 (i had some errors trying to convert directly so i added an extra step as i converted to DTS to WAV and then to AC3 (the DTS bitrate was a whooping 2304Kbps !!! audio.dts was 1.2Gb…. so i downgraded to a pretty good quality and more sensible 640Kbps).

ffmpeg -i audio.dts audio.wav
ffmpeg -i audio.wav -acodec ac3 -ac 3 -ab 640k audio.ac3

Now, i went in for the muxing with the GUI, just run ‘mmg’ and then in the simple interface simply add the mkv and the audio.ac3, select in the tracks the video and the ac3 audio, unselect all the others tracks, and then “Start muxing”.

30/07/2012: a simple php script to bulk edit mp3 bitrate

<?php

$files = scandir('./');

foreach ($files as $file) {
  if (preg_match('/\.mp3$/', $file)) {
    $output = shell_exec('ffmpeg -i "'.$file.'" -ar 44100 -ab 192k "tmp.mp3"');
    rename("tmp.mp3", $file);
    unlink("tmp.mp3");
  }
}
?>

21/03/2011: since the writing of the post, i have been using more and more VirtualDub, it’s Windows only 🙁 but also Open source. Also a pain in the ass to install all the pug-ins, codecs, filters, etc… but after up and running is that easy to decode/encode in various formats.

Eye protection goggles

I will always wear my eye protection goggles when doing in hazardous work (even for short time).
I will always wear my eye protection goggles when doing in hazardous work (even for short time).
I will always wear my eye protection goggles when doing in hazardous work (even for short time).
I will always wear my eye protection goggles when doing in hazardous work (even for short time).
I will always wear my eye protection goggles when doing in hazardous work (even for short time).
I will always wear my eye protection goggles when doing in hazardous work (even for short time).
I will always wear my eye protection goggles when doing in hazardous work (even for short time).
I will always wear my eye protection goggles when doing in hazardous work (even for short time).
I will always wear my eye protection goggles when doing in hazardous work (even for short time).
I will always wear my eye protection goggles when doing in hazardous work (even for short time).

So help me God.

European first aid training course

Just finished last week a first aid training course at Portuguese Red Cross. It’s a 12h course with a hands on approach, on subjects like burns, bleedings, choking, victim transportation, getting help, bonds, cpr, and so on. This is a very usefull course, with (in)formation that can make a real difference in some emergency situations in someone’s (can be yourself) life and/or life quality.

The question is: Why in 12 years of mandatory school you actually don’t learn anything about this issue?

You have to learn so many useless stuff – best regards to my History teacher and the Barbarians invasion for example – and this knowledge is kept out of the formal educational system.

Car care – AC clean and spare tyre stow

The AC clean is a very important procedure to get a good air quality inside a vehicle, it can avoid nasty bugs like Legionella developing . It is a very easy procedure, any DIYer should be able to do it with good results and saving some good money (really dont understand how some shops charge over 50 euros for this…). So, what you need:

  • AC cleaner product – i use the 1z klima-cleaner due to very good reviews online – you can get it at a paint shop or car parts shop .
  • Philips screwdriver
  • New cabin filter with charcoal element (if outside big cities get the simple no need of the charcoal).

So first, gain access to the cabin filter and remove it. The Golf 4 is very easy, lift rain rubber seal, remove the screws that hold the filter cover (located in engine bay in front of passenger seat), press clips of the filter frame and pull out. With the old filter out of the way, clean everything up (dust, leaves, cigar butts…).


© Volksbloggin

Now comes the very hard part (not), shake the AC cleaner can and insert the hose that comes with it all the way down the AC system thru the openings revealed by the filter remotion. Use half of the can there, the other half use evenly in the air vents. Remember, AC off and air blower off, open the vents and select in the dash the corresponding air direction as you deliver the product in each vents/section. After the can is empty, put the new filter in place (installation is the reverse of the removal). Then, open the windows and let AC pump air for 10 minutes with nobody inside. You can now enjoy the fresh air inside your car, so go buy something pretty to yourself with the money you have just saved.

I also cleaned up the mess that was the spare tyre compartment. I had a flat (a big rupture at tyre wall) and needed to change the tyre at the highway shoulder, so the wrecked tyre had lots of debris attached to it, brake dust, road dust, bits of tyre rubber, etc that were laid up to the spare tyre compartment. Everything normal, i just don’t understand why when afterward you get the car to the tyre shop they couldn’t care less about that mess, and don’t even pass up with a rag… what a pigs… so unless you want to carry at the trunk brake dust, bits of burned rubber in decomposition and other things that are not good to your health, its up to you to clean up, its very easy and need simple tools:

  • Portable vacuum cleaner
  • Water
  • Nivea lotion

Remove the spare tyre, wash it up with water. Let it dry. Vacuum all the shit of the tyre compartment and clean up with a rag. When the tyre has dried apply a coating of Nivea lotion to the rubber, better more than less. Check and inflate if needed. Now you can store the spare tyre and rest assured that will serve you good in case of need.