Help:Converting video

From Porn Base Central, the free encyclopedia of gay porn
Jump to navigation Jump to search
Shortcuts:

Welcome to the PBC Help guide on converting video files for upload. Supported formats: AV1, VP9, VP8, or Ogg Theora. Most videos available online or produced by recording devices are in other formats, which is why conversion is needed. Understanding these codecs and their compatibility with various containers is crucial for a smooth upload process. Let's dive into the details of each codec to help you choose the best format for your videos.

Codecs and Container Compatibility

  • AV1 (preferred): The AOMedia Video 1 (AV1) codec is designed for internet video streaming. It's known for its high efficiency in compressing video without compromising quality. AV1 is compatible with the WebM container, making it an excellent choice for web-based projects aiming for high-quality video with lower bandwidth usage.
    • As the most advanced codec among the options, AV1 is known for its exceptional compression efficiency and video quality. However, it is also the most resource-intensive, making file conversion challenging without hardware support. Since 2022, hardware encoding support for AV1 has been introduced in Nvidia's 40 series GPUs based on the Ada architecture, AMD's RX 7000 series GPUs, and Intel's Arc series GPUs. Among these, converting on Intel Arc GPUs may offer the best performance.
  • VP9 (preferred): Developed by Google, the VP9 codec offers a balance between video quality and file size, making it ideal for online video platforms. It's commonly used in WebM containers and is supported by major browsers and platforms for seamless streaming.
    • While VP9 is also a heavyweight codec, it is less demanding than AV1, making it possible to achieve acceptable conversion times even without hardware support. VP9 strikes a balance between compression efficiency and computational requirements, making it a suitable choice for projects that aim for high video quality without the need for the latest hardware acceleration.
  • VP8: Predecessor to VP9, VP8 is also widely used for web videos. While it offers less compression efficiency compared to VP9 and AV1, it remains a viable option for projects with less stringent quality requirements. VP8 videos are typically housed in WebM containers.
    • Known for its faster conversion times compared to its successors, VP8 offers a compromise between quality and encoding speed. Although it delivers lower compression efficiency and video quality than AV1 and VP9, VP8 remains a practical choice for projects with less stringent quality requirements or for creators working with older hardware. Its wider compatibility and ease of encoding make it accessible for a broad range of applications.
  • Theora: As an early open-source video codec, Theora is less efficient than AV1, VP9, and VP8 but still provides an option for projects prioritizing open standards and compatibility. Theora videos are encapsulated in OGG/OGV containers, suitable for a variety of multimedia applications.
    • Theora stands out for its commitment to open standards and broad compatibility. While it doesn't match the compression efficiency or video quality of AV1 or VP9, Ogg Theora is significantly less resource-intensive, offering reasonable conversion times without the need for specialized hardware. This codec is ideal for projects that prioritize open-source solutions and need to be accessible across a variety of platforms without the latest in hardware acceleration. Although it may not be the first choice for high-definition video, it's an excellent option for ensuring your content is easily distributable and viewable on older or less capable devices.

Converting video is a subject that still needs research and testing.

It should be noted that the process can get technically complicated, especially when it comes to advanced settings and command line interfaces, yet it's possible to convert with user-friendly applications with default configuration.

General conversion tips

  • When uploading a video, TimedMediaHandler will convert it into different versions, so you don’t need to provide separate versions for people on slow Internet connections. It is strongly recommended to upload your video with the best quality (bit rate and frame size) possible.
  • WebM is the preferred format, but please do not convert from Ogg Theora unnecessarily, as it is also supported.
  • Some of the tools listed here for converting to Theora output the converted file with a .ogg filename extension. Rename the file to a .ogv extension, as this is now the preferred extension. Pay attention to repeat the .ogv file type during upload; otherwise it (wrongly) defaults to .ogg again...
  • .ogx for MIME type application/ogg is not yet widely supported; you can use .ogg for Theora video with FLAC instead of Vorbis audio.

Online conversion tools

Shortcut:

CloudConvert.com

CloudConvert.com supports AV1, VP9, VP8.

Video-converter.com

Video-converter.com allows you to upload the video file (max. 2Gb). Uploading speed depends on the internet connection speed. A free web app that converts video files, allowing you to change the video format, resolution or size right in a browser. All the app features are accessible free of charge and has no limit on the number of files you can convert. Moreover, users don’t even need to sign up or sign in.

Online-convert.com

Video.online-convert.com allows you to upload the video file (max. 100MB without registration). The website will convert the video for you and present you with a link to download the converted file. The process may take several minutes depending on the size and quality of the video.

Multi-platform desktop editing tools with graphical UI

Handbrake

HandBrake is an opensource video converter. It will quickly and simply take an MP4 file and output it as webm. It is available for Linux, MacOS and Windows.

Shotcut

Shotcut is a free and open source software for Windows, Linux, macOS. It is based on FFmpeg, Media Lovin' Toolkit, Frei0r, Qt, and ICU, among others.

WebM with mkvtoolnix

WebM files are just MKV (Matroska) files which use a subset of the features for this format. With mkvtoolnix (GPLv2 for all platforms) it's very easy to manipulate them. VP9 video and OPUS audio in a WebM container are supported since 2013.

Kdenlive

Kdenlive is an open-source video editor for GNU/Linux, BSD, macOS and (recently) Windows.

OpenShot

OpenShot Video Editor is an Open source graphical video editing tool available for all current platforms. It is an ideal platform to edit and export videos to ogv format. Choose the "All Formats OGG High" format with the highest possible resolution.

Multi-platform command-line conversion tools

ffmpeg

FFmpeg is the Swiss army knife of video conversion. It's a highly flexible software suite that brings together a large amount of tools for handling video, audio, and other multimedia. It provides a command-line program "ffmpeg", with which you can convert also to WebM. See FFmpeg wiki's VP9 Encoding Guide for more information on its usage with VP9 specifically. For even more information on available command-line arguments specific to VP9 encoding, see FFmpeg's built-in help with the command ffmpeg -h encoder=libvpx-vp9

.webm

The recommended way to use VP9 is to utilise two-pass constant quality encoding. This is a combination of two modes (2-pass and constant quality) that have traditionally been separate approaches, and is recommended due to some quality-enhancing features in the libvpx encoder only being available in two-pass mode. Two-pass mode goes through the video twice, first to analyze it and second to use the collected data to encode the video efficiently at a certain set average bitrate. Constant quality mode aims to achieve a certain perceptual quality level for all parts of the video. Two-pass constant quality mode does an analysis pass and then encodes the video with a quality level set by the user. The quality level is set with the -crf switch and also requires that -b:v is set to 0 (zero).

There are other useful options available (not all of them specific to VP9), some of which are used in the example commands below and explained further in the bullet points below.

Two-pass encoding is done by running two commands, one for each pass, and specifying which pass you're running with the -pass switch. The first pass creates an analysis log file named ffmpeg2pass-0.log, which can be deleted after the second pass is done. (You may see a message "Output file is empty, nothing was encoded" in the first pass; this is normal.)

Since the command lines of different platforms use slightly different syntax (Windows uses NUL instead of /dev/null), the commands for each platform are listed separately.

Linux and OS X command line
First pass:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 0 -crf 30 -pass 1 -row-mt 1 -pix_fmt yuv420p -an -f webm -y /dev/null
Second pass:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 0 -crf 30 -pass 2 -row-mt 1 -pix_fmt yuv420p -c:a libopus output.webm

The two commands can be run back-to-back by combining them with the && operator, like so:

ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 0 -crf 30 -pass 1 -row-mt 1 -pix_fmt yuv420p -an -f webm -y /dev/null && ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 0 -crf 30 -pass 2 -row-mt 1 -pix_fmt yuv420p -c:a libopus output.webm

Create a script: When you frequently convert videos it can be handy to create a script video2webm:

#!/bin/bash
# Convert video file to webm
# Author: Geert Van Pamel
# Parameters:
#  P1: input file name

if [[ -z "$1" ]] ;then
 echo "Input file missing"
 exit 1
fi

input="$1"
output=$(basename "$1").webm

ffmpeg -i "$input" -c:v libvpx-vp9 -b:v 0 -crf 30 -pass 1 -row-mt 1 -pix_fmt yuv420p -an -f webm -y /dev/null &&
ffmpeg -i "$input" -c:v libvpx-vp9 -b:v 0 -crf 30 -pass 2 -row-mt 1 -pix_fmt yuv420p -c:a libopus "$output"

Then simply execute:

video2webm file.mp4

A file file.mp4.webm is created in the current directory.

Linux using VAAPI on Intel devices

Those running Linux on a modern Intel-based machine (Kaby/Coffee Lake, 9th generation or later) may see significant speedup by using the Video Acceration API (VAAPI) with ffmpeg. This takes advantage of the Intel QuickSync hardware in the integrated GPU (iGPU) of the Intel UHD Graphics 630 or the Iris Plus. Speeds of up to 8x can be seen using hardware VP9 encoding, versus pure CPU-only encoding speeds of 1-2x.

The following command can be invoked to tap into the VP9 VAAPI driver:

ffmpeg -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -c:v vp9_vaapi -c:a libopus -b:a 96K -bsf:v vp9_raw_reorder,vp9_superframe output.webm
Windows command line
First pass:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 0 -crf 30 -pass 1 -row-mt 1 -an -f webm -y NUL
Second pass:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 0 -crf 30 -pass 2 -row-mt 1 -c:a libopus output.webm
Combined:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 0 -crf 30 -pass 1 -row-mt 1 -an -f webm -y NUL && ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 0 -crf 30 -pass 2 -row-mt 1 -c:a libopus output.webm
  • The target quality of -crf is specified on a scale from 0 to 63, with smaller values indicating higher quality. The default value is 30, which is sufficient for HD video. In general, the higher the video resolution the higher the value can be set since VP9 is more efficient at higher resolutions. This is useful to keep in mind when encoding resolutions higher than 1080p.
  • The audio quality, when not manually determined by the -b:a switch, is set to 96k by default. This is more than sufficient for most use cases as Opus is a very efficient audio codec. However, if your use case requires it you may wish to set it to a different value.
  • If you wish your video to not have audio, you can remove it by using the -an flag during the second pass. This is always done with the first pass since re-encoding audio would slow it down for no benefit. Furthermore, if you wish to specify the number audio channels yourself (for example, for converting 5.1 surround audio to stereo, or even mono), you can use the -ac flag followed by the number of audio channels desired (ie. -ac 2 for stereo).
  • The log file created during the first pass can be re-used and isn't actually specific to the quality level specified during the first pass. So if you encoded a video with a certain quality level but aren't happy with the result, as long as you didn't delete the log file, you can just re-run the second pass with a different quality setting and save time by not re-running the first pass.
  • The -row-mt 1 switch tells the encoder to use row-based multithreading. This can speed up encoding significantly on computers with more than 4 CPU cores/threads, resulting in a speed-up of 2x or more depending on the video resolution and the amount of CPU cores available. This option is set to 0 by default (as of January 2019) and thus needs to be set manually.
  • If you're using a pre-2018 version of FFmpeg, you may find VP9 encoding performance lacking. This is due to the aforementioned -row-mt multithreading feature being introduced in version 1.7.0 of libvpx (the VP8/VP9 encoding library used by FFmpeg), released on January 25th, 2018. FFmpeg added support for -row-mt in FFmpeg 3.4.
Furthermore, libvpx versions prior to 1.7.0 also require setting other multithreading features manually. These are the amount of threads, set with the -threads switch, and the amount of tile columns to use, set with the -tile-columns switch. The amount of threads should be set to the amount of processor threads made available by your CPU. The number of tile columns possible is determined by the resolution of the video and also affects the maximum amount of encoding threads the encoder can use. Below is a table of the recommended tile-columns values for various resolutions and the maximum amount of threads made possible by them, taken from Google's VP9 encoding guide.
Video resolution -tile-columns value Number of threads
320x240 1 2
640x360 2 4
640x480 2 4
1280x720 4 8
1920x1080 4 8
2560x1440 8 16
3840x2160 16 24

.ogv

NOTE! Theora is older and significantly less efficient than VP9, leading to higher file sizes (and thus longer upload times and higher storage space use) at the same quality compared to newer formats. In general the use of Theora for new uploads should be avoided and VP9 used instead. Nevertheless, examples for converting to Theora are provided below.

Theora video with Vorbis audio:

ffmpeg -i demo.mp4 -c:v libtheora -q:v 7 -c:a libvorbis -q:a 6 demo.ogv

Theora video with FLAC audio:

ffmpeg -i demo.mp4 -c:v libtheora -q:v 7 -c:a flac -sample_fmt s16 demo.ogv

Theora video with audio removed:

ffmpeg -i demo.mp4 -c:v libtheora -q:v 7 -an demo.ogv

The quality of the video and audio is specified with -q:v and -q:a respectively (0–10, higher is better). See TheoraVorbisEncodingGuide for more information.

avconv

Libav is a fork of FFmpeg providing the similar command-line program "avconv". It appears that the quality is not as good as oggconvert. Also the first and last seconds of an mp3 file can be lost (which is certainly not OK).

apt-get install libav-tools
  • To extract 325 seconds of audio starting at second 475 with a bitrate of 64 Mbit/s:
avconv -i input-file.mp3 -b 64k -ss 475 -t 325 output-file.mp3

The input file bit rate should be higher or equal to the output file bit rate... otherwise bad audio quality will be the result.

  • To convert multiple mp3 files at once to ogg format:
for i in *.mp3 ;do avconv -i ${i} ${i:%mp3}ogg ;done
  • To remove the (bad) sound from a video:
avconv -i infile -c copy -an outfile

MPlayer

MPlayer is an open source multimedia player also being capable to transcode files but having the advantage of supporting both a GUI as well as the command line; available for most operating systems including Windows, Linux, and macOS. The MPlayer included by some SMPlayer distributions for Windows does not contain mencoder.exe.