Monthly Archive for June, 2010

Convert mp4 to mp3

In this little tutorial I show you how to convert mp4 to mp3.

First method:

1
vlc some-video.mp4 --sout '#transcode{acodec=mp2a, ab=96}:std{access=file, dst= "my_new.mp3", mux=ts}'

Second one:

Your copy of FFmpeg needs to be capable of outputting mp3:

1
ffmpeg -formats | grep libmp3lame
1
ffmpeg -i 2Invention_Lonely_Star.MP4 -acodec libmp3lame -ab 128k 2Invention.mp3

Or a loop for more than one file:

1
for f in *.mp4; do ffmpeg -i $f -acodec libmp3lame -ab 128k $(echo $f | sed 's/\.mp4$/\.mp3/'); done




Convert to WAV:

1
mplayer -ao pcm 2Invention_Star.MP4 -ao pcm:file="2Invention_Star.wav"

A little convert loop:

1
2
3
4
5
6
7
#!/bin/bash
# 
# m4a2wav
# 
for i in *.m4a; do
    mplayer -ao pcm "$i" -ao pcm:file="${i%.m4a}.wav"
done

Chmod quite different

1
chmod -R u=rwx,g=rwx,o=rx white/

u = User
g = Group
o = Other

Sed replace text


I show you in this little example how to replace quickly text using sed:



1
2
cat examples.conf 
foo+bar=foo


1
sed -i 's/foo/foo_bar/g' examples.conf

foo in file examples.conf will be replaced with foo_bar
After replacement:

1
foo_bar+bar=foo_bar

Dry run without changes:

1
sed 's/192.168.0.1/nameserver.local/g' $domain

WordPress html line break

The only solution for line break I have found is to insert the following html code in the HTML Editor mode:

1
<br class="blank" />

Secure Apache2

By default apache shows on each directory listing, error or non existing page etc. apache version, OS Version and some apache modules in the bottom of your site.

Attackers can use this information to their advantage when performing an attack.
I describe a little bit how to secure apache2, to prevent the showing of apache version and server strings.

1
vim /etc/apache2/conf.d/security

Configuration should be:

2
3
4
ServerTokens Prod
ServerSignature Off
TraceEnable Off

Restart apache:

1
/etc/init.d/apache2 restart