Compared to the conventional tapes, they are convenient to store, share and highly cost effective. The A/V data is stored in files with certain extensions. Example, mov, mp3, mpg, mp4, mkv etc.
The raw media files are often considered good for video editing as they retain unaltered data from camera/microphone. However, the raw size could be in order of hundreds of GB for just an hour of 1080i video. This isn’t suitable for transmission and storage. Hence, a compression on original data is applied according to the production house requirements. Most studio however prefer lossless compression.
The formats are often the extensions of the file, technically may be called as containers. We will use the term container henceforth. A container is a software wrapper which carries encoded A/V and its metadata.
(Coder-Decoder) The compression of the data is crucial. There are several algorithms implemented to optimize the encoding and decoding process. However, there are known tradeoffs, such as, a highly compressed file may require higher CPU while decoding, and so on. The selection of codecs is a thoughtful process based on factors such as end user, bandwidth, quality, cost etc.
Few popular codecs are h264, vp8, lame, DivX etc. Find more at this wiki page.
MP4 container holding audio, video, and metadata image source
A simple yet powerful cross platform, cross architecture, command line tool to record, convert and stream audio and video data. There are several projects which use FFmpeg in backend, an extensive list can be found here.
To check the bit rate, codec, frame rate info
ffmpeg -i sample-video.mp4
Size reduction by restricting bandwidth
ffmpeg -i sample-video.mp4 -vb 500k -c:a copy reduced_vb.mp4
Size reduction by scaling down
ffmpeg -i sample-video.mp4 -c:a copy -vf scale=640:360 reduced_scale.mp4
It is easier to concatenate less compressed files, H.264 and modern codecs are highly compact and complicated, however, it is possible to concantinate them using advance options in FFmpeg. We will use the more widely used approach where we will convert complex codecs to a simpler one’s.
Let us convert sample-video.mp4 to sample-video.mpg
ffmpeg -i sample-video.mp4 -q:v 2 sample-video.mpg
Please note, we haven’t mentioned target codec, ffmpeg choose the best codec for the mpg container. Once converted we can verify
ffmpeg -i sample-video.mpg
By the way, the -q:v 2 factor is chosen for best results. It can also be done with -vb flag. Also, note the size and bandwidth for the mpg file due to its poor compression.
Let us join videos
ffmpeg -i "concat:sample-video.mpg|sample-video.mpg" -c copy output.mpg
More on concatenation at https://trac.ffmpeg.org/wiki/Concatenate
Often we need to extract audio/video from a given media file, which is technically the demuxing process, and ofcourse, the reverse of it is muxing.
Let us demux our mpg file. The -an flag disable audio in output. Let us obtain only video component
ffmpeg -i sample-video.mpg -c:v copy -an video.mpg
To extract audio only
ffmpeg -i sample-video.mpg -c:a copy -vn audio.mpg
Now we can check the properties of both extracted files.
Let us join them back or mux them into mpg:
ffmpeg -i video.mpg -i audio.mpg -c copy output.mpg
We often shoot handheld videos with smartphones, despite of several on camera stabilizations, we may not get the desired results. The videostab filter of FFmpeg does the job neatly.
A stabilization act is a 2 step process.
Let us first detect shakiness
ffmpeg -i shaky-video.mkv -vf vidstabdetect=show=1 dummy.mkv
The dummy.mkv shows the points where the filter has found uneven movements. The above process also creates a text file with coordinates and filter parameters.
To remove the shakes, let us apply the filter
ffmpeg -y -i shaky-video.mkv -vf vidstabtransform -c:a copy stabilized.mkv
Explore more at https://github.com/georgmartius/vid.stab
It is a simple straight forward step with FFmpeg:
ffmpeg -ss 00:00:00.00 -i sample-video.mkv -t 00:00:05.00 -acodec copy -vcodec copy 5sec-cut.mkv
It is again a straight forward step
ffmpeg -i sample-video.mp4 -af "volume=enable='between(t,1,3)':volume=0 mute-1-3s.mp4
Similar to video stabilization, noise reduction is also a 2 step process.
Let us first extract audio from video
ffmpeg -i noisy-video.ogv -vn noisy-audio.ogg
Now, let us obtain the noise profile
sox noisy-audio.ogg -n trim 0 1 noiseprof myprofile
This will analyze audio from 0 to 1 second and create a noise profile.
To reduce noise to entire audio, we need to apply sox again with our detected noise profile.
sox noisy-audio.ogg noisefree.ogg noisered myprofile 0.2
The 0.2 value is for moderate noise reduction in a scale of 0 to 1.
Now, we can mux the audio-video files
ffmpeg -i noisefree.ogg -i noisy-video.ogv noisefree.ogv
Audacity is a free, easy-to-use, cross platform, cross architecture, multi-track audio editor.
The UI is simple and easy to navigate.
Audacity UI source image
Noise reduction is fairly simple due to visual navigation. However, it is still a 2 step process.
Let us begin with getting the noise profile. Import the audio to timeline, select a portion of noise.
Now, go to Menu -> Effect -> Noise Reduction and select get Get Noise Profile
You may adjust Noise Reduction(dB) to control the noise reduction factor, where 0 being no reduction and 48 is the maximum on the scale.
Now, select the portion of video you want to reduce noise, or else you may do a cntl+a to select the entire audio strip for noise reduction.
The noise reduction is complete. You may select File -> Export Audio to save the modifications in your desired format.
There are several effects under Menu -> Effect to enhance our audio.
For vocals, I usually prefer the following.
Blender is the free and open source 3D creation suite. It supports the entirety of the 3D pipeline—modeling, rigging, animation, simulation, rendering, compositing and motion tracking, even video editing and game creation.
Default video editing screen layout source
Press shift a to add a media file to Sequence editor
Once added blender will demux and show audio and video strips separately. We may select each strip Right click or RMB and press n by keeping the cursor inside the VSE to access the properties and minor adjustments.
The Left click on the strip will bring the green color cursor to the position we want.
With curson on VSE press alt a to toggle play and pause.
Right click and select the strip and then left click to bring the cursor the cut location. Enter k to cut at the location.
Select the strip and press x to delete
Select one or more strips by holding shift key and RMB. Select g to group them together and move the cursor to rearrange the strip.
Select the video strip and press shift a inside VSE to select Transfor Effect strip. Tweak the various transformations allowed by this strip by accessing the properties window on right hand side.
Press shift a by keeping the cursor inside VSE and select text Effect strip.
Change one of the window to Properties and modify your export settings.