-
Couldn't load subscription status.
- Fork 2
Home
- Index
- Video Filters
- Video Formats, Codecs & Encoders
- Video Encoding
- Video Cut/Clips
- Video Concatenation
- Miscellaneous
Video filters allow for visual modification of the video stream, and it requires re-encoding it (lossy output). While it's possible to perform some of these operations losslessly through metadata manipulation, it's currenty not supported.
There are several video filters available:
- Mirror the video image horizontally and/or vertically.
Rotate (Transpose Filter)
- Change the orientation of the video image.
Crop (Crop Filter)
- Cuts the selected screen area of the video canvas, using the cropped dimensions as the resolution of the output video.
Scale (Scale Filter)
- Change the output video resolution by arbitrary values, integer scaling factors or aspect ratio. You can also choose the scaling algorithm.
Even if lossless filtering through metadata is implemented in the future, not all formats and video players support those features, and compatibility could be very limited. It's recommended to just accept the unperceivable quality loss of re-encoding.
Video files are structured in two layers:
Codec (Video/Audio Streams)
- It includes the actual video/audio stream data, generated by a determined encoder which describes a specific compression syntax.
Format (Container)
- It encapsulates multiple of these encoded data streams into a single file, allowing for better playback manipulation and storage convenience.
Most, if not all of the common, modern file formats/containers are supported, each with its subset of codecs and encoders.
To learn more about video formats and codecs, see this Super User post by Werner Robitza (slhck).
Input formats are limited by the native HTML video player in Chromium/Electron. In situations where a format is incompatible, a temporal, lower quality version of the input video file will be created. Listed below are the natively supported containers:
Output formats have no limits. While there are only a handful of them available on the list in the export dialog (the most common/modern), you can always choose a specific file format and codec by manually editing the final output command.
Similarly to containers, supported video codecs are also limited by the native HTML video player in Chromium/Electron, although it's safe to assume that if the format is supported, most, if not all of its compatible codecs are supported as well.
h264 | H.264 / AVC / MPEG-4 Part 10
- The most common codec used everywhere. Provides good visual quality at a standard bitrate level. Has very fast encoding/decoding speeds and playback compatibility is universal.
- Encoders: libx264, libx264rgb, h264_v4l2m2m
hevc | H.265 / HEVC (High Efficiency Video Coding)
- High compression efficiency without loss of quality. Reduces stream bitrate by using bigger data blocks and more sophisticated algorithms. Compared to H.264, it can reduce the file size down to 50% at no quality cost. Video processing can take a considerably longer amount of time.
- Encoders: libx265, hevc_v4l2m2m
vp9 | Google VP9
- High compression level and great playback compatibility, mostly on web browsers and services such as YouTube. It can be compared with HEVC in terms of compression efficiency and performance, but with the advantage of having better support across the board.
- Encoders: libvpx-vp9
av1 | Alliance for Open Media AV1
- Successor to VP9, aims to be the same but better, with greater focus on high resolution videos and online streaming. Produces the highest bitrate savings, but encoding performance is terrible compared with both VP9 and HEVC.
- Encoders: libaom-av1, libsvtav1, librav1e
While formats/codecs/encoders not natively supported by Electron/Chromium's video player can still be manipulated with Viridian, there are some limitations to keep in mind.
First of all, not all codecs have encoders available. This is a FFmpeg limitation, so there's nothing I can do about it. In such cases where encoding is needed, the only solution is to transcode to another format/codec (defaults to mp4/h264). Alternatively, if the codec in use does support encoding, but it's not available through the user interface, you can always modify the output command manually with the desired encoder and options. You can check codec compatibility support in the export dialog.
For exclusively lossless operations (like video cut/clips), the video format is maintained, so you should not experience any of the issues mentioned above.
Video encoders use compression techniques to reduce redundant data while retaining as much quality as possible. For this, encoders use rate control modes, which decide how many bits will be used for each frame during the compression process. This process takes in account the differences between frames to compress the data, so the amount of motion a video has impacts directly into the compression rate and quality.
Control rates determine the amount of bits used per frame, resulting in a bitrate under a certain unit of time, usually measured in seconds. Encoders can use rate modes that process the video frames in different ways: through variable bitrate or constant bitrate.
Depending on the encoder and control rate mode selected, different options can be adjusted for the compression process:
Quality
- Range of values that define the quality level of the output file. Lower values mean better quality but bigger file size. The default value is usually good enough to maintain a similar level of quality to the input video.
- Defines the ratio between compression rate (image quality) and encoding speed. For h26x encoders, a slower preset will achieve better quality. Default presets should be good enough to maintain a similar level of quality to the input video.
Bitrate
- Defines a specific target bitrate to meet. Its usage depends on the control rate mode selected. When required, the original bitrate of the input file will be used by default, although this will result on a lower image quality.
Is important to mention that bitrate is not everything, but just a way to measure the compression level and quality (to some extent) produced by the encoder. This means that it's not recommended to force a specific bitrate value, but instead use the CRF mode when available, and just let the encoders do their thing. Since video encoding is not an exact science, manually manipulating the output bitrate could produce a big loss in quality and an inefficient use of space if you don't know what you're doing, and should only be used if you really need to reach a specific target bitrate or file size.
Variable bitrate encoding means that the bitrate is, well, variable. It allows for a better compression of both output size and quality, as it can use as little or many bits as it needs to compress a frame, delivering the best size-quality ratio possible.
There are several control rate modes that use variable bitrate:
CRF (Constant Rate Factor)
- The default control rate mode, ensures constant quality throughout the encoding process. It only requires a value to indicate the quality level, as the encoder takes care of the rest.
VBV (Constrained Encoding)
- Limits both the maximum and minimum bitrate values. Provides similar results to constant bitrate, although it's still technically variable.
VBV-2 (2-Pass Constrained Encoding)
- Encodes with the VBV mode twice, ensuring a better output quality.
ABR (Average Bitrate)
- Attempts to reach the specified bitrate. Provides similar results to constant bitrate, although it's still technically variable.
ABR-2 (2-Pass Average Bitrate)
- Encodes with the ABR mode twice, ensuring a better output quality.
For the ABR and VBV modes, since the encoder doesn't know what's ahead of time, it has to guess how to achieve the desired bitrate, resulting in huge quality variations throught the video. To (kind of) solve this issue, it's possible the use a 2-pass technique, where the first will do an initial encoding analysis, carrying this information over the second, which will do the proper encoding. If you want to use these modes, it's recommended to use the 2-pass variations instead.
Constant bitrate encoding attempts to maintain a consistent bitrate level across the entire video, which usually results not only in a waste of space, but lower quality as well. While it has its uses, it should not be used by normal users, and it's only available for completeness sake.
To learn more about video encoding and control rate modes, check the following posts by Werner Robitza (slhck), as well as FFmpeg's encoding guide:
Due to the way video encoding works, splitting/cutting videos is not a simple task. Video encoders use key/i-frames as part of their compression/decompression process, limiting what we can do in terms of video manipulation and editing.
Keyframes are also very inconsistent, since they depend on the contents of the video stream, and although specific intervals can be forced, similarly to bitrate, the video quality could be decreased drastically.
There are several ways available to clip videos:
Smart (Lossy + Lossless, Accurate, Fast)
- Clip exactly where you indicated. Mixes cutting losslessly when possible (whole keyframes), and transcoding when not (middle of keyframe).
Lossy (On exact frame, Accurate, Slow)**
- Clip exactly where you indicated, although it requires transcoding the entire video stream.
Lossless (Normal, Inaccurate, Very Fast)
- Use indicated clip times, and let FFmpeg automatically decide where to cut. Slightly inaccurate timing, can cause frames dropping during playback and desynchronization when concatenating files.
Lossless (On key/i-frame, Very Inaccurate, Very Fast)
- Manually force the cut on the previous nearest keyframe. More inaccurate results to the desired starting clip time, but ensures a smooth play.
Inaccuracy level is relative, as it really depends on each video and where you want to cut. If using a lossless method, remember to use the keyframe guides in the progress bar to ensure a clean cut.
Sometimes cut end points can be frame-inaccurate, mostly on lossless methods. For those situations where you need frame-level of precision, shift the clip's end time accordingly, or use the lossy mode for better results.
When using lossy methods, the default encoding settings will be applied, which are the recommended and most optimal. You can always modify this behavior by manually editing the export command.
Usually there's a single layer of encoding, which can be either lossless or lossy depending on whether you've applied any filters or not (crop, rotation, scaling, etc.), or if you manually selected a specific encoder.
But when working with clips, an extra layer of encoding is added first to cut these segments, which then will be either exported individually or merged together, using one of the methods described below.
This is important to keep in mind while cutting, as if you select a lossless method, but you are also using filters, the final output won't be truly lossless regardless of the mode you chose. The same way goes for a lossy cut where, if using filters, you'll be effectively re-encoding the video twice.
It's recommended to avoid using filters for a lossless output, and to use a lossless (or smart) cut method when using filters, minimizing the impact on the video quality.
Several video files can be concatenated/merged together using different methods depending on the video stream properties:
Lossless (Concatenation Demuxer, Fast)
- Lossless video stream concatenation mode used automatically when all files share the same codec, timebase, width and height. Files using different container formats may not be able to use this mode.
Lossy (Concatenation Filter, Slow)
- Lossy video stream concatenation mode used as a fallback when the files don't share the same codec and/or timebase, but have common width and height values. Forces video stream re-encoding.
Concatenation won't be possible if a video doesn't share any of these properties with an already opened file. File-level concatenation (protocol) is not supported, as it's only available for a very small amount of old and deprecated formats.
File concatenation is enabled automatically when multiple files are open. Otherwise, edit each file separatedly. This behavior can only be changed when working with clips.
By default, all opened files are concatenated into a single output file, and if there are any clips made, those will be cut first before the merging process.
When clips are available, it's possible to change this behavior and select between different concatenation modes:
Merge Everything (Concatenation Enabled)
- Merges all files and clips into a single output file. The proper encoding is done after the cut/concatenation process (2 encoding layers).
Individual Clips (Concatenation Disabled)
- Exports all available clips into their own output files. The proper encoding and cut process are done together for each clip (1 encoding layer).
When video concatenation is disabled, each clip will have only one phase of encoding, meaning that the encoder settings will collide with the cut encoding settings. For this reason, the encoder settings will take priority over. Remember that this only affects the encoding aspect, but the cut technique is otherwise retained (smart and keyframe cut).
Audio streams cannot be modified (unless done manually). When exporting a video file, the audio stream will be either copied or removed.
Hardware-accelerated encoders are not supported by default due to several factors:
- FFmpeg needs to be built with support for them.
- They are very system dependant, and usually requires to install custom third-party/proprietary software.
- It'd be a mess to implement, from the design and programming perspective.
Still, you can supply you own FFmpeg build if needed and manually edit the output commands accordingly.
Default video thumbnail generation methods in FFmpeg are very slow, so a combination of individual seeks are used instead, greatly improving the processing speed, although it can still take several seconds to finish, so thumbnails are disabled by default.
Depending on the length of the video, predefined intervals for thumbnail generation are used:
- < 30 seconds: Every 2 seconds, 15 thumbnails max.
- < 1 minute: Every 4 seconds, 15 thumbnails max.
- < 5 minutes: Every 10 seconds, 30 thumbnails max.
- < 10 minutes: Every 20 seconds, 30 thumbnails max.
- < 30 minutes: Every 30 seconds, 60 thumbnails max.
- > 30 minutes: Every 60 seconds.
Thumbnails get cached to avoid repeating the process everytime the same file is opened. They don't take much disk space due to their low resolution, but if you want, you can clear the cache either manually or from the settings.