Using ffmpeg to convert video file


Using FFmpeg to convert video file


Table of Contents

  • 1 Some basic concept about digital video file
  • 2 what is FFmpeg?
  • 3 how FFmpeg works inside?
  • 4 convert MOV file format into mp4 format
  • 5 what's more

1 Some basic concept about digital video file

There are many kinds of Video file format including MOV, mp4, Flv, AVI, which act as the containers in which video data is stored. And Video data is encoded by codecs.
In other words, Video file format is just a container, and Video codecs are used to encode or compress the video data. The anatomy of video file including following parts:
  • A container type: AVI, MOV, mp4, FLV…
  • The video and audio signal: the data stored in the container.
  • Codec: Codec refer to the software that is used to encode and decode the video signal
The characteristics of a video signal:
  • Frame size: the pixel dimension of the frame
  • The Aspect ratio: the ratio of width to height
  • Frame rate: the rate of frames per second
  • Bitrate: the amount of data used to describe the signal per second
  • The audio sample rate

2 what is FFmpeg?

FFmpeg is an open source project provided a video converter tool. It can be used to change the video file's file type, which means to change video file's container, and to change video data's encoding format, which means to encode video data with another codec. It also can change video's quality by change video's characteristics.

3 how FFmpeg works inside?


4 convert MOV file format into mp4 format

I make some video by my canon camera, whose default video file format is MOV with high resolution of 1080P, which consume a lot my disk space. So I use the following command to convert 1080P featured MOV style file into 720P featured mp4 style file.

ffmpeg -i MVI_0416.MOV -f mp4 -strict -2 -qscale 0 -s hd720 MVI_0416.mp4

5 what's more

  • Use FFmpeg as Video and Audio grabbing
In my PC, I can not grab Audio from the Alsa device, the problem may be located in PulseAudio. So I only grab the video from the video4linux2 device by the following code.

ffmpeg -f video4linux2 -i /dev/video0 ./out.mpg
  • Use FFmpeg as X11 grabbing
ffmpeg -f x11grab -r 25 -i :0.0 ./out.mpg

Comments

Popular posts from this blog

Bluedroid stack in android

How to setup a NAT server?

Network programming in elisp