Basic FFmpeg command lines

February 7th, 2011

want to convert a avi file to flv? extract the sound from a flv file and save it as mp3? see below:

1. Getting info from a video file

ffmpeg -i video.avi

2. Turn a sequence of images into video

ffmpeg -f image2 -i image%d.jpg video.mpg

3. Turn a video into a sequence of images

ffmpeg -i video.mpg image%d.jpg

4. Encode video for Ipod/IPhone

ffmpeg -i source_video_file.avi -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv -trell 1 -aic 2 -cmp 2 -subcmp 2 -s 320×180 -title X output_file.mp4

5. Encode video for PSP

ffmpeg -i source_video_file.avi -b 300 -s 320×240 -vcodec xvid -ab 32 -ar 24000 -acodec aac output_file.mp4ORffmpeg -i “OriginalFile.avi” -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 320×240 “OutputFile.mp4”

6. Extract audio from a video file and save it as mp3 format

ffmpeg -i source_video_file.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output_file.mp3

7. Convert a wave file to mp3

ffmpeg -i original_audio_file.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 output_file.mp3

8. Convert a avi video to mpeg

ffmpeg -i original_movie.avi output_file.mpg

9. Convert a mpeg video to avi

ffmpeg -i original_movie.mpg output_file.avi

10. Convert a avi video to uncompressed animated gif

ffmpeg -i original_movie.avi output_file.gif

11. Add audio to an existing video-only file (mix audio and video)

ffmpeg -i son.wav -i original_movie.avi output_file.mpg

12. Convert a avi video to flv (flash video)

ffmpeg -i original_movie.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320×240 -f flv output_file.flv

13. Convert a flv video to mpeg

ffmpeg -i myFile.flv -ab 56 -ar 22050 -b 500 -s 320×240 myFile.mpg

14. Convert a avi video to dv

ffmpeg -i original_movie.avi -s ntsc -r ntsc -aspect 4:3 -ar 48000 -ac 2 output_file.dvORffmpeg -i original_movie.avi -target ntsc-dv output_file.dv

15. Convert a avi video to mpeg specifically for DVD creation

ffmpeg -i source_video.avi -target ntsc-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg

16. Compress a avi video to Divx

ffmpeg -i original_movie.avi -s 320×240 -vcodec msmpeg4v2 output_file.avi

17. Convert a Ogg Theora video to mpeg specifically for DVD creation

ffmpeg -i original_movie.ogm -s 720×576 -vcodec mpeg2video -acodec mp3 output_file.mpg

18. Convert a avi video to mpeg2 for SVCD creation

ffmpeg -i original_movie.avi -target ntsc-svcd output_file.mpg

19. Convert a avi video to mpeg2 for VCD creation

ffmpeg -i original_movie.avi -target ntsc-vcd output_file.mpg

simple way to install flvtool2 on a centos server | 00.00 duration of a video?

November 28th, 2010

During the conversion of videos to flv format using ffmpeg, most video scripts use flvtool2 to calculate the duration of the video and to make the thumbs, sometimes it so happens that although flvtool2 is installed on the server, the duration is not calculated and all videos come out a 00.00 duration or the thumbs aren’t created, in this case it s better to reinstall flvtool2.
A simple way to reinstall flvtool2 with out having to reinstall the all ffmpeg libraries is the scope of this post.
First, make sure you have the newest version of Ruby installed from the Site Manager.
Login to root of your server, I assume it is a Centos 5.5 and enter the following commands:

# cd /usr/local/src
# wget
# tar zxf flvtool2-1.0.6.tgz
# cd flvtool2-1.0.6
# ruby setup.rb config –prefix=/usr/local/
# ruby setup.rb setup
# ruby setup.rb install

this will install the application into /usr/local/bin for you, and that is all. You are done, To use it, you can use this:
# cat /var/videos/flv/video.flv | flvtool2 -U stdin /var/videos/flv/video.flv

this will add the metadata to the flv file so that media players can read the file correctly.

On the official flvtool2 page the description of flvtool2 is:
FLVTool2 is a manipulation tool for Macromedia Flash Video files (FLV). It can calculate a lot of meta data, insert an onMetaData tag, cut FLV files, add cue points (onCuePoint), show the FLV structure and print meta data information in XML or YAML.

Of course if you host your video site with us FFmpeg Hosting this problems will not arise!! 🙂

how to protect a site using the htaccess file

November 18th, 2009

It is becoming increasingly difficult to protect a site from being hacked! Below are some lines which can be added to the .htaccess file to protect a site against some of the most common vulnerabilities:

# prevent access from santy webworm a-e
RewriteCond %{QUERY_STRING} ^(.*)highlight=\%2527 [OR]
RewriteCond %{QUERY_STRING} ^(.*)echr(.*) [OR]
RewriteCond %{QUERY_STRING}% s:(.*)252echr [OR]
RewriteCond %{QUERY_STRING} ^(.*)esystem(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)rush=\%65\%63\%68 [OR]
RewriteCond %{QUERY_STRING} ^(.*)rush=echo [OR]
RewriteCond %{QUERY_STRING} ^(.*)wget\%20 [OR]
RewriteCond %{QUERY_STRING}% s:(.*)wget
RewriteRule ^.*$ [R,L] 

# prevent pre php 4.3.10 bug
RewriteCond %{HTTP_COOKIE}% s:(.*):\%22test1\%22\%3b
RewriteRule ^.*$ [R,L]  

# this ruleset is to "stop" stupid attempts to use MS IIS Web Server expolits on us
RewriteCond %{REQUEST_URI} /(admin|cmd|httpodbc|nsiislog|root|shell)\.(dll|exe) [NC]
RewriteRule .* - [F,L]

RewriteCond %{REQUEST_URI} /default\.(ida|idq)$ [NC,OR]
RewriteCond %{REQUEST_URI} /.*\.printer$ [NC]
RewriteRule .* - [F,L]

# IE's "make available offline" mode
RewriteCond %{HTTP_USER_AGENT} MSIECrawler [OR]

# unknown bot
RewriteCond %{HTTP_USER_AGENT} ^NG [OR]

# You may want to enable these lines below to disallow php and perl scripts to access your site
 RewriteCond %{HTTP_USER_AGENT} ^.*PHP.*$ [OR]
 RewriteCond %{HTTP_USER_AGENT} ^.*libwww-perl [NC,OR]

# Ignorant user trying to edit my site
RewriteCond %{HTTP_USER_AGENT} FrontPage [OR]
#this one will ban everything microsoft. Use with caution.
RewriteCond %{HTTP_USER_AGENT} ^(Microsoft|MFC).(Data|URL|WebDAV|Foundation).(Access|Control|MiniRedir|Class) [NC,OR]

# MSOffice
RewriteCond %{REQUEST_URI} ^/(MSOffice|_vti) [NC,OR]

# Various
RewriteCond %{REQUEST_URI} ^/(bin/|cgi/|cgi\-local/|cgi\-bin/|sumthin) [NC,OR]
RewriteCond %{THE_REQUEST} ^GET\ http [NC,OR]
RewriteCond %{REQUEST_URI} /sensepost\.exe [NC,OR]

# Cyveillance is a spybot that scours the web for copyright violations and ?damaging information? on
# behalf of clients such as the RIAA and MPAA. Their robot spoofs its User-Agent to look like Internet
# Explorer, and it completely ignores robots.txt. I have
# banned it by IP address.
RewriteCond %{REMOTE_ADDR} ^63\.148\.99\.2(2[4-9]|[34][0-9]|5[0-5])$ [OR]
RewriteCond %{REMOTE_ADDR} ^63\.226\.3[34]\. [OR]
RewriteCond %{REMOTE_ADDR} ^63\.212\.171\.161$ [OR]
RewriteCond %{REMOTE_ADDR} ^65\.118\.41\.(19[2-9]|2[01][0-9]|22[0-3])$ [OR]

# NameProtect peddles their ?online brand monitoring? to unsuspecting and gullible companies
# looking for people to sue. Despite the claims on their robot information page, they do not
# respect robots.txt; in fact, they spoof their User-Agent in multiple ways to avoid detection.
# I have banned them by User-Agent and IP address.
RewriteCond %{REMOTE_ADDR} ^12\.148\.196\.(12[8-9]|1[3-9][0-9]|2[0-4][0-9]|25[0-5])$ [OR]
RewriteCond %{REMOTE_ADDR} ^12\.148\.209\.(19[2-9]|2[0-4][0-9]|25[0-5])$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^NPBot	[NC,OR]

# Web Content International
RewriteCond %{REMOTE_ADDR} ^65\.102\.12\.2(2[4-9]|3[01])$ [OR]
RewriteCond %{REMOTE_ADDR} ^65\.102\.17\.(3[2-9]|[4-6][0-9]|7[01]|8[89]|9[0-5]|10[4-9]|11[01])$ [OR]
RewriteCond %{REMOTE_ADDR} ^65\.102\.23\.1(5[2-9]|6[0-7])$ [OR]

# dumb bot
RewriteCond %{HTTP_USER_AGENT} "^Mozilla/4.0$" [OR]

# Wordtracker
RewriteCond %{REMOTE_ADDR} ^128\.242\.197\.101$ [OR]

# Unknown
RewriteCond %{REMOTE_ADDR} ^64\.156\.198\.(6[89]|7[0-9]|80)$ [OR]

RewriteCond %{REMOTE_ADDR} ^65\.223\.250\.25[0-3]$ [OR]

# Turnitin spybot
RewriteCond %{REMOTE_ADDR} ^64\.140\.49\.6([6-9])$ [OR]
RewriteCond %{HTTP_USER_AGENT} TurnitinBot [OR]

# this ruleset is for formmail script abusers...
# we don't use Perl for Postnuke so this is not really needed.
RewriteCond %{REQUEST_URI} (mail.?form|form|form.?mail|mail|mailto)\.(cgi|exe|pl)$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*FileHound.*$
RewriteRule .* - [F,L]

# dumb bot
RewriteCond %{HTTP_USER_AGENT} "^Mozilla/3.0$"
RewriteRule .* - [F,L]

<FILES .htaccess>
order allow,deny
deny from all

Alojamento Sites – New European Host

July 2nd, 2009

Normalmente as empresas de alojamento web limitam-se a fornecer ferramentas que permitam criar apenas um site básico com html e possivelmente php e bases de dados mysql, no entanto existem webmasters que precisam de mais do que isso, precisam de ter ferramentas que lhes permitam trabalhar com vídeo e usar o seu alojamento para funcionalidades avançadas.

Um alojamento com suporte ffmpeg irá fornecer todas as ferramentas necessárias ao webmaster para que este possa criar o seu site de partilha de vídeos sem ter que pagar por um servidor dedicado ou por uma VPS e/ou ter que pagar a alguém para que lhe instale as bibliotecas necessárias no servidor para que possa converter, editar e manipular vídeo online facilmente.


Server Paths

October 26th, 2007

Please login to your cpanel and on top of the cpanel, you will have all the information about server paths, ffmpeg and red5.

Thank you.