Transcoding a Fulldome Video File to a Different Bitrate

Generating a Fulldome Video File with a Different Bitrate


Ken Scott
Digital Chaotics LLC

Mac/Linux script contributed by
Sascha Kriegel
Planetarium Hamburg


In this post I’ll show you how to transcode a MOV or MP4 file to a new file with a different bitrate.

The video files for sale here (DomeSavers, DomeLoops, and DomeArts) are created with comparatively high quality settings – that is, high bitrates. Unfortunately that means that when you play them on your computer, it can easily result in choppy, blocky, streaky, even frozen video. Fortunately, there’s a workaround: reducing the bitrate.

The bitrate of a video file is directly proportional to the quality of the images. It’s the number of bits required to represent one second of a video stream, so more bits per second means better quality images. Unfortunately, it’s also true that the higher the bitrate is, the more load it puts on your computer to play it back. So choosing a good bitrate is a balancing act. You want the highest quality images possible, but you also want the video to play back at the speed that was intended by the producer. There’s no real one-size-fits-all solution, because each video stream has unique characteristics. It takes some experimenting to find the correct balance.

Follow the instructions below to transcode an existing video file to a lower bitrate. (And no, you can’t increase the quality of an existing video by increasing the bitrate. This isn’t like in the movies. The bits are gone, so there’s no way to add them back. All you’ll accomplish is to make a larger version of the same video file.)

Instructions:

  1. Download and install the free video conversion tool, FFMPEG [How to install FFMPEG »]
  2. Make sure it’s in your system PATH, so that you can run it from a command line.  (“add to path” from Google:  Windows »  Mac »  Linux »)
  3. Create an empty text file called “update-src-dst-vbr.cmd” (Windows) or “update-src-dst-vbr.sh” (Mac/Linux) [ Windows »  Mac »  Linux » ]
  4. Open the new file, copy the script below into it, and save it.
  5. Mac/Linux only: Make the file executable:  sudo chmod 555 update-src-dst-vbr.sh
  6. Ensure that the directory containing the new file is in your system PATH, too.
  7. Open a command-line window (Windows »  Mac »  Linux »)
  8. Execute:
    • Windows:  update-src-dst-vbr my_original_video.mp4 my_new_video.mp4 8000k
    • Mac/Linux:  ./update-src-dst-vbr.sh my_original_video.mp4 my_new_video.mp4 8000k
  9. Wait for it to finish. It’ll be a while. Take a walk. Get some coffee. Call a friend.

This will create a new file called “my_new_video.mp4” using “my_original_video.mp4” as the input, with a bitrate of approximately 8000K bits per second (a.k.a., 8Mbps). If the input video file had audio, then it will also be included in the output video file, too.

Quick note for Windows users: if you make the mistake of double-clicking on ‘update-src-dst-vbr.cmd’ you’ll see a command-line window flash on the screen very briefly. What happened is this: double-clicking on a ‘.cmd’ file causes your computer to try to execute the script. Double-clicking doesn’t give it the parameters it needs, so it runs without doing anything. Nothing bad happened. It just didn’t work. So don’t do that.

“update-src-dst-vbr” Script:

Windows

REM update-src-dst-vbr.cmd
REM
REM Reads a video file and writes them to a new video file with the video bitrate capped to
REM a given value. The bitrate is represented by values like 5000k, 10000k, 1024k, etc.
REM (The ‘k’ stands for kilobits per second. Bigger is better, but going too high may overload
REM the player.)
REM
REM Rule of thumb: for decent quality, the bitrate should be at least 4000k per 1k in
REM size (longest dimension). For example, a 1920 x 1080 HD video file should probably
REM have a bitrate of around 8000k. However, it’s possible that’s too high to be played
REM on your computer. If that’s the case, then you’ll have to step it down
REM incrementally to get the highest-possible quality at the lowest-possible bitrate.
REM
REM Should work with most popular video file formats, but only MOV and MP4 have been tested.
REM Audio is copied, too.
REM
REM Usage: update-src-dst-vbr
REM
REM source-video file: path to the existing MOV or MP4 file to be transcoded
REM destination-video-file: path where the transcoded video file should be created
REM bitrate: a bitrate value, e.g., 8000k, 15000k, etc.
REM
REM ex: update-src-dst-vbr src.MP4 dst.MP4 8000k

set srcFile=%1
set dstFile=%2
set videoBitRate=%3

echo Input File: %srcFile%
echo Output File: %dstFile%
echo Output Bitrate: %videoBitRate%

ffmpeg -i %srcFile% -b:v %videoBitRate% -b:a 320K -c:v libx264 -pix_fmt yuv420p %dstFile%

Mac/Linux

#!/bin/sh
# update-src-dst-vbr.sh
#
# Many thanks to Sascha Kriegel for his work creating this Mac/Linux version!
#
# Reads a video file and writes them to a new video file with the video bitrate capped to
# a given value. The bitrate is represented by values like 5000k, 10000k, 1024k, etc.
# (The ‘k’ stands for kilobits per second. Bigger is better, but going too high may overload
# the player.)
#
# Rule of thumb: for decent quality, the bitrate should be at least 4000k per 1k in
# size (longest dimension). For example, a 1920 x 1080 HD video file should probably
# have a bitrate of around 8000k. However, it’s possible that’s too high to be played
# on your computer. If that’s the case, then you’ll have to step it down
# incrementally to get the highest-possible quality at the lowest-possible bitrate.
#
# Should work with most popular video file formats, but only MOV and MP4 have been tested.
# Audio is copied, too.
#
# Usage: ./update-src-dst-vbr.sh
#
# source-video file: path to the existing MOV or MP4 file to be transcoded
# destination-video-file: path where the transcoded video file should be created
# bitrate: a bitrate value, e.g., 8000k, 15000k, etc.
#
# ex: ./update-src-dst-vbr.sh src.MP4 dst.MP4 8000k
#
#####
# NOTE: Be sure to make this file executable (e.g., ‘sudo chmod 555 update-src-dst-vbr.sh’), or
# your shell may refuse to run this script
#####

export srcFile=$1
export dstFile=$2
export videoBitRate=$3

echo “Input File: $srcFile”
echo “Output File: $dstFile”
echo “Output Bitrate: $videoBitRate”

ffmpeg -i $srcFile -b:v $videoBitRate -b:a 320K -c:v libx264 -pix_fmt yuv420p $dstFile

Please feel free to suggest improvements that I can make in the scripts or the instructions on their use by sending an e-mail my way [ken.scott at digitalchaotics dot com].
Password Reset
Please enter your e-mail address. You will receive a new password via e-mail.