Showing posts with label Convert. Show all posts
Showing posts with label Convert. Show all posts

Friday, August 24, 2012

Batch Encoding H.264 Video with HandBrake

Batch Encoding H.264 Video with HandBrake

(Just as in the previous section, in this section I’m going to use “H.264 video” as a shorthand for “H.264 baseline profile video and AAC low-complexity profile audio in an MPEG-4 container.” This is the combination of codecs+container that works natively in Safari, in Adobe Flash, on the iPhone, and on Google Android devices.)
HandBrake also comes in a command-line edition. As with ffmpeg2theora, the command-line edition of HandBrake offers a dizzying array of options. (Type HandBrakeCLI --help to read about them.) I’ll focus on just a few:
  • --preset "X", where “X” is the name of a HandBrake preset. The preset you want for H.264 web video is called “iPhone & iPod Touch”, and it’s important to put the entire name in quotes.
  • --width W, where “W” is the width of your encoded video. HandBrake will automatically adjust the height to maintain the original video’s proportions.
  • --vb Q, where “Q” is the average bitrate (measured in kilobits per second).
  • --two-pass, which enables 2-pass encoding.
  • --turbo, which enables turbo first pass during 2-pass encoding.
  • --input F, where “F” is the filename of your source video.
  • --output E, where “E” is the destination filename for your encoded video.
Here is an example of calling HandBrake on the command line, with command line flags that match the settings we chose with the graphical version of HandBrake.
you@localhost$ HandBrakeCLI --preset "iPhone & iPod Touch"
                            --width 320
                            --vb 600
                            --two-pass
                            --turbo
                            --input pr6.dv
                            --output pr6.mp4
From top to bottom, this command runs HandBrake with the “iPhone & iPod Touch” preset, resizes the video to 320×240, sets the average bitrate to 600 kbps, enables two-pass encoding with a turbo first pass, reads the file pr6.dv, and encodes it as pr6.mp4. Whew!

Tuesday, August 16, 2011

HOW TO : Convert .flv to .mp3 in Ubuntu, Debian Linux

Converting flv to mp3 has become so easy in Linux within few minutes.

Installation of FFmpeg on Debian OR Ubuntu Linux

* root:~#apt-get install ffmpeg

Converting .flv to .mp3

* ffmpeg -i input_filename.flv -acodec copy output_filename.mp3

Good luck :)

Wednesday, January 6, 2010

How To Convert DMG To ISO on Mac OSX, Windows and Linux

Here are ways that you can convert dmg files to iso files on Mac OSX, Windows and Linux.

Before we start, let’s download a dmg file from the public domain. I found one on Apple’s article about The XMLHttpRequest Object website while I was learning Ajax and that can be downloaded from this link. This is just a 150KB dmg file and will be handy if you want to have something to test with while you’re following this tutorial.

How to convert dmg files to iso files on Mac

Method 1: Using the Mac terminal
1. Open a terminal window from Finder > Applications > Utilities > Terminal.

2. Assuming that you have a disk image called apple.dmg in the current directory, type

hdiutil convert apple.dmg -format UDTO -o apple.iso

3. This will actually create a file called image.iso.cdr in the current directory (even though we asked for the output to be image.iso). This file can be safely renamed to image.iso, copied to a Windows server or machine, and burned with your CD/DVD burner of choice.

Generally, the command hdiutil can be used this way:

hdiutil convert /path/to/filename.dmg -format UDTO -o /path/to/savefile.iso

Method 2: Using DMGConverter (freeware)
1. DMGConverter is a disk image (.dmg, .cdr, .iso) creation and conversion tool which is simple and easy to use. It is a very useful tool for the collective processing of more than one file and every folder, and it can deal with all the fundamental processing with the drag & drop of the file/folder. For Mac Only.

How to convert dmg files to iso files on Windows

This is for Windows users who might have downloaded a dgm file and wondering how to extract the content, or not even knowing how and what to do with the dgm file. I’ve been there at a certain stage. the sharewares mentioned are fully functional and allows you to use the “convert dmg to iso” function even when it’s not registered yet.

Method 1: Using MagicISO (shareware)
1. Download MagicISO, install and run program.

2. Click to open dmg file.

3. Click to open “Properties” dialogs.

4. Uncheck Apple HFS and Apple HFS+

5. Check “ISO 9660″ “Joliet” “UDF”

6. Click OK

7. Click to save as to iso image, or click to burn to CD/DVD without saving.

Method 2: Using UltraISO (shareware)
UltraISO basically does the same thing, but it can save you time from doing step 3 to 6 compared to method 1.

Alternative Solutions: dmg2iso (freeware) and isobuster (shareware)
I’ve heard and read that some people had been able to convert dmg files into iso files using dmg2iso (freeware). I’ve tried dmg2iso, converted my dmg file to iso without problem, but the converted iso file is corrupted and can’t be open by any tools (Daemon Tools, Alcohol, MagicISO, UltraISO and ISOBuster) that I’ve tested. It might work for you, but no guarantees.

ISOBuster is pretty similar to MagicISO and UltraISO. But too bad that the function to “convert dmg to iso” is restricted and won’t be functional until you buy the software.

How to convert dmg files to iso files On Linux

Free open-source app AcetoneISO provides a great deal of disc image manipulation tools not found in the Gnome desktop. It can mount/unmount a variety of image formats (ISO, DMG, MDF, NRG, BIN, NRG), convert images, create, encrypt, and decrypt ISOs, play DVDs (with the required codecs installed), and much more. It is particularly useful for mounting proprietary formats found in Windows and Mac boot discs. AcetoneISO is a one-stop-shop for all of your CD/DVD image manipulation needs, and is a free download for Linux only. This works on all famous linux distro such as Ubuntu, SUSE, Fedora, Mandrake, and Redhat.

So there you have it, and this should get you covered no matter what operating system you’re using.

Monday, November 17, 2008

Linux Create / convert AVI file to DVD format ~ Create video DVDs

Create DVD from command line

Following tools get installed with devede:

  1. mencoder : MPlayer’s Movie Encoder) is a simple movie encoder
  2. ffmpeg : FFmpeg video converter
  3. dvdauthor : assembles multiple mpeg program streams into a suitable DVD filesystem

So if you are a pro command line user, type the following commands to convert file1.avi fille2.avi to DVD format (if you are not comfortable with command line use devede GUI software and just skip following commands) :


$ cat file1.avi file2.avi > ccmovie.avi


Now run movie encoder to create out.avi from ccmovie.avi (option -ovc and -oac sets no encoding, just streamcopy)


$ mencoder -o out.avi -noidx -oac copy -ovc copy ccmovie.avi


Next run FFmpeg video converter to set aspect ratio, ntsc dvd television standard etc:


$ ffmpeg -i out.avi -y -target ntsc-dvd -sameq -aspect 16:9 out.mpg


At a high level, a DVD is a collection of menus and titles. Conceptually, a menu contains buttons which can be assigned actions and provides a list of choices to the end user, while a title contains the main content of the DVD. However, in reality many of the features available in menus (including buttons, pausing, and looping) are also available in titles. Use dvdauthor assembles multiple mpeg program streams into a suitable DVD filesystem. You should see DVD filesytem in dvd directory:


$ dvdauthor --title -o dvd -f out.mpg


Creates the table of contents file instead of a titleset:

$ dvdauthor -o dvd -T


Create dvd.iso:

$ mkisofs -dvd-video -o dvd.iso dvd/


Burn dvd.iso to DVD disk:



$
growisofs -dvd-compat -dvd-video -speed=4 -Z /dev/dvdrw=dvd.iso

HOWTO Convert video files

Introduction

There are many good reasons to convert video files you made yourself - or video files forwarded to you which you plan to distribute.

Good reasons to change a video file can be:

  • Playability
  • Size

This howto will to introduce to you some of the basic commands to use the most common Linux command-line program to convert video files from one format to another.

The file-size

Size is important, a videofile reduced by 100 MB will save you 100 GB of bandwidth if 1000 people download it; obviously the reduction of 100 MB pr. file will save you 1 GB of harddrive space if you host 10 video-files on a web-server.

Thus; You will likely want files to be as small as possible without reducing the video quality

Playability

There is no point in sending someone a video file if they can not play it. The most common media formats on the Internet today are divx and xvid.

There is a myth among Windows-users that .wmv (Windows Media Video) is some kind of standard. However, this format is extremely poor and limited to users of that OS.

Basics

Mencoder:

input_filename.mpg
-ovc codec for video output
-oac codec for audio output
-o output_filename.avi


$ mencoder -ovc lavc -oac lavc -o


Transcode:

-i input_filename.mpg

-y codec for audio/video output
-o output_filename.avi


$ transcode -i movie.mpg -o movie.avi -y divx


These are just the basics. There are many more advanced options for choosing codecs, bitrate and so on for both these tools. dad

XviD Encoding

Using MPlayer (mencoder)

You can encode XviD using one or two passes of the original file. You will get better quality if you use two-pass encoding, but does take longer to encode the video.

One-Pass Encoding

You can only set the bitrate or fixed_quant using one-pass encoding. You can only choose bitrate if you do two-pass encoding.

You must set one of these when encoding XviD using mencoder.

By setting bitrate

  • Using bitrate will encode the video to a constant bitrate (CBR).
  • Set bitrate=
  • Higher = better quality with larger files, and
  • lower = less quality with smaller files.
  • A bitrate of 800 will give you near DVD quality when encoding hi-quality video like a DVD disc.
  • VCD quality is around 400-500.
  • Internet streaming quality is generally around 80-150.
  • Mencoder's default bitrate is 687 kbits/s.
  • You need about ~800kb/s to get high quality on a 720x480 sized movie.

Encoding example by setting the bitrate:



$ mencoder -ovc xvid -oac mp3lame -xvidencopts bitrate=687 -o


Setting the audio bitrate

You may also want to change the audio bitrate for the audio encoded using mp3lame when you are making a XviD file with the goal of making a small file using -lameopts abr:br=. For example, an audio bitrate of 92 (-lameopts abr:br=92) will do nicely for a video bitrate of 150.



$ mencoder \
-ovc xvid \
-oac mp3lame \
-lameopts abr:br=92 \
-xvidencopts bitrate=150 \
-o


By bitrate calculated by a fixed file-size

You can set the filesize you want in KiloBytes in order to make mencoder calculate the bitrate for you. This can be done by setting a "negative" bitrate, bitrate=-700000 will give you a movie file which fits nicely on a CD.



$ mencoder -ovc xvid -oac mp3lame -xvidencopts bitrate=-700000 -o


By setting a fixed quality

fixed_quant can also be used when doing one-pass encoding.

  • fixed_quant=<1-31> specifies what "quality level" you want and will make mencoder automatically try to obtain the best quality/size ratio.
  • 1 is the highest quality, and will result in very large file if you use it.
  • 31 is the lowest, and the video will look very poor.
  • 4 and 5 are good setting for high-quality video. 1, 2 and 3 will give you very little improvement compared to 4, but give you way bigger files.(example:1 is 20mb if 4 is 5mb)


$ mencoder -ovc xvid -oac mp3lame -xvidencopts fixed_quant=4 -o


Two-Pass Encoding


$ nice -n 19 mencoder file.wmx -ofps 23.976 -oac mp3lame -lameopts abr:br=92 -ovc xvid -xvidencopts pass=2:bitrate=150 -o audiofix-150bit-xvid.avi



Windows Media files (.wmv/.asf/.wmx)

mencoder can convert wmv files. However, it seems that files created with mencoder from .wmv can not be played in many mediaplayers, namely xine. Adding -ofps 23.976 to the command-line makes files made with mencoder from .wmv play in xine.



$ mencoder infile.wmv -ofps 23.976 -ovc lavc -oac copy -o outfile.avi


xvid from .wmv or .wmx, using two-pass xvid encoding:



$ mencoder file.wmx \
-ofps 23.976 \
-oac mp3lame \
-ovc xvid \
-xvidencopts pass=1 -o /dev/null


$ mencoder file.wmx \
-ofps 23.976 \
-oac mp3lame \
-ovc xvid \
-xvidencopts pass=2:bitrate=250 \
-o 250bit-xvid.avi


The audio track on Windows Media files are sometimes low. You can use midentify to get information about a video file.



midentify file.wmx
ID_AUDIO_BITRATE=64064


With a bitrate of 64k, add -lameopts abr:br=64 when you encode a divx:



$ mencoder file.wmx -ofps 23.976 \
-oac mp3lame \
-ovc xvid \
-xvidencopts pass=1 \
-o /dev/null


$ mencoder file.wmx \
-ofps 23.976 \
-oac mp3lame \
-lameopts abr:br=64 \
-ovc xvid \
-xvidencopts pass=2:bitrate=250 \
-o 250bit-xvid.avi


Storage space is simply wasted if you encode the audio track on the new video file with a higher bitrate than the audio bitrate on the original track.


Convert a video to xVid format:



$ transcode -i movie.mpg -o movie.avi -y xvid


divx

Using transcode

-i ((input file) -o (output) -y (format - xvid/divx)



$ transcode -i movie.mpg -o movie.avi -y divx


Video-CD

Using FFMPEG

ffmpeg can make VCD mpeg video files using -target where the target can be "vcd", "svcd", "dvd", "dv", "pal-vcd", "ntsc-svcd". These switches will set the output format options (bitrate, codecs, buffer sizes) automatically.

The default vcd switch makes a PAL vcd.



$ ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg


A ntsc vcd:



$ ffmpeg -i myfile.avi -hq -target ntsc-vcd /tmp/vcd.mpg


Same example using same quality as source:



$ ffmpeg -i myfile.avi -sameq -target vcd /tmp/vcd.mpg



Converting a file for VCD format using a and b frames for MPEG 2:



$ ffmpeg -i myfile.avi -target ntsc-vcd -bf 2 /home/user/Video/vcd.mpg


Flash video (flv)

ffmpeg is the best choice for making flash video sites (.flv files). The syntax is simple:



ffmpeg -i inputfile.avi flashfile.flv


A parameter you likely want is -ab, audio bitrate. The default is 64, which may be fine for home videos, but is is too poor if you want to promote your local talented singer in a music video. Example:



ffmpeg -i musicvideo.mpg -ab 256 Som_du_visnar2.flv



Also note that .flv files do not support a samlerate of 48000, but it will convert using the original file's rate anyway and fault on exit. Flash video can have a sample rate of 44100, 22050 and 11025. Set the audio sampling frequency with -ar freq (usually -ar 44100) if the original file has something other than the valid rates.

Options you may want to consider:

-ab (number)     # audio bitrate
-ar freq # audio sampling frequency
-b video bitrate # defaults to 200, which is kind of low

You should also be aware of -sameq. This makes the video the same quality as the original, but tends to make flash video files twice the size as original mpeg's. This is bad when it comes to serving files, but it may be worth it if you really want your flash video to have high quality (and you have the bandwidth..).


DVD

Using FFMPEG

ffmpeg can also make DVD video files using -target, where the target can be "vcd", "svcd", "dvd", "dv", "pal-vcd", "ntsc-svcd".



ffmpeg -i myfile.avi -target ntsc-dvd /tmp/dvd.mpg

Convert avi to 3gp

Install ffmpeg:

$ sudo apt-get install ffmpeg


Connvert from avi to 3gp

$ ffmpeg -i movie.avi -s qcif -vcodec h263 -acodec mp3 -ac 1 -ar 8000 -r 25 -ab 32 -y movie.3gp


Convert from 3GP to AVI:

$ ffmpeg -i movie.3gp -f avi -vcodec xvid -acodec mp3 -ar 22050 movie.avi


Convert from MPG to 3GP:

$ ffmpeg -i movie.mpg -s qcif -vcodec h263 -acodec mp3 -ac 1 -ar 8000 -ab 32 -y movie.3gp

Convert from MPG to 3GP:

$ ffmpeg -i input -acodec amr_nb -ar 8000 -ac 1 -ab 12 -vcodec h263 -s qcif -r 10 -aspect 16:9 out.3gp