Festus Tamakloe
Festus Tamakloe

Reputation: 11310

Convert video to FLV using FFMPEG

I come across this code in one php script that i bought last time to convert video. The script is running on Ubuntu 12.04

-i $file_source -b 9600k -aspect 16:9 -acodec aac -strict experimental -ab 128k -ar 22050 $file_dest" 

That is the full meaning of elements/attributes and what could be the alternative?

Thanks for your help

Upvotes: 0

Views: 2026

Answers (2)

Rajesh Ujade
Rajesh Ujade

Reputation: 2735

You can use below command to convert videos using ffmpeg

Required Codec:

  1. libmp3lame - acodec
  2. libfaac - acodec
  3. libvorbis - acodec
  4. libx264 - vcodec
  5. libtheora - vcodec
  6. libvpx - vcodec
  7. FFMPEG build Version - ffmpeg version N-54207-ge59fb3f

Commands As Below -

  1. Convert to flv -

    $file_source = "/tmp/test.mp4";
    $file_dest = "/tmp/test.flv";
    ffmpeg -i $file_source -pass 1 -vcodec libx264 -preset slower -b 512k -bt 512k -threads 0 -s 640x360 -aspect 16:9 -acodec libmp3lame -ar 44100 -ab 32  -f flv -y $file_dest
    
  2. Convert to mp4 to support HTML5 -

    $file_source = "/tmp/test.flv";
    $file_dest = "/tmp/test.mp4";
    ffmpeg -y -i $file_source -vcodec libx264 -q:v 1 -preset slower -profile:v baseline -level 30 -crf 30 -vf scale="480:360" -aspect 16:9 -s 640x360 -acodec libfaac -ab 128k -ac 2 -coder ac -me_range 16 -subq 5 -sc_threshold 40 -partitions +parti4x4+partp8x8+partb8x8 -i_qfactor 0.71 -keyint_min 25 -b_strategy 1 -g 250 -r 20 -f mp4 $file_dest
    
  3. Convert to webm to support HTML5 -

    $file_source = "/tmp/test.mp4";
    $file_dest = "/tmp/test.webm";
    ffmpeg -y -i $file_source -vcodec libvpx -b:v 480k -bt 480k -preset slower -level 30 -crf 30 -vf scale="480:360" -aspect 16:9 -s 640x360 -acodec libvorbis -ab 128k -ac 2 -coder ac -me_range 16 -subq 5 -sc_threshold 40 -partitions +parti4x4+partp8x8+partb8x8 -i_qfactor 0.71 -keyint_min 25 -b_strategy 1 -g 250 -r 20 -f webm $file_dest
    
  4. Convert to ogv to support HTML5-

    $file_source = "/tmp/test.mp4";
    $file_dest = "/tmp/test.ogv";
    ffmpeg -y -i $file_source -vcodec libtheora -b:v 480k -bt 480k -preset slower -level 30 -crf 30 -vf scale="480:360" -aspect 16:9 -s 640x360 -acodec libvorbis -ab 128k -ac 2 -coder ac -me_range 16 -subq 5 -sc_threshold 40 -partitions +parti4x4+partp8x8+partb8x8 -i_qfactor 0.71 -keyint_min 25 -b_strategy 1 -g 250 -r 20 -f ogg $file_dest;
    

For more information about ogg,mp4,web check link html5-videos-things-you-need-to-know and easyhtml5video

Upvotes: 1

VC.One
VC.One

Reputation: 15871

This is a command line instruction for FFMPEG
You can read the documentation for alternative options at: FFMPEG Docs

Anyways just to explain..

-i $file_source -b 9600k -aspect 16:9 -acodec aac -strict experimental -ab 128k -ar 22050 $file_dest

Where..
-i $file_source is your input file (any media type)

-b 9600k is video bitrate

-aspect 16:9 is widescreen

-acodec aac -strict experimental is using AAC codec (is experimental codec so use strict to force usage anyway)

-ab 128k is audio bitrate 128kb/s

-ar 22050 is audio samplerate of 22.05 khz

$file_dest the output filename (with extension so FFMPEG knows your preferred output format

Upvotes: 1

Related Questions