Video Conversion: Using a Graphical User Interface vs Command Line
Over the past decades, video creation and distribution have become available to everyone. Moving from analog to digital recording devices has multiplied possible ways to create and distribute video. Whether you want to share your creativity and your creations on a physical medium (DVD) or via streaming, you should take a look at this chapter.
The chapter focuses on the compression/decompression file formats used by different cameras, video players, and editing software. A large variety of formats exist, some are current and still being used, others might have become obsolete, and you may never have even heard of them before. Most major media companies are members of the MPEG Consortium, so you might be familiar with the different versions of the MPEG format. But it is easy to be confused - MP3 is not version 3 of MPEG, for example, but a subchapter called "layer 3" of the "MPEG 1" standard.
We compare and contrast two tools. One is called VLC, an open-source cross-platform multimedia player and framework, which can also stream audio and video in a number of formats. The second is FFmpeg, an open source cross-platform solution to record, convert and stream audio and video. While VLC has a graphical user interface (GUI), FFmpeg uses a command-line interface, i.e. a text-base interface where the users enters commands. As a developer, you are already familiar with text-based interfaces and can draw on this experience as you work with open video. If you have never used a command-line interface, this is your chance to try it out and find out more about the code work underlying file compression.
The first things to do is to analyse your footage. This process indicate some important things to consider.
- Is this the same size of picture, is this full HD, HD, SD, web size ?
- Is this the same aspect, is this 4:3, 16:9, 21:9... ?
- Is this the same frame rate, is this 24 images pers second, 25/s, 30/s, 60/s, 120/s... ?
- Is this the same process of compression for video or audio, is this format, MPEG version, AVI, MOV, Webm...?
- Is this drastic compression in consequence many informations are missing or a high quality compression ?
- An if you are an adept of speciale effect the depht color is a chart of quality ; 4.2.0, 4.2.2, 4.4.4 ?
- Is this the same ideas of arts, another footage for an artistic cohesion, i don't think that VLC and FFMPEG can help you... Sorry
They are all the basic questions that you have to know about your footage.
How to analyse your footage :
By detecting the codec, the size of your image, the frame rate, the depht of color, the bitrate, you can improve your understanding and critical vision of codec quality. There are so many fromats from diffrent types of hardware, software and Operating Systems, you eventually have to juggle different formats and codes and perhaps some more exotic types.
To answer at the differents questions about the quality of your footage, size, aspect, framerate... you can use VLC. Open your footage with this tools, or drag on drop it on VLC to read it.
To be informed about the informations that contains your file and go to the Menu/Tools/Codecs information.
As you can see at the screen capture above showing codecs information, this footage contains two codecs for the compression video and the other for the video. Two methods of compression because by their nature, light for images and sound for audio are differents in our cerebral process of perception. This two compression are synchronised in a container the format, named by the extension of the file name.
There are two kinds of containers those who incorporate only the audio and video flux and those who contains chapter for navigation, subtitles, multilanguage choice... for authoring DVD, BluRay, for this last containers please see the chapter Hands on - DVD. This last container is called a Wrapper.
You know probably this wrapper format : QuickTime, MKV from the opensource project Matroska, VOB for the standard version MPEG2 for DVD and MXF from the MPEG Consortium.
For the traditionnal containers, you know certainly the AVI file format and ASF from microsoft, MPEG1, MPEG2, MPEG4 or MP1, MP2, MP4 from the differents version of MPEG consortium, in generical termes MPEG, Mov from Apple qnd for the professionnals some of these : AVC-Intra and DVC-Pro from Panasonic, DV and XD-Cam from Sony...
So differents containers who in theory can encapsulated differents kinds of codecs audio and video. Before to see what is a codec and how does it works. We have to response at the principals questions listed in the introduction. In fact the codecs information of VLC give us the responses.
For this example ;
- The size of picture is this full HD : resolution by 1920x1080
- The aspect : information is missing, aaaaaargh !
- The frame rate : 30 images per second
- The type of compression for video is MPEG4-AVC layer 10 called H.264
- The type of compression for audio is MPEG4 layer 3 called AAC (Advanced Audio Codec)
- The quality of the compression defined by the bitrate : information is missing, aaaaaargh !
- The depht color is standart for the diffusion ; 4.2.0
- Artistic cohesion ? effectively, no informations.
As you can see VLC gives most informations that can help us to define the different footage. Now, take a look about FFMPEG. For this you need the Terminal or Konsole software, for that in Ubuntu plateform searche with tehe dashBoard the Terminal and open it. Then, you type in it FFMPEG to call the application and the command -i for input. Like this : ffmpeg -i and drag and drop you file media or indicate the location of your file media.
Now, we've got the same informations, but it's more precise, ffmpeg indicates the quality of compression for video 9414 kb/s and for audio 36 kb/s, the total for the footage is also indicated 9459 kb/s
It gives also the duration of the footage : 00:09:46.26 that you can read like this : 00 hour:09 mn:46 sec.26 pictures/30.
FFMpeg uses in fact three different timestamps in different bases in order to work.
- tbn = the time base in AVStream that has come from the container
- tbc = the time base in AVCodecContext for the codec used for a particular stream
- tbr = tbr is guessed from the video stream and is the value users want to see when they look for the video frame rate
The information about the aspect of the film is given by the DAR, in this case : 22/9.
The PAR indicate the pixel ratio. The pixel can have differents dimensions, if this dimension is different of 1/1, we speack about anamophic
Now with this two methods, you can classify your footage and have an approach of your flux of production before editing your video.
Transcoding with the preset MPEG-4
Current presets in descending order of speed are: ultrafast,superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. The default preset is medium. Ignore placebo as it is not useful You can see a list of current presets with -preset help, and what settings they apply with x264 --fullhelp.
You can optionally use -tune to change settings based upon the specifics of your input. Current tunings include: film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency. For example, if your input is animation then use the animation tuning, or if you want to preserve grain then use the grain tuning. If you are unsure of what to use or your input does not match any of tunings then omit the -tune option. You can see a list of current tunings with -tune help, and what settings they apply with x264 --fullhelp.
Another optional setting is -profile:v which will limit the output to a specific H.264 profile. This can generally be omitted unless the target device only supports a certain profile. Current profiles include: baseline, main, high, high10, high422, high444. Note that usage of -profile:v is incompatible with lossless encoding.
As a shortcut, you can also list all possible internal presets/tunes for FFmpeg by specifying no preset or tune option at all:
ffmpeg -i input -c:v libx264 -preset main -tune film dummy.mp4
Exchange with Apple Final Cut User
The ProRes codec is the product for the tools of editing video for the apple users. FFMPEG have some preset to share with them video files.
-vcodec prores
-acodec pcm_s24be
-vf setdar=4:3 ou 16:9 (Aspect)
-profile 0, 1, 2 ou 3
0 : ProRes Proxy
1 : ProRes LT
2 : ProRes 422 for SD (High Frequence)
3 : ProRes HQ for HD (Low Frequence)
ffmpeg -y -i '<inputfile.avi>' -vcodec prores -vf setdar=16:9 -profile 3 -acodec pcm_s24be '<outputfile.mov>'
Exchange with Avid user from Digidesign
The DNxHD codec is the product fort the tools of editing video for the Avid users. This is a simple command line that you can arrange if needed.
ffmpeg -y -i '<inputfile.avi>' -vcodec dnxhd -vb 185000k -acodec pcm_s16le '<outputfile.mov>'
You can add :
- To give interlaced video : -top 1 -flags +ilme+ildct
- To give dnxhd intraframes : -qscale 1 -qmin 1 -intra
Exchange with an uncompressed video file, RAW video file.
ffmpeg -y -i '<inputfile.avi>' -vcodec rawvideo -pix_fmt rgb24 -vtag 0x20776172 -acodec pcm_s16le '<outputfile.mov>'