Add Audio to a Video file in Linux with FFMPEG

Add Audio to a Video file in Linux with FFMPEG:

$ ffmpeg -i input.mp4 -i input.mp3 -vcodec copy -acodec libmp3lame output.flv


*NOTES:
- Where input is the source file and output the outcome file.
- The $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.
- Many file formats are supported, for more see $ man ffmpeg

Convert .MPG Video to a Compressed .AVI in Linux with Mencoder


Convert .MPEG/MPG Video to a Compressed .AVI in Linux with Mencoder:

1.) xvid

$ mencoder -ofps 25 -ovc xvid -oac mp3lame -lameopts abr:br=128 -srate 48000 -xvidencopts fixed_quant=4 input.mpg -o output.avi

/or

2.) x264

$ mencoder -ofps 25 -ovc x264 -oac mp3lame -lameopts abr:br=128 -srate 48000 -xvidencopts fixed_quant=4 input.mpg -o output.avi



*NOTES:
- Where input is the source file and output the outcome file.
- The $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.
- Using x264 option than xvid will make it the better compressed file, approx 10-30% smaller, this is my preferred conversion of the two.

Screencasting in Linux with FFMPEG

Screencasting in Linux with FFMPEG:

Open a terminal and issue the command below to start recording a video screencast of your desktop -


$ ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/output.mpg

press CTRL-C to exit.

*NOTES:
- Where output is the outcome file.
- The $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.
- You can name your file and folder to where the video will be saved whatever you like, in this tutorial I just use /tmp and output.mpg as the destination directory and outcome file name.

3 Ways to Join/Merge .AVI video files in Linux:


3 Ways to Join/Merge .AVI video files in Linux:



1.) avimerge

Issue the avimerge command as such:

$ avimerge -i b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi -o output.avi



2.) mencoder

Issue the mencoder command as such:

$ mencoder -oac copy -ovc copy file1.avi file2.avi file3.avi -o output.avi




3.) cat & mencoder

Issue the cat command to string together or concatenate the binary .avi files:

$ cat foo1.avi foo2.avi foo3.avi > output.avi

(this will string all binary .avi files first but the sync of audio and video might likely be broken, so follow the next instructions below to fix it.)

after issuing the cat command and getting the final file output from it, issue the following meconder command from the mplayer package:

$ mencoder -forceidx -oac copy -ovc copy input.avi -o output.avi




*NOTES:
- Where input is the source file and output the outcome file.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.
- The order you set the files to be joined or merged from left to right will be the sequence it will playback as one video file.
- Though for me avimerge is my preferred tool for this task.
- If the header file is broken in the final .avi use the avifix command part of the transcode package, as such:

$ avifix -i input.avi

/or

$ avifix -i input.avi -f 30,1

(this changes the header of the file input.avi and sets the frame rate to 30 fps.)

2 Ways to Disable Laptop Touchpad in Linux:


2 Ways to Disable laptop touchpad in Linux:

1.) Disable Touchpad with PSMOUSE Kernel Module

Sometimes when using a laptop the touchpad is too sensitive for typing that simply typing fast causes misstypes due to vibrations because of it, or you can be hitting it by accident, or that you dont need the touchpad as your using a mouse instead, to disable the touchpad issue command -

$ sudo /sbin/modprobe -r psmouse
/or
$ /sbin/modprobe -r psmouse
/or
# modprobe -r psmouse

to re-enable the touchpad again issue command -
$ sudo /sbin/modprobe psmouse
/or
# /sbin/modprobe psmouse
/or
# modprobe psmouse


2.) Disable Touchpad with SYNCLIENT

 - Using synclient utility, you can disable the laptop touchpad.
Disable touchpad, issue the command below:
 $ synclient TouchpadOff=1

For enabling touchpad, you need to set value to 0 and run this command in terminal as in below. 

 $ synclient TouchpadOff=0

- You can also put it in a startup bash script or config script so that it disables the touchpad on startup


*NOTES:
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.
- the # sign at the start of the command is to signify the Root user's terminal's prompt, no need to type this in.

Convert Image files within current Directory to .MPG video in Linux with FFMPEG


Convert Image/Picture files within current Directory to .MPG video in Linux with FFMPEG:

$ ffmpeg -r 10 -b 1800 -i %03d.jpg output.mp4



*NOTES:
- Where output is the outcome file.
- The $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.
- For this to work the files must start with 001.jpg and count from there in order, be careful not to miss a sequence number for example 001.jpg 002.jpg 003.jpg 005.jpg missing 004.jpg wont count the rest after, 005.jpg and if there are more after wont be added.


Convert an .MPG video to Picture files in Linux with FFMPEG


Convert an .MPG video to Picture files in Linux with FFMPEG:

$ ffmpeg -i input.mpg image%d.jpg

This command will generate the files named image1.jpg, image2.jpg, …

Picture files supported: PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.



*NOTES:
- Where input is the source file.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.

Convert .AVI video to PSP friendly .MP4 video file in Linux with FFMPEG


Convert .AVI video to a PSP friendly .MP4 video file in Linux with FFMPEG:

$ ffmpeg -i input.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac output.mp4

*NOTES:
- Where input is the source file and output the outcome file.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.

Extract Audio from .AVI video to an .MP3 file in Linux with FFMPEG:


Extract Audio/Music from .AVI video to an .MP3 file in Linux with FFMPEG:

$ ffmpeg -i input.avi -vn -ar 44100 -ac 2 -ab 320k -f mp3 output.mp3

*NOTES:
- Where input is the source file and output the outcome file.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.

Create VCD/SVCD/DVD from an .AVI in Linux with FFMPEG


Create VCD/SVCD/DVD from an .AVI in Linux with FFMPEG:



$ ffmpeg -i input.avi -target ntsc-dvd /tmp/output.mpg

*NOTES:
- Where input is the source file and output the outcome file.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.
- ffmpeg can make DVD video files using -target option,
the target can be any of the following "vcd", "svcd", "dvd", "dv", "pal-vcd", "ntsc-vcd", "ntsc-dvd", "ntsc-svcd in the example above ntsc-dvd is used

Convert .FLV to .AVI in Linux with FFMPEG


Convert .FLV to .AVI and vice versa in Linux with FFMPEG
(and vice versa)


$ ffmpeg -i input.flv -sameq output.avi

or


$ ffmpeg -i input.avi -sameq output.flv

*NOTES:
- Where input is the source file and output the outcome file.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.



Convert .MPG to .AVI in Linux with Transcode:


Convert .MPG to .AVI (divx/xvid) in Linux with Transcode:

$ transcode -i input.mpg -o output.avi -y divx

or 

$ transcode -i input.mpg -o output.avi -y xvid


*NOTES:
- Where input is the source file and output the outcome file.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.

Convert .AVI to .MP4 in Linux with Mencoder


Convert .AVI to .MP4 in Linux with Mencoder:

$ mencoder input.avi -o output.mp4 -oac copy -ovc lavc -lavcopts vcodec=mpeg1video -of mpeg

*NOTES:
- where input.avi is the avi file you want to convert and output.mp4 your desired mp4 file name.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.


Convert .VOB files to .AVI in Linux with Mencoder

Convert .VOB files to .AVI in Linux with Mencoder:

$ mencoder -vf harddup -vf-add smartblur=.6:-.5:0,unsharp=l5x5:.8:c5x5:.4 -xvidencopts fixed_quant=4:profile=dxnhtntsc -lameopts cbr:br=128:aq=0:vol=1 -oac mp4lame -ovc xvid input.vob -o output.avi

*NOTES:
- where input.vob is the vob file you want to convert and output.avi your desired avi file name.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.

Convert .VOB files to .AVI in Linux with FFMPEG


Convert .VOB files to .AVI in Linux with FFMPEG:

$ ffmpeg -i input.vob -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec libmp3lame -ab 128k output.avi

*NOTES:
- where input.vob is the vob file you want to convert and output.avi your desired avi file name.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.

Extract Audio .MP3 from Flash Videos in Linux with FFMPEG

Extract .mp3 music/audio from .mp4/flv flash videos using FFMPEG:
(like files from youtube)

$ ffmpeg -i input.flv -ab 128 -ar 44100 nodame_theme.mp3

/or

$ ffmpeg -i input.mp4 -ab 128 -ar 44100 nodame_theme.mp3



NOTES:
- where input is the flash file you want to extract the audio from,  and nodame_theme.mp3 the mp3 output file you want.
- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.
- rename nodame_theme.mp3 to the title you want after executing the command above.

3 Ways to Create an ISO image file from a Directory in Linux with Genisoimage

3 Ways to Create an ISO image file from a Directory in Linux:

*NOTES:

- Where output.iso is the iso image file name you want to name your iso to be, and input_directory/ your folder to create the iso from.

- the $ sign at the start of the command is to signify the terminal's prompt, no need to type this in.




1.) Creating an ISO image file from a Directory in Linux with Genisoimage:

Navigate in your CLI to the desired path where your directory you want to create an image file out of is:

$ genisoimage -r -J -o output.iso input_directory/


- You need to have genisoimage installed. 


2.) Creating an ISO image file from a Directory in Linux with Mkisofs:

$ mkisofs -J -o output.iso input_directory/

- You need to have mkisofs installed. 


3.) Creating an ISO image file from a directory in Linux with dd/diskdump:

$ dd if=/path-to-dir/ of=path-to-output/file.iso


* Though, I do prefer using genisoimage for this task.