Home > Streaming > Encoding a video in H264 format and use MP4 as container

Encoding a video in H264 format and use MP4 as container

I have used ffmpeg to encode the input video into H264 format and finally used MP4 as container. The following command line I have used for encoding.

#!/bin/bash
outfile=”video.mp4″
options=”-vcodec libx264 -b 512k -flags +loop+mv4 -cmp 256 \
-partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8 \
-me_method hex -subq 7 -trellis 1 -refs 5 -bf 3 \
-flags2 +bpyramid+wpred+mixed_refs+dct8x8 -coder 1 -me_range 16 \
-g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10\
-qmax 51 -qdiff 4″

ffmpeg -y -i “$1” -an -pass 1 -threads 2 $options “$outfile”

ffmpeg -y -i “$1” -acodec libfaac -ar 44100 -ab 96k -pass 2 -threads 2 $options “$outfile”

Advertisements
Categories: Streaming Tags: , , ,
  1. Arim
    March 15, 2011 at 8:29 am

    Now you could use profiles.
    ffmpeg -y -i $1 -vcodec libx264 -vpre libx264-hq $outfile

    This approach makes it easier for you to control all the parameters. You do not have to be encoding expert anymore to produce good quality movies.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: