Code Monkey home page Code Monkey logo

video_transcoding's Introduction

Video Transcoding

Tools to transcode, inspect and convert videos.

About

Hi, I'm Lisa Melton. I created these tools to transcode my collection of Blu-ray Discs and DVDs into a smaller, more portable format while remaining high enough quality to be mistaken for the originals.

What makes these tools unique are the ratecontrol systems which achieve those goals.

This package is based on my original collection of Video Transcoding Scripts written in Bash. While still available online, those scripts are no longer in active development. Users are encouraged to install this Ruby Gem instead.

Most of the tools in this package are essentially intelligent wrappers around Open Source software like HandBrake, FFmpeg, MKVToolNix, and MP4v2. And they're all designed to be executed from the command line shell:

  • transcode-video Transcode video file or disc image directory into format and size similar to popular online downloads.

  • detect-crop Detect crop values for video file or disc image directory.

  • convert-video Convert video file from Matroska to MP4 format or from MP4 to Matroksa format without transcoding video.

  • query-handbrake-log Report information from HandBrake-generated .log files.

Even if you don't try any of my tools, you may find this "README" document helpful:

Installation

My Video Transcoding tools are designed to work on macOS, Linux and Windows. They're packaged as a Gem and require Ruby version 2.0 or later. See "Installing Ruby" if you don't have the proper version on your platform.

Use this command to install the package:

gem install video_transcoding

You may need to prefix that command with sudo in some environments:

sudo gem install video_transcoding

Updating

Use this command, or the variation prefixed with sudo, to update the package:

gem update video_transcoding

Requirements

Most of the tools in this package require other software to function properly, specifically these command line programs:

  • HandBrakeCLI
  • ffmpeg
  • mkvpropedit
  • mp4track

Previewing the output of detect-crop is optional, but doing so uses mpv, a free, Open Source, and cross-platform media player.

You can download the command line version of HandBrake, called HandBrakeCLI, here:

https://handbrake.fr/downloads2.php

On macOS, HandBrakeCLI and all its other dependencies can be easily installed via Homebrew, an add-on package manager:

brew install handbrake
brew install ffmpeg
brew install mkvtoolnix
brew install mp4v2

The optional crop previewing package can also be installed via Homebrew:

brew install mpv

On Linux, package management systems vary so it's best consult the indexes for those systems. But there's a Homebrew port available called Linuxbrew and it doesn't require root access.

On Windows, it's best to follow one of the two methods, manually installing binaries or installing into the Windows Subsystem for Linux, as described here:

https://github.com/JMoVS/installing_video_transcoding_on_windows

When installing HandBrakeCLI or other downloaded programs, make sure the executable binary is in a directory listed in your PATH environment variable. On Unix-style systems like macOS and Linux, that directory might be /usr/local/bin.

If you're comfortable using Docker virtualization software, a pre-built container with everything you need, plus installation instructions, is available here:

https://hub.docker.com/r/ntodd/video-transcoding/

Rationale

Why transcode-video?

Videos from the iTunes Store are my template for a portable format while remaining high enough quality to be mistaken for the originals. Their files are very good quality, much smaller than the same video on a Blu-ray Disc, and play on a wide variety of devices.

HandBrake is a powerful video transcoding tool but it's complicated to configure. It has several presets but they aren't smart enough to automatically change bitrate targets and other encoding options based on different inputs. More importantly, HandBrake's default presets don't produce a predictable output size with sufficient quality.

HandBrake's "AppleTV 3" preset is closest to what I want but transcoding "Planet Terror (2007)" with it results in a huge video bitrate of 19.9 Mbps, very near the original of 22.9 Mbps. And transcoding "The Girl with the Dragon Tattoo (2011)," while much smaller in output size, lacks detail compared to the original.

So, the transcode-video tool configures the x264 video encoder within HandBrake to use a modified constrained variable bitrate (CVBR) mode, and to automatically target bitrates appropriate for different input resolutions.

Input resolution Target video bitrate
1080p or Blu-ray video 6000 Kbps
720p 3000 Kbps
480i, 576p or DVD video 1500 Kbps

When audio transcoding is required, it's done in AAC format and, if the original is multi-channel surround sound, in Dolby Digital AC-3 format. Meaning the output can contain two tracks from the same source in different formats. And mono, stereo and surround inputs are all handled differently.

Input channels AAC track AC-3 track
Mono 80 Kbps none
Stereo 160 Kbps none
Surround 160 Kbps 640 Kbps with 5.1 channels

But most of these default settings and automatic behaviors can be easily overridden or augmented with additional command line options.

Why detect-crop?

HandBrake applies automatic crop detection by default. While it's usually correct, it does guess wrong often enough not to be trusted without review. For example, HandBrake's default behavior removes the top and bottom 140 pixels from "The Dark Knight (2008)" and "The Hunger Games: Catching Fire (2013)," losing significant portions of their full-frame content.

This is why transcode-video doesn't allow HandBrake to apply cropping by default.

Instead, the detect-crop tool leverages both HandBrake and FFmpeg to find the video cropping bounds. It then indicates whether those two programs agree. To aid in review, this tool prints commands to the terminal console allowing the recommended (or disputed) crop to be displayed, as well as a sample command line for transcode-video itself.

Why convert-video?

All videos from the iTunes Store are in MP4 format format. However, the transcode-video tool generates output in the more flexible Matroska format by default.

While you can easily change the behavior of transcode-video to generate MP4 format with a command line option, it's sometimes handy to convert between formats quickly without re-transcoding. The convert-video tool is designed for exactly that convenience.

Why query-handbrake-log?

The transcode-video tool creates both video files and .log files. While not nearly as entertaining, the cryptic .log file still contains useful information. And the query-handbrake-log can extract performance metrics, video bitrate and relative quality from those .log files into easily readable reports.

Usage

Each of my Video Transcoding tools has several command line options. The transcode-video tool is the most complex with over 40 of its own. Not all of those options are detailed here. Use --help to list the full set of options available for a specific tool, along with brief instructions on their usage:

transcode-video --help

This built-in help works even if a tool's software dependencies are not yet installed.

All of the tools can accept multiple inputs, but batch processing for transcode-video is still best handled by a separate script.

The transcode-video and detect-crop tools work best with video files:

transcode-video "/path/to/Movie.mkv"

However, both tools also accept disc image directories as input:

transcode-video "/path/to/Movie disc image directory/"

Disc image directories contain unencrypted backups of Blu-ray Discs or DVDs. Typically these formats include more than one video title. These additional titles can be bonus features, alternate versions of a movie, multiple TV show episodes, etc.

By default, transcode-video and detect-crop will automatically select the main feature in a disc image directory. Or they will select the first title, if the main feature can't be determined.

Both tools allow you to scan disc image directories, listing titles and tracks:

transcode-video --scan "/path/to/Movie disc image directory/"

So you can then select a specific title by number:

transcode-video --title 5 "/path/to/Movie disc image directory/"

Using transcode-video

The transcode-video tool automatically determines target video bitrate, number of audio tracks, etc. without any command line options, so using it can be as simple as:

transcode-video "/path/to/Movie.mkv"

That command creates, after a reasonable amount of time, two files in the current working directory:

Movie.mkv
Movie.mkv.log

The .log file can be used as input to the query-handbrake-log tool.

Changing output format

By default, the transcode-video tool generates output in Matroska format. To generate output in MP4 format, use the --mp4 option:

transcode-video --mp4 "/path/to/Movie.mkv"

Which will instead create:

Movie.mp4
Movie.mp4.log

To create MP4 output with the .m4v file extension instead of .mp4, use the --m4v option:

transcode-video --m4v "/path/to/Movie.mkv"

The .m4v file extension is more "iTunes-friendly," but the file content itself is exactly the same as a file with the .mp4 extension.

Improving performance

You can increase encoding speed by 70-80% with no easily perceptible loss in video quality by using the --quick option:

transcode-video --quick "/path/to/Movie.mkv"

The --quick option avoids the typical quality problems associated with the x264 video encoder's speed-based presets, especially as that speed increases.

Cropping

No cropping is applied by default. Use the --crop TOP:BOTTOM:LEFT:RIGHT option and arguments to indicate the amount of black, non-content border to remove from the edges of your video.

This command removes the top and bottom 144 pixels, typical of a 2.40:1 widescreen movie embedded within 16:9 Blu-ray Disc video:

transcode-video --crop 144:144:0:0 "/path/to/Movie.mkv"

This command removes the left and right 240 pixels, typical of a 4:3 classic TV show embedded within 16:9 Blu-ray Disc video:

transcode-video --crop 0:0:240:240 "/path/to/Movie.mkv"

Use the detect-crop tool to determine the cropping bounds before transcoding.

You can also call the detect-crop logic from transcode-video with the single detect argument:

transcode-video --crop detect "/path/to/Movie.mkv"

However, be aware that detect can fail if HandBrake and FFmpeg disagree about the cropping values.

Which is why you can select a fallback behavior using the --fallback-crop option when that happens, choosing handbrake, ffmpeg, minimal or none as its argument:

transcode-video --crop detect --fallback-crop minimal "/path/to/Movie.mkv"

The minimal argument is perhaps the most useful behavior since it determines the smallest possible crop values by combining results from both HandBrakeCLI and ffmpeg.

Understanding audio

By default, the transcode-video tool selects the first audio track in the input as the main audio track. This is the first track in the output and the default track for playback.

But you can select any input audio track as the main track. In this case, track number 3:

transcode-video --main-audio 3 "/path/to/Movie.mkv"

Or you can select the first input audio track in a specific language using a three-letter code instead of a track index number. This command selects the first Spanish language track:

transcode-video --main-audio spa "/path/to/Movie.mkv"

If no track in the target language is found, then selection defaults to the first audio track in the input.

You can also give the main audio track a custom name:

transcode-video --main-audio 3="Original Stereo" "/path/to/Movie.mkv"

Unlike HandBrakeCLI, custom track names are allowed to contain commas.

By default, only one track is selected as the main audio or default track. But you can add additional tracks, also with custom names:

transcode-video --add-audio 4 --add-audio 5="Director Commentary" "/path/to/Movie.mkv"

Or you can add all audio tracks with a single option and argument:

transcode-video --add-audio all "/path/to/Movie.mkv"

You can also add audio tracks selected by their three-letter language code. This command adds all French and Spanish language tracks in the same order they're found in the input:

transcode-video --add-audio fra,spa "/path/to/Movie.mkv"

By default, the main audio track is transcoded in AAC format and, if the original is multi-channel surround sound, in Dolby Digital AC-3 format. Meaning the output can contain two tracks from the same source in different formats. So, main audio output is "wide" enough for "double" tracks.

Also by default, any added audio tracks are only transcoded in AAC format. Meaning the output only contains a single track in one format. So, additional audio output is only "wide" enough for "stereo" tracks.

However, you can change the "width" of main audio or additional audio output using the --audio-width option. There are three possible widths: double, surround and stereo.

Use this command to treat any other additional audio tracks just like the main audio track:

transcode-video --audio-width other=double "/path/to/Movie.mkv"

Or use this command to make main audio output as a single track but still allow it in surround format:

transcode-video --audio-width main=surround "/path/to/Movie.mkv"

If possible, audio is first passed through in its original format, providing that format is either AC-3 or AAC. This hardly ever works for Blu-ray Discs but it often will for DVDs and other random videos.

However, you can still copy audio tracks and maintain their original format, provided HandBrake and your selected file format support it:

transcode-video --copy-audio all "/path/to/Movie.mkv"

The --copy-audio option doesn't implicitly add audio tracks to be copied. Since only the main audio track is included by default, the previous command only tries to copy that track. To also copy another track, you must first add it:

transcode-video --add-audio 4 --copy-audio all "/path/to/Movie.mkv"

Be aware that copying audio tracks in their original format will likely defeat two very important goals of transcoding: portability and compression.

Understanding subtitles

By default, the transcode-video tool automatically burns any forced subtitle track it detects into the output video track. "Burning" means that the subtitle becomes part of the video itself and isn't retained as a separate track. A "forced" subtitle track is detected by a special flag on that track in the input.

But you can select any subtitle track for burning. In this case, track number 3:

transcode-video --burn-subtitle 3 "/path/to/Movie.mkv"

You can also use a special "scan" mode of HandBrake to find any embedded forced subtitle track that's in the same language as the main audio track:

transcode-video --burn-subtitle scan "/path/to/Movie.mkv"

Be aware that using this special "scan" mode does not always work. Sometimes it won't find any track or, worse, it will find the wrong track. And you won't know whether it worked until the transcoding is complete.

Burning subtitles into the output video works best for "forced" rather than optional subtitles. But it's still a much better idea than adding subtitle tracks in their original format to the output file.

Blu-ray Disc and DVD subtitles are bitmap formats. They're not text. They're large, unwieldy and may not appear correctly if you crop your video. Blu-ray Disc-format subtitles aren't even allowed in MP4 output. And DVD-format subtitles, while allowed, often won't display at all in many MP4 players.

However, you can leverage programs like SUBtools or Subtitle Edit to extract Blu-ray Disc and DVD subtitles and convert them into text format. Be aware that while both of these programs can perform automatic character recognition of the subtitle bitmaps, you'll still need to edit the output text by hand. Even the best automatic character recognition is still wrong far too often.

You can also find text-based subtitles for your movies and TV shows at sites like OpenSubtitles, where someone else has already done the tedious work of conversion and editing.

If and when you do have a subtitle in text format, specifically SubRip .srt format, you can easily add it to your output video from an external file:

transcode-video --add-srt "/path/to/Subtitle.srt" "/path/to/Movie.mkv"

Unlike HandBrakeCLI, external subtitle file names are allowed to contain commas.

Using detect-crop

The command to find the video cropping bounds is as simple as:

detect-crop "/path/to/Movie.mkv"

Which prints out something like this:

mpv --no-audio --vf lavfi=[drawbox=0:132:1920:816:invert:1] '/path/to/Movie.mkv'
mpv --no-audio --vf crop=1920:816:0:132 '/path/to/Movie.mkv'

transcode-video --crop 132:132:0:0 '/path/to/Movie.mkv'

Just copy and paste the sample commands to preview or transcode.

Please note that path names within the sample commands are not escaped properly when using cmd.exe or PowerShell on Windows. If you have Git for Windows or another Unix-like environment installed, you can use the Bash shell (usually named bash.exe) to work around this issue.

If HandBrake and FFmpeg disagree about the cropping values, then detect-crop prints out something like this:

Results differ...

# From HandBrakeCLI:

mpv --no-audio --vf lavfi=[drawbox=0:132:1920:816:invert:1] '/path/to/Movie.mkv'
mpv --no-audio --vf crop=1920:816:0:132 '/path/to/Movie.mkv'

transcode-video --crop 132:132:0:0 '/path/to/Movie.mkv'

# From ffmpeg:

mpv --no-audio --vf lavfi=[drawbox=0:130:1920:820:invert:1] '/path/to/Movie.mkv'
mpv --no-audio --vf crop=1920:820:0:130 '/path/to/Movie.mkv'

transcode-video --crop 130:130:0:0 '/path/to/Movie.mkv'

You'll then need to preview both and decide which to use.

When input is a disc image directory instead of a single file, the detect-crop tool doesn't use FFmpeg, nor does it print out commands to preview the crop.

Using convert-video

The convert-video tool repackages video files, converting them from Matroska to MP4 format or from MP4 to Matroksa format without transcoding the video. It's as simple as:

convert-video "Movie.mkv"

Which creates this MP4 file in the current working directory:

Movie.mp4

Or...

convert-video "Movie.mp4"

Which creates this Matroska file in the current working directory:

Movie.mkv

If necessary, the convert-video tool may transcode audio tracks to AAC or Dolby Digital AC-3 format when converting to MP4 format.

Chapter markers, metadata such as track titles and most subtitles are converted. However, be aware that any Blu-ray Disc-format subtitles are ignored.

Using query-handbrake-log

The query-handbrake-log tool reports information from HandBrake-generated .log files. While it can certainly work with a single .log file, it really shines with multiple files.

There are four types of information that query-handbrake-log can report on:

  • time The time spent during transcoding, sorted from short to long. This even works for two-pass transcodings.

  • speed The speed of transcoding in frames per second, sorted from fast to slow. Since most video is 23.976 FPS, you can easily see trends when you're faster or slower than real time.

  • bitrate The final video bitrate of the transcoded output, sorted from low to high. Very useful since most media query tools only provide approximate bitrates for Matroska files, if at all.

  • ratefactor Technically this is the average P-frame quantizer for transcoding, sorted from low to high. But you should consider it a relative quality assessment by the x264 video encoder.

One of these information types is required as an argument:

query-handbrake-log time "/path/to/Logs directory/"

Which prints out something like this, time spent transcoding followed by video file name:

01:20:25 Movie.mkv
01:45:10 Another Movie.mkv
02:15:35 Yet Another Movie.mkv

Guide

Preparing your media for transcoding

I have four rules when preparing my own media for transcoding:

  1. Use MakeMKV to rip Blu-ray Discs and DVDs.
  2. Rip each selected video as a single Matroska format .mkv file.
  3. Look for forced subtitles and isolate them in their own track.
  4. Convert lossless audio tracks to FLAC format.

Why MakeMKV?

  • It runs on most desktop computer platforms like macOS, Windows and Linux. There's even a free version available to try before you buy.

  • It was designed to decrypt and extract a video track, usually the main feature of a disc and convert it into a single Matroska format .mkv file. And it does this really, really well.

  • It can also make an unencrypted backup of your entire Blu-ray or DVD to a disc image directory.

  • It's not pretty and it's not particularly easy to use. But once you figure out how it works, you can rip your video exactly the way you want.

Why a single .mkv file?

  • Many automatic behaviors and other features in both transcode-video and detect-crop are not available when input is a disc image directory. This is because that format limits the ability of HandBrakeCLI and ffmpeg to detect or manipulate certain information about the video.

  • Both forced subtitle extraction and lossless audio conversion, detailed below, are not possible when input is a disc image directory.

Why bother with forced subtitles?

  • Remember "The Hunt for Red October (1990)" when Sean Connery and Sam Neill are speaking actual Russian at the beginning of the movie instead of just using cheesy accents like they did the rest of the time? The Blu-ray Disc version provides English subtitles just for those few scenes. They're "forced" on screen for you. Which is actually very convenient.

  • Forced subtitles are often embedded within a full subtitle track. And a special flag is set on the portion of that track which is supposed to be forced. MakeMKV can recognize that flag when it converts the video into a single .mkv file. It can even extract just the forced portion of that subtitle into a another separate subtitle track. And it can set a different "forced" flag in the output .mkv file on that separate track so other software can tell what it's for.

  • Not all discs with forced subtitles have those subtitles embedded within other tracks. Sometimes they really are separate. But enough discs are designed with the embedded technique that you should avoid using a disc image directory as input for transcoding.

Why convert lossless audio?

  • DTS-HD Master Audio is the most popular high definition, lossless audio format. It's used on more than 80% of all Blu-ray Discs.

  • Currently, HandBrake can't decode the lossless portion of a DTS-HD audio track. It's only able to extract the non-HD, lossy core which is in DTS format.

  • But MakeMKV can decode DTS-HD and convert it into FLAC format which can then be decoded by HandBrake and most other software. Once again, MakeMKV can only do this when it converts the video into a single .mkv file.

Understanding the x264 preset system

The --preset option in transcode-video controls the x264 video encoder, not the other preset system built into HandBrake. It takes a preset name as its single argument:

transcode-video --preset slow "/path/to/Movie.mkv"

The x264 preset names (mostly) reflect their relative speed compared to the default, medium.

Presets faster than medium trade precision and compression efficiency for more speed. You may notice quality loss problems when using these presets, especially as speed increases.

However, you can increase encoding speed by 70-80% with no easily perceptible loss in video quality by using the --quick option instead:

transcode-video --quick "/path/to/Movie.mkv"

Presets slower than medium trade encoding speed for more precision and compression efficiency. Any quality improvement using these presets may not be perceptible for most input.

A faster and more perceptible way to improve quality is to simply raise the target video bitrate 50% by using the --target big option and argument macro:

transcode-video --target big "/path/to/Movie.mkv"

Recommended transcode-video usage

Use the default settings whenever possible.

Use the --mp4 or --m4v options if your target player can't handle Matroska format.

Use the --quick option if you're in a hurry.

Use detect-crop before transcoding to manually review and apply the best crop values.

Don't add audio tracks in their original format that aren't AAC or Dolby Digital AC-3.

Don't add subtitles in their original Blu-ray Disc or DVD format.

Save your .log files so you can mine the data later.

Batch control for transcode-video

Although the transcode-video tool can accept multiple inputs, batch processing is still best handled by a separate script because options can be changed for each input.

A batch.sh script can simply be a list of commands:

#!/usr/bin/env bash

transcode-video --crop 132:132:0:0 "/path/to/Movie.mkv"
transcode-video "/path/to/Another Movie.mkv"
transcode-video --crop 0:0:240:240 "/path/to/Yet Another Movie.mkv"

But a better solution is to write the script once and supply the list of movies and their crop values separately:

#!/usr/bin/env bash

readonly work="$(cd "$(dirname "$0")" && pwd)"
readonly queue="$work/queue.txt"
readonly crops="$work/Crops"

input="$(sed -n 1p "$queue")"

while [ "$input" ]; do
    title_name="$(basename "$input" | sed 's/\.[^.]*$//')"
    crop_file="$crops/${title_name}.txt"

    if [ -f "$crop_file" ]; then
        crop_option="--crop $(cat "$crop_file")"
    else
        crop_option=''
    fi

    sed -i '' 1d "$queue" || exit 1

    transcode-video $crop_option "$input"

    input="$(sed -n 1p "$queue")"
done

This requires a work directory on disk with three items, one of which is a directory itself:

batch.sh
Crops/
    Movie.txt
    Yet Another Movie.txt
queue.txt

The contents of Crops/Movie.txt is simply the crop value for /path/to/Movie.mkv:

132:132:0:0

And the contents of queue.txt is just the list of movies, full paths without quotes, delimited by carriage returns:

/path/to/Movie.mkv
/path/to/Another Movie.mkv
/path/to/Yet Another Movie.mkv

Notice that there's no crop file for /path/to/Another Movie.mkv. This is because it doesn't require cropping.

For other options that won't change from input to input, e.g. --mp4, simply augment the line in the script calling transcode-video:

    transcode-video --mp4 $crop_option "$input"

The transcoding process is started by executing the script:

./batch.sh

The path is first deleted from the queue.txt file and then passed as an argument to the transcode-video. tool. To pause after transcode-video returns, simply insert a blank line at the top of the queue.txt file.

These examples are written in Bash and only supply crop values. But almost any scripting language can be used and any option can be changed on a per input basis. Nick Wronski has written a batch-processing wrapper for transcode-video in Node.js, available here:

https://github.com/nwronski/batch-transcode-video

Explanation

Ratecontrol systems

What is a ratecontrol system? It's how a video encoder decides on the amount of bits to allocate for a specific frame.

My transcode-video tool has four different ratecontrol systems which manipulate x264 and three which manipulate x265, both software-based video encoders built into HandBrakeCLI.

Additionally, transcode-video allows access to hardware-based video encoders which have their own ratecontrol systems.

All of these ratecontrol systems, mine and those built into hardware, target a specific video bitrate.

The target video bitrate for all of these systems is automatically determined by transcode-video using the resolution of the input. For example, the default target for 1080p output is 6000 Kbps, which is about one-fifth the video bitrate found on a typical Blu-ray Disc.

How my simple and special ratecontrol systems work

My simple and special ratecontrol systems attempt to produce the highest possible video quality near a target bitrate using a constant ratefactor (CRF) to specify quality. A CRF is represented by a number from 0 to 51 with lower values indicating higher quality. The special value of 0 is for lossless output.

Unfortunately, the output bitrate is extremely unpredictable when using the default CRF-based system in x264 or x265. Typically, people pick a middle-level CRF value as their quality target and just hope for the best. This is what most of the presets built into HandBrake do, choosing a CRF of 20 or 22.

But such a strategy can result in output larger than its input or, worse, output too low in quality to be mistaken for that input.

So I set the target CRF value to 1, the best possible "lossy" quality. Normally this would produce a huge output bitrate but I also reduce the encoder's maximum bitrate to my target, e.g. 6000 Kbps for 1080p output, by manipulating an option called vbv-maxrate.

With this approach, the encoder chooses the lowest CRF value, and therefore the highest quality, which fits below that maximum bitrate ceiling, even if that's usually not a a CRF value of 1.

And this fully describes the behavior of transcode-video when using the --simple option.

However, my special, or default, ratecontrol system also sets a maximum CRF (crf-max) value of 25, raising the minimum quality. This allows vbv-maxrate to become a "soft" ceiling so that the output bitrate can exceed the target when necessary to maintain that quality.

Unfortunately, this internal tug of war can cause the encoder to sometimes generate a few very low quality frames.

As part of the encoding process, a quantizer value (QP) is calculated for each macroblock within a frame of video. A QP is represented by a number from 0 to 69 with lower values indicating higher quality.

So I set a maximum quantizer (qpmax) value of 34, again raising the minimum quality. The occasional bad frame is still there, but it's no longer noticeable because it's now of sufficient quality to blend in with the others.

How my average bitrate (ABR) ratecontrol system works

My average bitrate (ABR) ratecontrol system, selected via the --abr option, is based on the ABR algorithm already within x264 and x265 which targets a specific bitrate.

But I constrain the maximum bitrate (vbv-maxrate) to only 1.5 times that of the target, i.e. to just 9000 Kbps when the target bitrate is 6000 Kbps for 1080p output.

It seems counterintuitive, but constraining the maximum bitrate prevents too much bitrate being wasted on complex or difficult to encode passages at the expense of quality elsewhere. This is because with an average bitrate algorithm, when the peaks get too high then the valleys get too low.

And this manipulation is exactly the same strategy used by streaming services such as Netflix.

How my average variable bitrate (AVBR) ratecontrol system works

My average variable bitrate (AVBR) ratecontrol system, selected via the --avbr option, is also based on the ABR algorithm already within x264 which targets a specific bitrate.

But the maximum bitrate is not constrained like my ABR system.

Instead, the tolerance of missing the average bitrate is raised to the maximum amount, disabling overflow detection completely. This makes the ABR algorithm behave much more like a CRF-based encode, so final bitrates can be 10-15% higher or lower than the target.

And to prevent bitrates from getting too low, the Macroblock-tree ratecontrol system built into x264 is disabled. While this does lower compression efficiency somewhat, it significantly reduces blockiness, color banding and other artifacts.

Unfortunately, these modifications to implement AVBR are not possible when using x265.

FAQ

Should I worry about all these VBV underflow warnings?

No, these warnings are simply a side effect of my special ratecontrol system. The x264 video encoder within HandBrake is just being overly chatty. Ignore it. Nothing is wrong with the output from transcode-video.

Can you make a GUI version of your tools?

My command line tools have the same behavior and scriptable interface across multiple platforms. Developing a GUI application with those requirements is not an investment that I want to make.

Plus, I wouldn't use a GUI for these tasks. And it's a bad idea to develop software that you won't use yourself.

When will you add support for H.265 video?

HandBrake has supported High Efficiency Video Coding or H.265 ever since it included the x265 video encoder.

You can try HEVC transcoding now using the --encoder option:

transcode-video --encoder x265 "/path/to/Movie.mkv"

While speed continues to improve, x265 is still considerably slower than the default x264 encoder.

What about hardware-based video transcoding?

Hardware-based encoders, like those in Intel Quick Sync Video, are often considerably faster than x264 or x265. Some are available in recent versions of HandBrake.

Check the Video Options section from the output of HandBrakeCLI --help to find out if your platform has any of these video encoders available:

Platform H.264 encoder HEVC encoder
Intel Quick Sync Video qsv_h264 qsv_h265 and qsv_h265_10bit
AMD Video Coding Engine vce_h264 vce_h265
Nvidia NVENC nvenc_h264 nvenc_h265
Apple VideoToolbox vt_h264 vt_h265

You can try hardware-based transcoding now using the --encoder option. On macOS, select the Apple VideoToolbox H.264 encoder this way:

transcode-video --encoder vt_h264 "/path/to/Movie.mkv"

You can also use the --target option with these encoders.

How do you assess video transcoding quality?

I compare by visual inspection. Always with the video in motion, never frame by frame. It's tedious but after years of practice I know which portions of which videos are problematic and difficult to transcode. And I look at those first.

In addition, I use the query-handbrake-log tool to report on ratefactor, the average P-frame quantizer, to get a relative quality assessment from the x264 encoder.

What I don't use are peak signal-to-noise ratios or a structural similarity index in an attempt to objectively compare quality. Although both metrics are available to the x264 encoder, enabling either of them ironically disables key psychovisual optimizations that improve quality.

What options do you use with transcode-video?

I never use the --crop detect function of transcode-video because I don't trust either HandBrakeCLI or ffmpeg to always get it right without supervision. Instead, I use the separate detect-crop tool before transcoding to manually review and apply the best crop values.

I let transcode-video automatically burn any forced subtitles into the output video track when the "forced" flag is enabled in the original.

I never include separate subtitle tracks, but I do add audio commentary tracks.

For a few problematic videos, I have to apply options like --force-rate 23.976 --filter detelecine. But that's rare.

History

All of the notes for each release are now available in the "CHANGELOG" document.

Feedback

The best way to send feedback is mentioning me, @[email protected], on Mastodon. You can also file bugs or ask questions in a longer form by creating a new issue on GitHub. I always try to respond quickly but sometimes it may take as long as 24 hours.

Acknowledgements

A big "thank you" to the developers of HandBrake and the other tools used by this package. So much wow.

Thanks to Rene Ritchie for letting me continue to babble on about transcoding in his podcasts.

Thanks to Joyce Melton, my sister, for help editing this "README" document.

Many thanks to Jordan Breeding and numerous others online for their positive feedback, bug reports and useful suggestions.

License

Video Transcoding is copyright Lisa Melton and available under a MIT license.

video_transcoding's People

Contributors

arikalish avatar chrisridd avatar cnrd avatar davidnielsen avatar eventualbuddha avatar jmovs avatar joshstaiger avatar lisamelton avatar samhutchins avatar timsutton avatar vitorgalvao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

video_transcoding's Issues

H.265 Support

I am seeing H265 is becoming very popular (and I can see why). Do you think H265 support could be added? I think moving forward I would like to start using H265 (after running a few more tests) as it looks like I can achieve up to around 50% size reduction with no noticeable quality loss. It appears it will become the new standard in the next few years.

After moving house I will be setting up my HP server probably with VMware and having a new ubuntu 16.04 VM dedicated to automatically converting and transcoding using my automated bash scripts and your scripts. Im looking forward to getting this set up.

Media Duration Cannot be Found (Windows)

Description

Whenever I try to transcode any mkv file, it parses the parameters, then the following message is printed out.

/home/Callum/bin/transcode-video: media duration not found

This happens regardless of the parameters or input files. It happens for all kinds of mkv inputs. I cannot find an mkv that works.

Environment

  • Script Version: 0.1.1
  • Handbrake CLI version: Latest stable version 0.10.1 (2015030800)
  • OS: Win7 x64 Service Pack 1
  • Cygwin version: 2.0.1(0.287/5/3)
  • Ruby version: ruby 2.0.0p598 (2014-11-13) [x86_64-cygwin]

Convert-video does not recognized ffmpeg version on windows

Kind what the title says really. Realised I had been outputting to MKV rather than MP4, so I tried to use the convert-video tool, but got the following error:

convert-video The\ Imitation\ Game\ \(2014\).mkv
...
/home/Callum/bin/convert-video: ffmpeg version unknown

Environment

  • Script Version: 0.2.6
  • Handbrake CLI version: Latest stable version 0.10.1 (2015030800)
  • OS: Win7 x64 Service Pack 1
  • Cygwin version: 2.0.1(0.287/5/3)
  • Ruby version: ruby 2.0.0p598 (2014-11-13) [x86_64-cygwin]
  • ffmpeg version N-70348-g9564375

Allow language code as argument to --main-audio option in transcode-video

I called thr script with this:

transcode-video --output titlesmall.mkv --add-audio language=deu --audio-width all=double --no-auto-burn title01.mkv

My file has an audio track 1 with english and a track 4 which is german. According to help, main output is number 1 by default, so shouldn't need to change/specify it as "adding" means additional audio tracks beside the main track. Resulting video only had the german audio track

Multiple inputs into one output?

For a movie that spans multiple DVD/Blu-Ray discs, there a way to specify multiple inputs to be converted (merged) into one output? My current process is to use MKVtoolnix to merge the multiple MakeMKV outputs into one large MKV before conversion.

Calling script results in "undefined method" error

I called it with these parameters:

transcode-video --main-audio 1=English --add-audio language=deu --audio-width all=double --no-auto-burn /title01.mkv

and the output was:

/usr/local/bin/transcode-video: undefined method `[]' for nil:NilClass

Detect-crop fails on windows

Description

When running detect-crop on any file, nothing happens except the below error:

detect-crop: mplayer version unknown

Likely to be another passing issue on windows? For reference my mplayer versions is

MPlayer Redxii-SVN-r37378-4.9.2 (i686)

Environment

  • Script Version: 0.1.1
  • Handbrake CLI version: Latest stable version 0.10.1 (2015030800)
  • OS: Win7 x64 Service Pack 1
  • Cygwin version: 2.0.1(0.287/5/3)
  • Ruby version: ruby 2.0.0p598 (2014-11-13) [x86_64-cygwin]

Hazel needs fulls paths for the script to work

BACKGROUND
I am getting closer building a full hands-off solution to convert movie files with
Drop in one folder, Hazel transcodes, adds subtitles and more ... final movie lands in Plex without any interaction.

I tell Hazel to run shell script on folder contens with below rule:
transcode-video --quick --add-all-subtitles --add-audio all --m4v "$1"

At first look it seems to work. But I have found out that it is unstable end often ends up with errors. After some googling I found out that:
The which command does not function as expected within a Hazel shell. What does is simply specifying the actual path of each binary and adding an exception to the checkdep function.

I have tried but my knowledge in shell is limited and I am unsure how to get this to work.

I know that I must change above rule in Hazel to
/usr/local/bin/transcode-video --quick --add-all-subtitles --add-audio all --m4v "$1"

skarmavbild 2016-01-23 kl 08 27 22

QUESTIONS

  1. How do I change all the paths in the transcode-video to full paths (eg usr/local/bin/XXXX)
  2. Is it possible to tell the script to trash the original file if the conversion was successfull and delete the converted .mv4 file if the script was unsuccesful. Needed because this is a hands-off solution and I dont want unsuccessfully transcoded movies to show up in Plex, then I would rather take the original file.

FORUM-THREAD TALKING ABOUT HAZEL AND SHELL SCRIPTS
http://www.noodlesoft.com/forums/viewtopic.php?f=4&t=1942&p=8096#p8096

Will post the whole process and get you a link when I get this to work!

Allow the user to change audio metadata language.

This is already available when using MakeMKV, but I sometimes forget to add the correct language tag for the audio tracks. This can especially be a problem when ripping in multiple languages and still wanting to be able to see if the file contains English or local audio.

This means that I have to do one of two things currently:
Rip another copy with MakeMKV
Change the metadata using another tool before or after converting.

What I would like to be able to do:
If I find that I forgot to tag the file in MakeMKV, I would love to just be able to pass a parameter to transcode-video that would add the metadata language tag (I'm pretty sure handbrake have this?)

This would also enable me to just ignore the language tag in MakeMKV (Which is quite time consuming to actually do) and batch convert a bunch of movies that I know is in the same language, just passing the parameter for every file.

Windows: convert-video : ffmpeg version unknown

I looked at the ruby code and it looks like it is looking for a ffmpeg version that starts with 1-9., but the windows builds are all built off source so they look like:
git-21fbc41 (2015-12-06) which obviously fails the version check. Anything we can do here to either not do the check of also allow git-
builds?

ProRes File Error

philips-Mac-Pro:Desktop philipmozolak$ transcode-video --dry-run -vv /Users/philipmozolak/Desktop/2015-05-14-River/kD-30117_01.mov
transcode-video 0.2.3
Copyright (c) 2013-2015 Don Melton
Processing: /Users/philipmozolak/Desktop/2015-05-14-River/kD-30117_01.mov...
Scanning media title 1 with HandBrakeCLI...
HandBrake 0.10.0 found...
[17:49:42] hb_init: starting libhb thread
HandBrake 0.10.0 (2014112200) - Darwin x86_64 - https://handbrake.fr
8 CPUs detected
Opening /Users/philipmozolak/Desktop/2015-05-14-River/kD-30117_01.mov...
[17:49:42] CPU: Intel(R) Xeon(R) CPU           X5482  @ 3.20GHz
[17:49:42]  - logical processor count: 8
[17:49:42] OpenCL device #1: NVIDIA GeForce 8800 GT
[17:49:42]  - OpenCL version: 1.0 
[17:49:42]  - driver version: 10.0.31 310.90.10.05b12
[17:49:42]  - device type:    GPU
[17:49:42]  - supported:      no
[17:49:42] hb_scan: path=/Users/philipmozolak/Desktop/2015-05-14-River/kD-30117_01.mov, title_index=1
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening /Users/philipmozolak/Desktop/2015-05-14-River/kD-30117_01.mov/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening /Users/philipmozolak/Desktop/2015-05-14-River/kD-30117_01.mov/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(/Users/philipmozolak/Desktop/2015-05-14-River/kD-30117_01.mov) failed
[17:49:42] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[17:49:42] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/philipmozolak/Desktop/2015-05-14-River/kD-30117_01.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2015-05-14 21:19:06
    date            : 2015-05-14T12:45:04-0500
    encoder         : Mac OS X 10.10.4 (14E17e)
  Duration: 00:00:12.01, start: 0.000000, bitrate: 118195 kb/s
    Stream #0.0(eng): Video: prores, yuv422p10le, 1440x1080, 116646 kb/s, PAR 4:3 DAR 16:9, 29.97 fps, 30k tbn (default)
    Metadata:
      creation_time   : 2015-05-14 21:19:06
    Stream #0.1(eng): Data: tmcd / 0x64636D74, 0 kb/s (default)
    Metadata:
      creation_time   : 2015-05-14 21:19:13
    Stream #0.2(eng): Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2015-05-14 21:19:13
[17:49:42] scan: decoding previews for title 1
Scanning title 1 of 1, preview 1, 50.00 %[17:49:43] scan: 2 previews, 1440x1080, 29.970 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 4:3
[17:49:43] scan: removing audio 0x2 because no bitrate found
[17:49:43] libhb: scan thread found 1 valid title(s)
+ title 1:
  + stream: /Users/philipmozolak/Desktop/2015-05-14-River/kD-30117_01.mov
  + duration: 00:00:12
  + size: 1440x1080, pixel aspect: 4/3, display aspect: 1.78, 29.970 fps
  + autocrop: 0/0/0/0
  + support opencl: no
  + support hwd: not built-in
  + chapters:
    + 1: cells 0->0, 0 blocks, duration 00:00:12
  + audio tracks:
  + subtitle tracks:
HandBrake has exited.

/usr/bin/transcode-video: undefined method `[]=' for nil:NilClass
philips-Mac-Pro:Desktop philipmozolak$  

Need help automating on windows 10

Sorry if this is the wrong place for this, but my scripting experience is near zero and I figured who better to help automate this than the author.

So I'm just trying to set up a simple script where the transcoder will run on a schedule, search an input directory for .mkv files, transcode them to an output directory, and then delete the original files. I'm just looking for a simple setup for the mother in laws HTPC. I'm trying to take most of the effort out of her ripping her dvd collection.

Thank you for your assistance.

mplayer not available

Running in OSX. I closed terminal in the middle of an encode and now get the following error:

/usr/local/bin/transcode-video: mplayer not available

mplayer was not an active process and rebooting didn't resolve the issue.

Passing Argument/Setting to HandbrakeCLI

In learning/applying the transcode-video tool, I saw that the DVD that was being transcoded was being done with h264 level 3.0; I was wondering if you could elucidate why that setting was chosen and if there is a way to pass a setting of 4.1 for example to HandbrakeCLI. For example, is the level for a Blu-Ray automatically 4.1? I tried a few combinations after reviewing the HandbrakeCLI and transcode-video --fullhelp and --help to pass the setting directly; I met with no success.

Thoughts?

Create output directory when it does not exist

I've run batch conversion on a folder, where I have couple files and got following output:

$ for i in *.mkv; do
    convert-video -o out/ ${i}
done

/usr/local/bin/convert-video: not a directory: out/
Try `/usr/local/bin/convert-video --help` for more information.

Why can't output directory be created if it does not exist?

Feature Request: add command-line options (and HB inputs) to the log output

Hi Don,

Just looking through 150+ transcodes from the last month from the bash scripts/new Ruby ones and would appreciate if you could include the command (and options) as typed in the resultant output log. It would be really useful to see what was run instead of reconstructing it from the HB summary.

Also, could the --dry-run output be included too? Both of these are really useful post-transcoding especially for those of us who retain the logs and historically look back to see what was run.

Thanks again for all the hard work and for sharing these with us.
Joe

Stutter in source causes loss of video (possible Handbrake issue), add warning?

I'm ripping and transcoding my Sopranos DVD boxset.
Luckily for me I started also watching the show before finishing all of the episodes (about 25% left) and I noticed S01E01 ended at 53:15 (it's susposed to be around 1 hour).
So I went to look at the log for the particular episode and see this:

Encoding: task 1 of 1, 88.58 % (139.56 fps, avg 137.33 fps, ETA 00h01m15s) 
Encoding: task 1 of 1, 88.62 % (139.56 fps, avg 137.33 fps, ETA 00h01m15s)[18:12:38] reader: done. 1 scr changes

Encoding: task 1 of 1, 88.68 % (139.56 fps, avg 137.33 fps, ETA 00h01m15s)
Encoding: task 1 of 1, 88.68 % (139.56 fps, avg 137.33 fps, ETA 00h01m15s)[18:12:39] work: average encoding speed for job is 137.333069 fps

Encoding: task 1 of 1, 88.68 % (139.56 fps, avg 137.33 fps, ETA 00h01m15s)[18:12:39] sync: got 79895 frames, 90088 expected
[18:12:39] render: lost time: 0 (0 frames)
[18:12:39] render: gained time: 0 (0 frames) (0 not accounted for)
[18:12:39] mpeg2video-decoder done: 79895 frames, 0 decoder errors, 0 drops

I went and checked the raw mkv file (from MakeMKV) and it was full-length, however at the 53:15 mark there is a stutter where it seems to freeze for 1 second (probably from the source dvd being scratched or the dvd-drive being bad I'm guessing.)
I tried encoding the same episode using Handbrake GUI (High Profile, burned in subtitles) and the same issue happened there, so it's an issue with Handbrake, and not your script particularly.

So that's fine, I can just re-rip that particular episode (S01E02 and S01E03 from the same disc seems fine) and hope I don't get a stutter in the same spot again. But I would like if your script warned me with something similar to "This transcode is shorter than the source, possibly bad source." and paused the script so I could acknowledge it and know to make a new rip (I made a shell script with a bunch of transcode-video commands for each episode (because some are interlaced and some aren't for example) so I didn't see when it jumped from Encoding: 88.68% to completion because it had moved on to the next episode.
I'm now gonna have to check every transcoded episode and make sure I see the credits at the end.

I'm attaching mediainfo for the transcode and raw mkv and log from your script.
s01e01.mp4.log.txt
mediainfo_title00.mkv.txt
mediainfo_s01e01.mp4.txt

Here's the transcode-video command I used for S01E01:

transcode-video --mp4 --720p --burn-subtitle 1 --filter deinterlace=1 /Volumes/1tb/SOPRANOS_SEASON1_DISC2/title00.mkv --o "Sopranos S01E04 [swesub-burned, dvdrip, x264, donmelton-script, 2-1-2016].mp4"

Chapter names not working with HandBrake nightly builds

Using version 5.0 of the transcode video script I've been unable to get the --chapter-names option to work. Attached is a .txt version of the chapter names file I was using (I know it needs to be .csv but GitHub wouldn't accept an upload in that format). Also attached is the resultant log file (again in .txt rather than .log).

GDT.txt
The Girl With The Dragon Tattoo.mkv.txt

I've previously used the bash version of your script and had little issue with chapter names.

Why handbrake 0.10.0?

I'm running CentOS 7, and the newest HandBrake-cli I can get out of a repo is 0.9.9. I can build a newer version, but that's... well it's painful in the environment I'm in.

Is there any reason for 0.10.0, or will 0.9.9 work in most cases? Is there a way to avoid the version check?

Add documentation for handling when handbrake and mplayer disagree

Running detect-crop on a movie returned the following:

Results differ...

# From HandBrakeCLI:

mplayer -really-quiet -nosound -vf rectangle=1920:816:0:132 /path/to/Movie.mkv
mplayer -really-quiet -nosound -vf crop=1920:816:0:132 /path/to/Movie.mkv

transcode-video --crop 132:132:0:0 /path/to/Movie.mkv

# From mplayer:

mplayer -really-quiet -nosound -vf rectangle=1920:818:0:132 /path/to/Movie.mkv
mplayer -really-quiet -nosound -vf crop=1920:818:0:132 /path/to/Movie.mkv

transcode-video --crop 132:130:0:0 /path/to/Movie.mkv

The difference appears very minor in this case but it serves as an example. Are there details and/or a rule of thumb that can be added to the documentation on which transcode-video string would be the better choice?

no H.264 format video track:

Hey,
Im currently getting this error when testing out convert-video. Not sure why. Any suggestions?

Just to confirm the video track is H264

Not working due to ffmpeg issue

root@billiards:/media/media5/Plex/Movies# convert-video movie.mkv
/usr/local/bin/convert-video: ffmpeg version unknown

Ubuntu 14.04

root@billiards:/media/media5/Plex/Movies# ffmpeg -version
ffmpeg version N-75159-g319898b Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
configuration: --disable-asm --enable-libx264 --enable-gpl
libavutil 55. 1.100 / 55. 1.100
libavcodec 57. 1.100 / 57. 1.100
libavformat 57. 0.100 / 57. 0.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 1.100 / 6. 1.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.100 / 2. 0.100
libpostproc 54. 0.100 / 54. 0.100

--crop detect returns "/usr/local/bin/transcode-video: mplayer version unknown"

When using the --crop detect parameter, conversion refuses to start and returns the error "/usr/local/bin/transcode-video: mplayer version unknown"

I am fully up-to-date on OS X, 'brew update/upgrade', as well as having both the old transcode-video.sh script still installed (but am using the new ruby gem), in case that helps diagnose.

Feature Request: Write to tmp file during transcode

I'm transcoding a batch of mkv files. My process is:

  1. Put a bunch of .mkv files in a directory.

  2. Manually run detect-crop on each one to get the "transcode-video" recommendations.

  3. Create a transcode.bash script in the source directory with a line for each transcode call. For example:

    #!/bin/bash
    
    transcode-video --mp4 --crop 0:0:0:0 PrettyGoodMovie.mkv
    transcode-video --mp4 --crop 132:132:0:0 AwesomeMovie.mkv
    # etc...
    
  4. Run the script overnight to process as many movies as possible.

  5. Stop the script in the morning when I have to go to work.

  6. Figure out which movie was only partially transcoded.

  7. Delete the partial file so the next time the script is run the full movie gets transcoded.


My suggestion is to update the 'transcode-video' script to write the output file to a temporary location (e.g. "AwesomeMovie.mp4.tmp") during the transcoding. Then, when the transcoding is complete, rename it to its final name (e.g. "AwesomeMovie.mp4").

Aside from batch runs, this will also help avoid confusion for simple calls if the transcoding chokes or is stopped before finishing. It'll be evident by the fact that the file still has a temporary extension that the process didn't complete.

Proposal to lower target video bitrates (again)

Proposal to lower target video bitrates (again)

The 0.6 release of the video_transcoding Gem contained perhaps the most significant change to the transcode-video tool since the deprecated --big option became the default behavior. Not only was the ratecontrol system enhanced to produce higher quality, the target bitrates for 480i and 720p content were lowered to limit the higher bitrates produced by that higher quality.

For the upcoming 0.7 release, I propose to lower those video bitrate targets again, and not just for 480i and 720p content. The targets for 2160p (4K/UHD) content would also be lowered. However, I'm not proposing any change to bitrate targets for 1080p.

Also different for 0.7 would be lowering the targets when using the --small or --small-video options.

Default target video bitrate

Input resolution Version 0.5.x Version 0.6 Proposed 0.7
2160p or 4K/UHD video 16000 Kbps (same) 12000 Kbps
1080p or Blu-ray video 8000 Kbps (same) (same)
720p 6000 Kbps 5000 Kbps 4000 Kbps
480i, 576p or DVD video 3000 Kbps 2500 Kbps 2000 Kbps

Target video bitrate with --small or --small-video

Input resolution Version 0.5.x Version 0.6 Proposed 0.7
2160p or 4K/UHD video 10000 Kbps (same) 8000 Kbps
1080p or Blu-ray video 5000 Kbps (same) (same)
720p 4000 Kbps (same) 3000 Kbps
480i, 576p or DVD video 2000 Kbps (same) 1600 Kbps

OK, what's the rationale for doing this?

First, the new ratecontrol system introduced in version 0.6 with a constant rate factor (CRF) quality target of 1 does much better at putting pressure on x264 to hit that target bitrate than the old quality target of 16 ever did. So, bitrates are higher now. Weirdly, 480i and 720p content is suddenly too good. And that seems very wasteful of space.

Second, these proposed targets seem to be more in line with what Apple, Netflix, warez (you know what I mean), etc. are doing now as opposed to what they were doing when the project started.

This makes sense to me and my tests so far indicate that quality is still good with lower target video bitrates.

BTW, you can try any of these targets yourself by setting vbv-maxrate directly like this:

transcode-video --encoder-option vbv-maxrate=4000 "/path/to/Movie.mkv"

So, I'm asking for your feedback. Let me know what you think. Soon. Because I'm liable to make the change as early as next week.

Thanks.

MacPorts has all the required support packages too

With almost the same package names as homebrew, so this works:

port install ffmpeg
port install mkvtoolnix
port install mp4v2
port install mpv

Apparently mplayer2 is obsolete and replaced with mpv. To be honest I don't have either installed and just use VLC / QuickTime Player.

using --force-subtitle option doesn't seem to set the force-flag on the subtitle

I ran the following command:

transcode-video --main-audio 1 --add-audio 2 --add-audio 3="Creator's Commentary" --audio-width all=double --force-subtitle 5 --quick -o "Bourne Supremacy - quick.mkv" /pathToSource/Filme/Bourne/The\ Bourne\ Supremacy\ -\ Die\ Bourne\ Verschwoฬˆrung\ -\ K09.mkv

the result transcodes finde and the subtitle 5 is included, but when I run mediainfo on the resulting mkv, it claims that only the "default" flag is set to yes but the forced flag is set to "no". I thought according --help that it is supposed to set the forced flag on the subtitle.

MPEG-TS, subtitles and Video Transcoding

I live in a country where English is a foreign language and movies are
not dubbed so it is important to be able to preserve the subtitles in videos when editing or transcoding.

I have a lot of videos (mostly movies) which have been recorded on either my DVB-S or my DVB-T receiver. In both cases the stored recording is a straight dump of the transport stream received. So far I have not found any program that can convert the transport stream to anything that an editor or a transcoding program will handle and still preserve the subtitles.

Your excellent Video Transcoding suite of scripts seems to be my best possibility so far. The scripts work beautifully when working with e.g. videos ripped from a DVD. Unfortunately I have been unable to make it work for MPEG-TSs. I have a 7 minute recording I use for all my trials. Running it through 'mediainfo' I get the following:

General
ID : 1002 (0x3EA)
Complete name : Kristendommens historie.ts
Format : MPEG-TS
File size : 120 MiB
Duration : 7mn 29s
Overall bit rate mode : Variable
Overall bit rate : 2 233 Kbps

Video
ID : 2111 (0x83F)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : [email protected]
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : 27
Duration : 7mn 29s
Width : 704 pixels
Height : 576 pixels
Display aspect ratio : 16:9
Frame rate : 25.000 fps
Standard : PAL
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : MBAFF
Color primaries : BT.601 NTSC
Transfer characteristics : BT.601
Matrix coefficients : BT.601

Audio
ID : 2121 (0x849)
Menu ID : 1 (0x1)
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Muxing mode : LATM
Codec ID : 17
Duration : 7mn 29s
Bit rate mode : Variable
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Delay relative to video : -907ms
Language : Danish

Text #1
ID : 2031 (0x7EF)-104
Menu ID : 1 (0x1)
Format : Teletext
Language : Danish

Text #2
ID : 2135 (0x857)
Menu ID : 1 (0x1)
Format : DVB Subtitle
Codec ID : 6
Duration : 7mn 25s
Delay relative to video : 3s 878ms
Language : Danish

Text #3
ID : 2136 (0x858)
Menu ID : 1 (0x1)
Format : DVB Subtitle
Codec ID : 6
Duration : 7mn 25s
Delay relative to video : 3s 878ms
Language : Danish

Menu
ID : 2100 (0x834)
Menu ID : 1 (0x1)
Duration : 7mn 29s
List : 90 (0x5A) () / 91 (0x5B) () / 2031 (0x7EF) () / 2111 (0x83F) (AVC) / 2121 (0x849) (AAC, Danish) / 2135 (0x857) (DVB Subtitle, Danish) / 2136 (0x858) (DVB Subtitle, Danish)
Language : / / / / Danish / Danish / Danish

(the title of the video is Danish for 'The History of Christianity')

However, running the video through 'transcode-video โ€“scan' I get this:

`

  • title 1:
    • stream: Kristendommens historie.ts
    • duration: 00:07:24
    • size: 704x576, pixel aspect: 16/11, display aspect: 1.78, 25.000 fps
    • chapters:
      • 1: cells 0->0, 0 blocks, duration 00:07:24
    • audio tracks:
      • 1, Dansk (LC) (2.0 ch) (iso639-2: dan)
    • subtitle tracks:

`
Is there any possiblity to make transcode-video handle subtitle tracks in a MPEG-TS?

Dolby Digital Plus support

Reading the tech specs for the new Apple TV, it supports Dolby Digital Plus 7.1 which Handbrake supports encoding to with aencoder=eac3. Dolby Digital Plus is reportedly twice as efficient as AC3, has more channels, and allows for higher overall bitrate. Would it be possible to add support to use Dolby Digital Plus for surround tracks? Thanks!

No-hands-batch

I am trying to set up a batch to convert files without any involvment from my side (om my server).

Would like to use your workflow, but my knowledge in scripting does not reach this far (have spent many hours googling to try and solve this, but with no luck).

I am using Hazel, and I guess it is kind of easy to adapt the workflow (if I only knew how).

What I would like to accomplish is to put videofiles (avi, mkv, video_ts) in one folder and trigger your scripts.

Here is the Hazel documentation:
Using Hazel's "Passes shell script" condition or "Run shell script" action, you can have Hazel run shell scripts or trigger any external command-line program. Some important points about running scripts/programs with Hazel:

Hazel will pass one argument which is the path of the file being processed.
The program/script can be written in any language (including Perl and Python) as long as you tell Hazel which shell/interpreter to use.

Embeded vs. External
Hazel can run scripts in one of two ways: embedded or external.

When running an embedded script, you can enter the script using Hazel's built-in editor. Here you can also specify the shell/interpreter to use (sh, perl, python, etc). Embedded scripts are stored with your rules and therefore do not need to be exported/imported separately when transferring your rules.

When using an external script, you can have Hazel trigger a script/program already on your disk. The program must be executable. If it is a script, it should start with a sha-bang (#!) line to indicate which interpreter to use. When transferring rules between machines, the scripts must be transferred separately.

Using shellscripts for use in a rule condition
When using scripts in a rule condition, the script should exit with a 0 status to indicate that the file passes the condition. Any other exit status will tell Hazel that the file does not match the condition.
Since rule conditions tend to be evaluated many times, you should make sure the scripts runs quickly. Time consuming scripts will greatly affect performance.
The script must not modify any files or folders underneath the folder Hazel is monitoring as it can result in a loop where Hazel never stops processing the folder.

Using shellscripts for use in a rule action
When using scripts via the "Run shell script" action, the script should return 0 to indicate that the action was performed successfully. Any other value indicates an error and the rule will be re-executed until the action proceeds successfully.*

query-handbrake-log reports wrong time and speed when parsing logs with subtitle scan mode data

This is a separate issue to that described in #45.

When using the "--burn-subtitle scan" command from transcode-video, the resultant log file produces incorrect value for speed when processed with query-handbrake-log. Attached below are two log files produced from encoding the same file with identical setting except one uses "--burn-subtitle scan" and the other doesn't. You should see 21.032848 fps from one log and 0.0 fps from the other.

MIB chapter 11.mkv.txt
MIB chapter 11 Subtitles.mkv.txt

P.S. You'll also notice the same issue as described in #45 affecting both log files, although the one produced with "--burn-subtitle scan" reports the time as NaN rather than 00:00:00.

transcode-video: mp4track version unknown

Running ubuntu 15.10. Can confirm mp4track is installed and the correct version but transcode video is not picking this up.

/usr/local/bin/transcode-video: mp4track version unknown

user@video-transcode:~/output$ mp4track --version
mp4track - MP4v2 -r

Request to allow transcode-video to continue with default crop values if both tests differ when using detect-crop

When using detect-crop in the same argument as transcode-video, if the results differ between mplayer and handbrake, the script will fail. I'd like to request an option to allow the script to continue with default 0:0:0:0 cropping values instead of the script halting.

The is beneficial if you want to attempt to get correct cropping values, but trust if results differ between the two tests, something must be up, so continue safely with default values.

This is even more beneficial when you load up multiple inputs (like DVD extras or multiple movies) and you want to attempt to crop correctly when the tests agree, but don't want to monitor it.

Convert hevc (x265) video to mp4 not working

Hi, I', trying to convert an hevc video file to mp4, but the command complains about not finding any h264 track, is there a way to tell it to search for h265 or havoc?

Thanks,

--bind-srt-encoding or --bind-srt-language flags cause recursive array join error

ran transcode-video with the following arguments:
transcode-video --add-srt /Volumes/BitBucket/batch-mkv/Subtitles/Paper\ Towns.srt --bind-srt-language eng --bind-srt-encoding UTF-8 --mp4 /Volumes/BitBucket/MakeMKV\ Destination/Paper\ Towns.mkv
I get an error returned:
/usr/bin/transcode-video: recursive array join

If I remove either --bind-srt-language OR --bind-srt-encoding but leave the other flag in, I still get the error. Removing both flags causes the error to not occur and the transcoding completes successfully.

Error: "invalid subtitle track information"

Problem

I'm getting an "invalid subtitle track information" error when attempting to transcode an MKV file that contains a subtitle track. In fact, this error is appearing for other MakeMKV rips that do not include subtitles. There are no issues when transcoding these files with the old bash scripts.

Software Versions

  • Windows 8.1
  • Cygwin: 2.0.1
  • Ruby: 2.0.0p598
  • video_transcoding: 0.2.2
  • HandBrake: 0.10.1

Command Output

$ transcode-video -vv title01.mkv 
transcode-video 0.2.2
Copyright (c) 2013-2015 Don Melton
Processing: title01.mkv...
Scanning media title 1 with HandBrakeCLI...
HandBrake 0.10.1 found...
[02:41:30] hb_init: starting libhb thread
HandBrake 0.10.1 (2015030800) - MinGW x86_64 - https://handbrake.fr
4 CPUs detected
Opening title01.mkv...
[02:41:30] CPU: Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz
[02:41:30]  - Intel microarchitecture Haswell
[02:41:30]  - logical processor count: 4
[02:41:30] OpenCL device #1: Advanced Micro Devices, Inc. Pitcairn
[02:41:30]  - OpenCL version: 1.2 AMD-APP (1445.5)
[02:41:30]  - driver version: 1445.5 (VM)
[02:41:30]  - device type:    GPU
[02:41:30]  - supported:      YES
[02:41:30] Intel Quick Sync Video support: no
[02:41:30] hb_scan: path=title01.mkv, title_index=1
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening title01.mkv/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening title01.mkv/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(title01.mkv) failed
[02:41:30] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[02:41:30] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'title01.mkv':
  Metadata:
    title           : BABYLON 5 IN THE BEGINNING
  Duration: 01:34:17.65, start: 0.000000, bitrate: N/A
    Chapter #0.0: start 0.066733, end 71.771700
    Metadata:
      title           : Chapter 01
    Chapter #0.1: start 71.771700, end 341.074067
    Metadata:
      title           : Chapter 02
    Chapter #0.2: start 341.074067, end 605.371433
    Metadata:
      title           : Chapter 03
    Chapter #0.3: start 605.371433, end 851.750900
    Metadata:
      title           : Chapter 04
    Chapter #0.4: start 851.750900, end 962.261300
    Metadata:
      title           : Chapter 05
    Chapter #0.5: start 962.261300, end 1181.079900
    Metadata:
      title           : Chapter 06
    Chapter #0.6: start 1181.079900, end 1341.239900
    Metadata:
      title           : Chapter 07
    Chapter #0.7: start 1341.239900, end 1429.461367
    Metadata:
      title           : Chapter 08
    Chapter #0.8: start 1429.461367, end 1580.512267
    Metadata:
      title           : Chapter 09
    Chapter #0.9: start 1580.512267, end 1720.852467
    Metadata:
      title           : Chapter 10
    Chapter #0.10: start 1720.852467, end 1962.160200
    Metadata:
      title           : Chapter 11
    Chapter #0.11: start 1962.160200, end 2150.281467
    Metadata:
      title           : Chapter 12
    Chapter #0.12: start 2150.281467, end 2330.761767
    Metadata:
      title           : Chapter 13
    Chapter #0.13: start 2330.761767, end 2465.162700
    Metadata:
      title           : Chapter 14
    Chapter #0.14: start 2465.162700, end 2615.579633
    Metadata:
      title           : Chapter 15
    Chapter #0.15: start 2615.579633, end 2945.208933
    Metadata:
      title           : Chapter 16
    Chapter #0.16: start 2945.208933, end 3079.843433
    Metadata:
      title           : Chapter 17
    Chapter #0.17: start 3079.843433, end 3297.260633
    Metadata:
      title           : Chapter 18
    Chapter #0.18: start 3297.260633, end 3556.119233
    Metadata:
      title           : Chapter 19
    Chapter #0.19: start 3556.119233, end 3743.940200
    Metadata:
      title           : Chapter 20
    Chapter #0.20: start 3743.940200, end 3934.931000
    Metadata:
      title           : Chapter 21
    Chapter #0.21: start 3934.931000, end 4188.951433
    Metadata:
      title           : Chapter 22
    Chapter #0.22: start 4188.951433, end 4330.125800
    Metadata:
      title           : Chapter 23
    Chapter #0.23: start 4330.125800, end 4521.049867
    Metadata:
      title           : Chapter 24
    Chapter #0.24: start 4521.049867, end 4672.701367
    Metadata:
      title           : Chapter 25
    Chapter #0.25: start 4672.701367, end 4890.652433
    Metadata:
      title           : Chapter 26
    Chapter #0.26: start 4890.652433, end 5118.379933
    Metadata:
      title           : Chapter 27
    Chapter #0.27: start 5118.379933, end 5335.897233
    Metadata:
      title           : Chapter 28
    Chapter #0.28: start 5335.897233, end 5604.098500
    Metadata:
      title           : Chapter 29
    Chapter #0.29: start 5604.098500, end 5657.652000
    Metadata:
      title           : Chapter 30
    Stream #0.0(eng): Video: mpeg2video (Main), yuv420p, 720x480 [PAR 32:27 DAR 16:9], 7500 kb/s, PAR 186:157 DAR 279:157, 29.97 fps, 1k tbn, 59.94 tbc
    Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s (default)
    Metadata:
      title           : Surround 5.1
    Stream #0.2(eng): Subtitle: dvdsub (default)
[02:41:30] dxva2:IDirect3D9_GetAdapterIdentifier failed
[02:41:30] dxva2:IDirect3D9_CreateDevice failed
[02:41:30] dxva2:Failed to create Direct3D device
[02:41:30] scan: decoding previews for title 1
[02:41:30] scan: audio 0x1: ac3, rate=48000Hz, bitrate=448000 English (AC3) (5.1 ch)
[02:41:31] scan: 2 previews, 720x480, 29.970 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 32:27
[02:41:31] libhb: scan thread found 1 valid title(s)
+ title 1:
  + stream: title01.mkv
  + duration: 01:34:17
  + size: 720x480, pixel aspect: 32/27, display aspect: 1.78, 29.970 fps
  + autocrop: 0/0/0/0
  + support opencl: yes
  + support hwd: no
  + chapters:
    + 1: cells 0->0, 0 blocks, duration 00:01:12
    + 2: cells 0->0, 0 blocks, duration 00:04:29
    + 3: cells 0->0, 0 blocks, duration 00:04:24
    + 4: cells 0->0, 0 blocks, duration 00:04:06
    + 5: cells 0->0, 0 blocks, duration 00:01:51
    + 6: cells 0->0, 0 blocks, duration 00:03:39
    + 7: cells 0->0, 0 blocks, duration 00:02:40
    + 8: cells 0->0, 0 blocks, duration 00:01:28
    + 9: cells 0->0, 0 blocks, duration 00:02:31
    + 10: cells 0->0, 0 blocks, duration 00:02:20
    + 11: cells 0->0, 0 blocks, duration 00:04:01
    + 12: cells 0->0, 0 blocks, duration 00:03:08
    + 13: cells 0->0, 0 blocks, duration 00:03:00
    + 14: cells 0->0, 0 blocks, duration 00:02:14
    + 15: cells 0->0, 0 blocks, duration 00:02:30
    + 16: cells 0->0, 0 blocks, duration 00:05:30
    + 17: cells 0->0, 0 blocks, duration 00:02:15
    + 18: cells 0->0, 0 blocks, duration 00:03:37
    + 19: cells 0->0, 0 blocks, duration 00:04:19
    + 20: cells 0->0, 0 blocks, duration 00:03:08
    + 21: cells 0->0, 0 blocks, duration 00:03:11
    + 22: cells 0->0, 0 blocks, duration 00:04:14
    + 23: cells 0->0, 0 blocks, duration 00:02:21
    + 24: cells 0->0, 0 blocks, duration 00:03:11
    + 25: cells 0->0, 0 blocks, duration 00:02:32
    + 26: cells 0->0, 0 blocks, duration 00:03:38
    + 27: cells 0->0, 0 blocks, duration 00:03:48
    + 28: cells 0->0, 0 blocks, duration 00:03:38
    + 29: cells 0->0, 0 blocks, duration 00:04:28
    + 30: cells 0->0, 0 blocks, duration 00:00:54
  + audio tracks:
    + 1, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 448000bps
  + subtitle tracks:
    + 1, English (iso639-2: eng) (Bitmap)(VOBSUB)

HandBrake has exited.
transcode-video: invalid subtitle track information: 

$ 

Any ideas? Let me know if you need any more info or testing on my end.

Cheers!
David

mkv v. mp4: --no-auto-burn works in .mkv but burns-in when output is mp4

Hi Don,

I'm not sure if this is a bug, user error or a "feature" of .mp4 but I've come across a problem with Crouching Tiger, Hidden Dragon and mkv/mp4 subtitle behaviours.

AIM: Chinese track (160 stereo + 640 5.1) + English subtitles (separate track, not burned in)
English dubbed (160 stereo + 640 5.1) + no subtitles

Starting BluRay MKV

screen shot 2015-05-11 at 23 14 47

Command run for Matroska
transcode-video --crop 140:140:0:0 --quick --big --main-audio 2=Chinese --add-audio 1=Engish --audio-width 1=double --add-subtitle 1 --no-auto-burn 'Crouching Tiger Hidden Dragon (2000).mkv'

This outputs the following (correctly achieving the above aim):

[23:07:29] job configuration:
[23:07:29]  * source
[23:07:29]    + Crouching Tiger Hidden Dragon (2000).mkv
[23:07:29]    + title 1, chapter(s) 4 to 4
[23:07:29]    + container: matroska,webm
[23:07:29]  * destination
[23:07:29]    + /Volumes/4TB Hitachi/Rips/test.mkv
[23:07:29]    + container: Matroska (libavformat)
[23:07:29]  * video track
[23:07:29]    + decoder: h264
[23:07:29]    + filters
[23:07:29]      + Framerate Shaper (2:27000000:900000)
[23:07:29]        + frame rate: 23.976 fps -> peak rate limited to 30.000 fps
[23:07:29]      + Crop and Scale (1920:800:140:140:0:0)
[23:07:29]        + source: 1920 * 1080, crop (140/140/0/0): 1920 * 800, scale: 1920 * 800
[23:07:29]    + strict anamorphic
[23:07:29]      + storage dimensions: 1920 * 800, mod 0
[23:07:29]      + pixel aspect ratio: 1 / 1
[23:07:29]      + display dimensions: 1920 * 800
[23:07:29]    + encoder: H.264 (libx264)
[23:07:29]      + options: vbv-maxrate=8000:vbv-bufsize=4000:crf-max=25:ref=1:weightp=1:subme=6:mixed-refs=0:rc-lookahead=30
[23:07:29]      + quality: 16.00 (RF)
[23:07:29]  * subtitle track 1, English (track 3, id 0x3) Picture [PGS] -> Passthrough
[23:07:29]  * audio track 1
[23:07:29]    + name: Chinese
[23:07:29]    + decoder: Chinese (FLAC) (5.1 ch) (track 2, id 0x2)
[23:07:29]      + samplerate: 48000 Hz
[23:07:29]    + mixdown: 5.1 Channels
[23:07:29]    + encoder: AC3 (libavcodec)
[23:07:29]      + bitrate: 640 kbps, samplerate: 48000 Hz
[23:07:29]  * audio track 2
[23:07:29]    + name: Chinese
[23:07:29]    + decoder: Chinese (FLAC) (5.1 ch) (track 2, id 0x2)
[23:07:29]      + samplerate: 48000 Hz
[23:07:29]    + mixdown: Dolby Pro Logic II
[23:07:29]    + encoder: AAC (Apple AudioToolbox)
[23:07:29]      + bitrate: 160 kbps, samplerate: 48000 Hz
[23:07:29]  * audio track 3
[23:07:29]    + name: Engish
[23:07:29]    + decoder: English (FLAC) (5.1 ch) (track 1, id 0x1)
[23:07:29]      + samplerate: 48000 Hz
[23:07:29]    + mixdown: 5.1 Channels
[23:07:29]    + encoder: AC3 (libavcodec)
[23:07:29]      + bitrate: 640 kbps, samplerate: 48000 Hz
[23:07:29]  * audio track 4
[23:07:29]    + name: Engish
[23:07:29]    + decoder: English (FLAC) (5.1 ch) (track 1, id 0x1)
[23:07:29]      + samplerate: 48000 Hz
[23:07:29]    + mixdown: Dolby Pro Logic II
[23:07:29]    + encoder: AAC (Apple AudioToolbox)
[23:07:29]      + bitrate: 160 kbps, samplerate: 48000 Hz
[23:07:29] encx264: min-keyint: 24, keyint: 240
[23:07:29] encx264: encoding at constant RF 16.000000
[23:07:29] encx264: unparsed options: vbv-maxrate=8000:vbv-bufsize=4000:crf-max=25:ref=1:weightp=1:subme=6:mixed-refs=0:rc-lookahead=30
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
x264 [info]: profile High, level 4.0

If you output an mp4 version by adding the --mp4, the subtitle passthrough switches to Render/Burn-in ... which is ok for the default Chinese + English subtitle ... but not good when playing the English sound-track as the English subtitles are burned onto the video track already.

transcode-video --crop 140:140:0:0 --mp4 --quick --big --main-audio 2=Chinese --add-audio 1=Engish --audio-width 1=double --add-subtitle 1 --no-auto-burn 'Crouching Tiger Hidden Dragon (2000).mkv'

[23:09:19] * subtitle track 1, English (track 3, id 0x3) Picture [PGS] -> Render/Burn-in

Am I doing something incorrectly?

Many thanks,
Joe

detect-crop doesn't work on Lord of rings 3

I ripped a DVD of Lord of the rings 3 and the mkv file is fine for playback but detect-crop only shows 3 dot-lines. It works in general when I supply another film, but only with this one (I also tried renaming it, but it wasn't the name), it doesn't work.

Possibly using incorrect bitrate when scaling down to 480p.

Hi.

When using transcode-video with a 1080p source for example, I like to create both an HD and SD version. For the SD version, I target a max width and height that matches 480p by using args --max-width 854 --max-height 480. This is the standard width and height of 480p.

The problem is that transcode-video has a block that sets vbv_maxrate this way:

...
elsif width > 720 or height > 576
handbrake_options['encoder-level'] = '3.1'
vbv_maxrate = @vbv_maxrate_720p
else
handbrake_options['encoder-level'] = '3.0'
vbv_maxrate = @vbv_maxrate_480p
end

Because 480p has a standard width of 854, the "width > 720" matches, and @vbv_maxrate_720p is used instead of @vbv_maxrate_480p

Perhaps it would be better to use

elsif width > 854 or height > 576

here instead?

Forced-subtitles not being detected (?)

Hi Don,

Hope you're well and enjoying the summer?

Quick issue has me stumped and probably user-error but I've run a test transcoding of the "The Da Vinci Code" DVD for a friend and the new ruby scripts seem to be missing the forced-subtitle sequences when .mkv/.mp4 files are produced. (Running the latest Ruby scripts with HandBrakeCLI 0.10.2)

I did two quick tests to check that the forced subtitles were burned in for the French sequence in Ch. 3:

Test 1
transcode-video --crop 74:74:0:0 --quick --chapters 3 --mp4 --force-subtitle scan 'The Da Vinci Code (2006).mkv'

Test 2
transcode-video --crop 74:74:0:0 --quick --chapters 3 --mp4 --burn-subtitle scan --force-subtitle scan 'The Da Vinci Code (2006).mkv'

HandBrakeCLI failed to detect a suitable candidate for forced-subtitles on both of the above.

[15:53:31] Subtitle track 2 (id 0x2) 'English': 71 hits (19 forced)
[15:53:31] Subtitle track 3 (id 0x3) 'English': 80 hits (0 forced)
[15:53:31] No candidate detected during subtitle scan

The following did work (explicitly telling HandBrakeCLI to scan for and burn them in):
Test 3
transcode-video --crop 74:74:0:0 --quick --chapters 3 --mp4 -H subtitle=scan -H subtitle-forced -H subtitle-burned --dry-run 'The Da Vinci Code (2006).mkv'

Test 4
Similarly, the older bash scripts worked when the following was run:
transcode-video.sh --find-forced burn --chapters 3 --fast 'The Da Vinci Code (2006).mkv'

In tests 3/4, HandBrakeCLI picked up the following and correctly burned-in the forced subtitles.
[14:36:24] * subtitle track 1, English (track 2, id 0x2) Picture [VOBSUB] -> Render/Burn-in, Forced Only

Have I used the incorrect settings on the Ruby scripts or is there a bug lingering somewhere?
Many thanks,
Joe Hurley


Some outputs for you:

.mkv file being used

General
Unique ID : 41071907310636362737018229354878173197 (0x1EE6295FAEFD5CAEB4A286E5CF23800D)
Complete name : /Volumes/4TB Hitachi/Rips/The Da Vinci Code (2006).mkv
Format : Matroska
Format version : Version 2
File size : 5.22 GiB
Duration : 2h 22mn
Overall bit rate mode : Variable
Overall bit rate : 5 237 Kbps
Movie name : Davinci
Encoded date : UTC 2015-07-07 11:37:23
Writing application : MakeMKV v1.9.4 darwin(x86-release)
Writing library : libmakemkv v1.9.4 (1.3.0/1.4.1) darwin(x86-release)
Video
ID : 1
Format : MPEG Video
Format version : Version 2
Format profile : Main@Main
Format settings, BVOP : Yes
Format settings, Matrix : Custom
Format settings, GOP : M=3, N=12
Format settings, picture structure : Frame
Codec ID : V_MPEG2
Codec ID/Info : MPEG 1 or 2 Video
Duration : 2h 22mn
Bit rate mode : Variable
Bit rate : 4 685 Kbps
Maximum bit rate : 9 800 Kbps
Width : 720 pixels
Height : 576 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 fps
Standard : PAL
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Interlaced
Scan order : Top Field First
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.452
Time code of first frame : 00:59:58:12
Time code source : Group of pictures header
GOP, Open/Closed : Open
Stream size : 4.67 GiB (89%)
Language : English
Default : No
Forced : No
Audio
ID : 2
Format : AC-3
Format/Info : Audio Coding 3
Mode extension : CM (complete main)
Format settings, Endianness : Big
Codec ID : A_AC3
Duration : 2h 22mn
Bit rate mode : Constant
Bit rate : 448 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Side: L R, LFE
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Compression mode : Lossy
Stream size : 457 MiB (9%)
Title : Surround 5.1
Language : English
Default : Yes
Forced : No
Text #1
ID : 3
Format : VobSub
Codec ID : S_VOBSUB
Codec ID/Info : Picture based subtitle format used on DVDs
Language : English
Default : Yes
Forced : No
Text #2
ID : 4
Format : VobSub
Codec ID : S_VOBSUB
Codec ID/Info : Picture based subtitle format used on DVDs
Language : English
Default : No
Forced : No
Menu
00:00:00.080 : en:Chapter 01
00:06:17.680 : en:Chapter 02
00:12:24.560 : en:Chapter 03
00:16:39.920 : en:Chapter 04
00:23:41.200 : en:Chapter 05
00:27:46.760 : en:Chapter 06
00:38:16.320 : en:Chapter 07
00:39:59.960 : en:Chapter 08
00:46:24.280 : en:Chapter 09
00:53:19.040 : en:Chapter 10
00:57:16.320 : en:Chapter 11
01:02:05.360 : en:Chapter 12
01:10:06.320 : en:Chapter 13
01:16:13.480 : en:Chapter 14
01:21:05.160 : en:Chapter 15
01:25:47.120 : en:Chapter 16
01:31:05.000 : en:Chapter 17
01:37:33.680 : en:Chapter 18
01:43:35.880 : en:Chapter 19
01:47:10.320 : en:Chapter 20
01:55:10.440 : en:Chapter 21
02:00:25.360 : en:Chapter 22
02:06:04.920 : en:Chapter 23
02:11:28.280 : en:Chapter 24

Test 1

Joes-MBP:Rips joe$ transcode-video --crop 74:74:0:0 --quick --chapters 3 --mp4 --force-subtitle scan 'The Da Vinci Code (2006).mkv'
invalid framerate 25.0
[15:53:30] hb_init: starting libhb thread
HandBrake 0.10.2 (2015060900) - Darwin x86_64 - https://handbrake.fr
8 CPUs detected
Opening The Da Vinci Code (2006).mkv...
[15:53:30] CPU: Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz
[15:53:30]  - Intel microarchitecture Haswell
[15:53:30]  - logical processor count: 8
[15:53:30] OpenCL device #1: Intel Iris Pro
[15:53:30]  - OpenCL version: 1.2 
[15:53:30]  - driver version: 1.2(Jun 10 2015 16:35:16)
[15:53:30]  - device type:    GPU
[15:53:30]  - supported:      YES
[15:53:30] OpenCL device #2: NVIDIA GeForce GT 750M
[15:53:30]  - OpenCL version: 1.2 
[15:53:30]  - driver version: 10.4.2 310.41.35f01
[15:53:30]  - device type:    GPU
[15:53:30]  - supported:      no
[15:53:30] hb_scan: path=The Da Vinci Code (2006).mkv, title_index=1
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening The Da Vinci Code (2006).mkv/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening The Da Vinci Code (2006).mkv/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(The Da Vinci Code (2006).mkv) failed
[15:53:30] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.1
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[15:53:30] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'The Da Vinci Code (2006).mkv':
  Metadata:
    title           : Davinci
  Duration: 02:22:42.52, start: 0.000000, bitrate: N/A
    Chapter #0.0: start 0.080000, end 377.680000
    Metadata:
      title           : Chapter 01
    Chapter #0.1: start 377.680000, end 744.560000
    Metadata:
      title           : Chapter 02
    Chapter #0.2: start 744.560000, end 999.920000
    Metadata:
      title           : Chapter 03
    Chapter #0.3: start 999.920000, end 1421.200000
    Metadata:
      title           : Chapter 04
    Chapter #0.4: start 1421.200000, end 1666.760000
    Metadata:
      title           : Chapter 05
    Chapter #0.5: start 1666.760000, end 2296.320000
    Metadata:
      title           : Chapter 06
    Chapter #0.6: start 2296.320000, end 2399.960000
    Metadata:
      title           : Chapter 07
    Chapter #0.7: start 2399.960000, end 2784.280000
    Metadata:
      title           : Chapter 08
    Chapter #0.8: start 2784.280000, end 3199.040000
    Metadata:
      title           : Chapter 09
    Chapter #0.9: start 3199.040000, end 3436.320000
    Metadata:
      title           : Chapter 10
    Chapter #0.10: start 3436.320000, end 3725.360000
    Metadata:
      title           : Chapter 11
    Chapter #0.11: start 3725.360000, end 4206.320000
    Metadata:
      title           : Chapter 12
    Chapter #0.12: start 4206.320000, end 4573.480000
    Metadata:
      title           : Chapter 13
    Chapter #0.13: start 4573.480000, end 4865.160000
    Metadata:
      title           : Chapter 14
    Chapter #0.14: start 4865.160000, end 5147.120000
    Metadata:
      title           : Chapter 15
    Chapter #0.15: start 5147.120000, end 5465.000000
    Metadata:
      title           : Chapter 16
    Chapter #0.16: start 5465.000000, end 5853.680000
    Metadata:
      title           : Chapter 17
    Chapter #0.17: start 5853.680000, end 6215.880000
    Metadata:
      title           : Chapter 18
    Chapter #0.18: start 6215.880000, end 6430.320000
    Metadata:
      title           : Chapter 19
    Chapter #0.19: start 6430.320000, end 6910.440000
    Metadata:
      title           : Chapter 20
    Chapter #0.20: start 6910.440000, end 7225.360000
    Metadata:
      title           : Chapter 21
    Chapter #0.21: start 7225.360000, end 7564.920000
    Metadata:
      title           : Chapter 22
    Chapter #0.22: start 7564.920000, end 7888.280000
    Metadata:
      title           : Chapter 23
    Chapter #0.23: start 7888.280000, end 8562.520000
    Metadata:
      title           : Chapter 24
    Stream #0.0(eng): Video: mpeg2video (Main), yuv420p, 720x576 [PAR 64:45 DAR 16:9], 9800 kb/s, 25 fps, 1k tbn, 50 tbc
    Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s (default)
    Metadata:
      title           : Surround 5.1
    Stream #0.2(eng): Subtitle: dvdsub (default)
    Stream #0.3(eng): Subtitle: dvdsub
[15:53:30] scan: decoding previews for title 1
[15:53:30] scan: audio 0x1: ac3, rate=48000Hz, bitrate=448000 English (AC3) (5.1 ch)
[15:53:30] scan: 10 previews, 720x576, 25.000 fps, autocrop = 74/74/0/0, aspect 16:9, PAR 64:45
[15:53:30] libhb: scan thread found 1 valid title(s)
+ title 1:
  + stream: The Da Vinci Code (2006).mkv
  + duration: 02:22:42
  + size: 720x576, pixel aspect: 64/45, display aspect: 1.78, 25.000 fps
  + autocrop: 74/74/0/0
  + support opencl: yes
  + support hwd: not built-in
  + chapters:
    + 1: cells 0->0, 0 blocks, duration 00:06:18
    + 2: cells 0->0, 0 blocks, duration 00:06:07
    + 3: cells 0->0, 0 blocks, duration 00:04:15
    + 4: cells 0->0, 0 blocks, duration 00:07:01
    + 5: cells 0->0, 0 blocks, duration 00:04:06
    + 6: cells 0->0, 0 blocks, duration 00:10:30
    + 7: cells 0->0, 0 blocks, duration 00:01:44
    + 8: cells 0->0, 0 blocks, duration 00:06:24
    + 9: cells 0->0, 0 blocks, duration 00:06:55
    + 10: cells 0->0, 0 blocks, duration 00:03:57
    + 11: cells 0->0, 0 blocks, duration 00:04:49
    + 12: cells 0->0, 0 blocks, duration 00:08:01
    + 13: cells 0->0, 0 blocks, duration 00:06:07
    + 14: cells 0->0, 0 blocks, duration 00:04:52
    + 15: cells 0->0, 0 blocks, duration 00:04:42
    + 16: cells 0->0, 0 blocks, duration 00:05:18
    + 17: cells 0->0, 0 blocks, duration 00:06:29
    + 18: cells 0->0, 0 blocks, duration 00:06:02
    + 19: cells 0->0, 0 blocks, duration 00:03:34
    + 20: cells 0->0, 0 blocks, duration 00:08:00
    + 21: cells 0->0, 0 blocks, duration 00:05:15
    + 22: cells 0->0, 0 blocks, duration 00:05:40
    + 23: cells 0->0, 0 blocks, duration 00:05:23
    + 24: cells 0->0, 0 blocks, duration 00:11:14
  + audio tracks:
    + 1, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 448000bps
  + subtitle tracks:
    + 1, English (iso639-2: eng) (Bitmap)(VOBSUB)
    + 2, English (iso639-2: eng) (Bitmap)(VOBSUB)
Subtitle Scan Enabled - enabling subtitles if found for foreign language segments
[15:53:31] 2 job(s) to process
[15:53:31] starting job
[15:53:31] sync: expecting 6384 video frames
[15:53:31] work: only 1 chapter, disabling chapter markers
[15:53:31] job configuration:
[15:53:31]  * source
[15:53:31]    + The Da Vinci Code (2006).mkv
[15:53:31]    + title 1, chapter(s) 3 to 3
[15:53:31]    + container: matroska,webm
[15:53:31]  * destination
[15:53:31]    + The Da Vinci Code (2006).mp4
[15:53:31]    + container: MPEG-4 (libavformat)
[15:53:31]  * video track
[15:53:31]    + decoder: mpeg2video
[15:53:31]      + bitrate 9800 kbps
[15:53:31]    + filters
[15:53:31]      + Framerate Shaper (0:27000000:1080000)
[15:53:31]        + frame rate: same as source (around 25.000 fps)
[15:53:31]      + Crop and Scale (720:428:74:74:0:0)
[15:53:31]        + source: 720 * 576, crop (74/74/0/0): 720 * 428, scale: 720 * 428
[15:53:31]    + strict anamorphic
[15:53:31]      + storage dimensions: 720 * 428, mod 0
[15:53:31]      + pixel aspect ratio: 64 / 45
[15:53:31]      + display dimensions: 1024 * 428
[15:53:31]  * Foreign Audio Search: Passthrough, Default
[15:53:31]    + subtitle, English (track 2, id 0x2) Picture [VOBSUB]
[15:53:31]    + subtitle, English (track 3, id 0x3) Picture [VOBSUB]
[15:53:31] reader: end of chapter 3 (media 3) reached at media chapter 4
[15:53:31] reader: done. 1 scr changes
[15:53:31] work: average encoding speed for job is 0.000000 fps
[15:53:31] render: lost time: 0 (0 frames)
[15:53:31] render: gained time: 0 (0 frames) (0 not accounted for)
[15:53:31] mpeg2video-decoder done: 0 frames, 0 decoder errors, 0 drops
[15:53:31] Subtitle track 2 (id 0x2) 'English': 71 hits (19 forced)
[15:53:31] Subtitle track 3 (id 0x3) 'English': 80 hits (0 forced)
[15:53:31] No candidate detected during subtitle scan
[15:53:31] starting job
[15:53:31] Auto Passthru: allowed codecs are AAC, AC3, DTS, DTS-HD, MP3
[15:53:31] Auto Passthru: no valid fallback specified
[15:53:31] Auto Passthru: using AC3 Passthru for track 2
[15:53:31] work: mixdown not specified, track 1 setting mixdown Dolby Pro Logic II
[15:53:31] work: bitrate not specified, track 1 setting bitrate 160 Kbps
[15:53:31] sync: expecting 6384 video frames
[15:53:31] work: only 1 chapter, disabling chapter markers
[15:53:31] job configuration:
[15:53:31]  * source
[15:53:31]    + The Da Vinci Code (2006).mkv
[15:53:31]    + title 1, chapter(s) 3 to 3
[15:53:31]    + container: matroska,webm
[15:53:31]  * destination
[15:53:31]    + The Da Vinci Code (2006).mp4
[15:53:31]    + container: MPEG-4 (libavformat)
[15:53:31]  * video track
[15:53:31]    + decoder: mpeg2video
[15:53:31]      + bitrate 9800 kbps
[15:53:31]    + filters
[15:53:31]      + Framerate Shaper (0:27000000:1080000)
[15:53:31]        + frame rate: same as source (around 25.000 fps)
[15:53:31]      + Crop and Scale (720:428:74:74:0:0)
[15:53:31]        + source: 720 * 576, crop (74/74/0/0): 720 * 428, scale: 720 * 428
[15:53:31]    + strict anamorphic
[15:53:31]      + storage dimensions: 720 * 428, mod 0
[15:53:31]      + pixel aspect ratio: 64 / 45
[15:53:31]      + display dimensions: 1024 * 428
[15:53:31]    + encoder: H.264 (libx264)
[15:53:31]      + options: vbv-maxrate=2000:vbv-bufsize=1000:crf-max=25:ref=1:weightp=1:subme=6:mixed-refs=0:rc-lookahead=30
[15:53:31]      + quality: 16.00 (RF)
[15:53:31]  * audio track 1
[15:53:31]    + decoder: English (AC3) (5.1 ch) (track 1, id 0x1)
[15:53:31]      + bitrate: 448 kbps, samplerate: 48000 Hz
[15:53:31]    + mixdown: Dolby Pro Logic II
[15:53:31]    + encoder: AAC (Apple AudioToolbox)
[15:53:31]      + bitrate: 160 kbps, samplerate: 48000 Hz
[15:53:31]  * audio track 2
[15:53:31]    + decoder: English (AC3) (5.1 ch) (track 1, id 0x1)
[15:53:31]      + bitrate: 448 kbps, samplerate: 48000 Hz
[15:53:31]    + AC3 Passthru
Encoding: task 2 of 2, 0.00 %[15:53:31] encx264: encoding at constant RF 16.000000
[15:53:31] encx264: unparsed options: vbv-maxrate=2000:vbv-bufsize=1000:crf-max=25:ref=1:weightp=1:subme=6:mixed-refs=0:rc-lookahead=30
x264 [info]: using SAR=64/45
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
x264 [info]: profile High, level 3.0
[15:53:31] reader: first SCR 67010400 id 0x0 DTS 67010400
Encoding: task 2 of 2, 31.85 % (197.48 fps, avg 216.18 fps, ETA 00h00m20s)

Test 4

Joes-MBP:Rips joe$ transcode-video.sh --find-forced burn --chapters 3 --fast 'The Da Vinci Code (2006).mkv'
Transcoding: The Da Vinci Code (2006).mkv
[16:07:00] hb_init: starting libhb thread
HandBrake 0.10.2 (2015060900) - Darwin x86_64 - https://handbrake.fr
8 CPUs detected
Opening The Da Vinci Code (2006).mkv...
[16:07:00] CPU: Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz
[16:07:00]  - Intel microarchitecture Haswell
[16:07:00]  - logical processor count: 8
[16:07:00] OpenCL device #1: Intel Iris Pro
[16:07:00]  - OpenCL version: 1.2 
[16:07:00]  - driver version: 1.2(Jun 10 2015 16:35:16)
[16:07:00]  - device type:    GPU
[16:07:00]  - supported:      YES
[16:07:00] OpenCL device #2: NVIDIA GeForce GT 750M
[16:07:00]  - OpenCL version: 1.2 
[16:07:00]  - driver version: 10.4.2 310.41.35f01
[16:07:00]  - device type:    GPU
[16:07:00]  - supported:      no
[16:07:00] hb_scan: path=The Da Vinci Code (2006).mkv, title_index=1
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening The Da Vinci Code (2006).mkv/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening The Da Vinci Code (2006).mkv/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(The Da Vinci Code (2006).mkv) failed
[16:07:00] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.1
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[16:07:00] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'The Da Vinci Code (2006).mkv':
  Metadata:
    title           : Davinci
  Duration: 02:22:42.52, start: 0.000000, bitrate: N/A
    Chapter #0.0: start 0.080000, end 377.680000
    Metadata:
      title           : Chapter 01
    Chapter #0.1: start 377.680000, end 744.560000
    Metadata:
      title           : Chapter 02
    Chapter #0.2: start 744.560000, end 999.920000
    Metadata:
      title           : Chapter 03
    Chapter #0.3: start 999.920000, end 1421.200000
    Metadata:
      title           : Chapter 04
    Chapter #0.4: start 1421.200000, end 1666.760000
    Metadata:
      title           : Chapter 05
    Chapter #0.5: start 1666.760000, end 2296.320000
    Metadata:
      title           : Chapter 06
    Chapter #0.6: start 2296.320000, end 2399.960000
    Metadata:
      title           : Chapter 07
    Chapter #0.7: start 2399.960000, end 2784.280000
    Metadata:
      title           : Chapter 08
    Chapter #0.8: start 2784.280000, end 3199.040000
    Metadata:
      title           : Chapter 09
    Chapter #0.9: start 3199.040000, end 3436.320000
    Metadata:
      title           : Chapter 10
    Chapter #0.10: start 3436.320000, end 3725.360000
    Metadata:
      title           : Chapter 11
    Chapter #0.11: start 3725.360000, end 4206.320000
    Metadata:
      title           : Chapter 12
    Chapter #0.12: start 4206.320000, end 4573.480000
    Metadata:
      title           : Chapter 13
    Chapter #0.13: start 4573.480000, end 4865.160000
    Metadata:
      title           : Chapter 14
    Chapter #0.14: start 4865.160000, end 5147.120000
    Metadata:
      title           : Chapter 15
    Chapter #0.15: start 5147.120000, end 5465.000000
    Metadata:
      title           : Chapter 16
    Chapter #0.16: start 5465.000000, end 5853.680000
    Metadata:
      title           : Chapter 17
    Chapter #0.17: start 5853.680000, end 6215.880000
    Metadata:
      title           : Chapter 18
    Chapter #0.18: start 6215.880000, end 6430.320000
    Metadata:
      title           : Chapter 19
    Chapter #0.19: start 6430.320000, end 6910.440000
    Metadata:
      title           : Chapter 20
    Chapter #0.20: start 6910.440000, end 7225.360000
    Metadata:
      title           : Chapter 21
    Chapter #0.21: start 7225.360000, end 7564.920000
    Metadata:
      title           : Chapter 22
    Chapter #0.22: start 7564.920000, end 7888.280000
    Metadata:
      title           : Chapter 23
    Chapter #0.23: start 7888.280000, end 8562.520000
    Metadata:
      title           : Chapter 24
    Stream #0.0(eng): Video: mpeg2video (Main), yuv420p, 720x576 [PAR 64:45 DAR 16:9], 9800 kb/s, 25 fps, 1k tbn, 50 tbc
    Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s (default)
    Metadata:
      title           : Surround 5.1
    Stream #0.2(eng): Subtitle: dvdsub (default)
    Stream #0.3(eng): Subtitle: dvdsub
[16:07:00] scan: decoding previews for title 1
[16:07:00] scan: audio 0x1: ac3, rate=48000Hz, bitrate=448000 English (AC3) (5.1 ch)
[16:07:00] scan: 10 previews, 720x576, 25.000 fps, autocrop = 74/74/0/0, aspect 16:9, PAR 64:45
[16:07:00] libhb: scan thread found 1 valid title(s)
+ title 1:
  + stream: The Da Vinci Code (2006).mkv
  + duration: 02:22:42
  + size: 720x576, pixel aspect: 64/45, display aspect: 1.78, 25.000 fps
  + autocrop: 74/74/0/0
  + support opencl: yes
  + support hwd: not built-in
  + chapters:
    + 1: cells 0->0, 0 blocks, duration 00:06:18
    + 2: cells 0->0, 0 blocks, duration 00:06:07
    + 3: cells 0->0, 0 blocks, duration 00:04:15
    + 4: cells 0->0, 0 blocks, duration 00:07:01
    + 5: cells 0->0, 0 blocks, duration 00:04:06
    + 6: cells 0->0, 0 blocks, duration 00:10:30
    + 7: cells 0->0, 0 blocks, duration 00:01:44
    + 8: cells 0->0, 0 blocks, duration 00:06:24
    + 9: cells 0->0, 0 blocks, duration 00:06:55
    + 10: cells 0->0, 0 blocks, duration 00:03:57
    + 11: cells 0->0, 0 blocks, duration 00:04:49
    + 12: cells 0->0, 0 blocks, duration 00:08:01
    + 13: cells 0->0, 0 blocks, duration 00:06:07
    + 14: cells 0->0, 0 blocks, duration 00:04:52
    + 15: cells 0->0, 0 blocks, duration 00:04:42
    + 16: cells 0->0, 0 blocks, duration 00:05:18
    + 17: cells 0->0, 0 blocks, duration 00:06:29
    + 18: cells 0->0, 0 blocks, duration 00:06:02
    + 19: cells 0->0, 0 blocks, duration 00:03:34
    + 20: cells 0->0, 0 blocks, duration 00:08:00
    + 21: cells 0->0, 0 blocks, duration 00:05:15
    + 22: cells 0->0, 0 blocks, duration 00:05:40
    + 23: cells 0->0, 0 blocks, duration 00:05:23
    + 24: cells 0->0, 0 blocks, duration 00:11:14
  + audio tracks:
    + 1, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 448000bps
  + subtitle tracks:
    + 1, English (iso639-2: eng) (Bitmap)(VOBSUB)
    + 2, English (iso639-2: eng) (Bitmap)(VOBSUB)
Subtitle Scan Enabled - enabling subtitles if found for foreign language segments
[16:07:00] 2 job(s) to process
[16:07:00] starting job
[16:07:00] sync: expecting 6384 video frames
[16:07:00] work: only 1 chapter, disabling chapter markers
[16:07:00] job configuration:
[16:07:00]  * source
[16:07:00]    + The Da Vinci Code (2006).mkv
[16:07:00]    + title 1, chapter(s) 3 to 3
[16:07:00]    + container: matroska,webm
[16:07:00]  * destination
[16:07:00]    + The Da Vinci Code (2006).mp4
[16:07:00]    + container: MPEG-4 (libavformat)
[16:07:00]  * video track
[16:07:00]    + decoder: mpeg2video
[16:07:00]      + bitrate 9800 kbps
[16:07:00]    + filters
[16:07:00]      + Framerate Shaper (1:27000000:1080000)
[16:07:00]        + frame rate: 25.000 fps -> constant 25.000 fps
[16:07:00]      + Subtitle renderer (0:0:0:0)
[16:07:00]      + Crop and Scale (720:576:0:0:0:0)
[16:07:00]        + source: 720 * 576, crop (0/0/0/0): 720 * 576, scale: 720 * 576
[16:07:00]    + strict anamorphic
[16:07:00]      + storage dimensions: 720 * 576, mod 0
[16:07:00]      + pixel aspect ratio: 64 / 45
[16:07:00]      + display dimensions: 1024 * 576
[16:07:00]  * Foreign Audio Search: Render/Burn-in, Forced Only
[16:07:00]    + subtitle, English (track 2, id 0x2) Picture [VOBSUB]
[16:07:00]    + subtitle, English (track 3, id 0x3) Picture [VOBSUB]
[16:07:00] reader: end of chapter 3 (media 3) reached at media chapter 4
[16:07:00] reader: done. 1 scr changes
[16:07:00] work: average encoding speed for job is 0.000000 fps
[16:07:00] render: 0 frames output, 0 dropped and 0 duped for CFR/PFR
[16:07:00] render: lost time: 0 (0 frames)
[16:07:00] render: gained time: 0 (0 frames) (0 not accounted for)
[16:07:00] mpeg2video-decoder done: 0 frames, 0 decoder errors, 0 drops
Encoding: task 1 of 2, 100.00 %[16:07:00] Subtitle track 2 (id 0x2) 'English': 71 hits (19 forced)
[16:07:00] Subtitle track 3 (id 0x3) 'English': 80 hits (0 forced)
[16:07:00] Found a subtitle candidate with id 0x2 (contains forced subs)
[16:07:00] starting job
[16:07:00] Auto Passthru: allowed codecs are AAC, AC3, DTS, DTS-HD, MP3
[16:07:00] Auto Passthru: no valid fallback specified
[16:07:00] Auto Passthru: using AC3 Passthru for track 2
[16:07:00] work: mixdown not specified, track 1 setting mixdown Dolby Pro Logic II
[16:07:00] work: bitrate not specified, track 1 setting bitrate 160 Kbps
[16:07:00] sync: expecting 6384 video frames
[16:07:00] work: only 1 chapter, disabling chapter markers
[16:07:00] job configuration:
[16:07:00]  * source
[16:07:00]    + The Da Vinci Code (2006).mkv
[16:07:00]    + title 1, chapter(s) 3 to 3
[16:07:00]    + container: matroska,webm
[16:07:00]  * destination
[16:07:00]    + The Da Vinci Code (2006).mp4
[16:07:00]    + container: MPEG-4 (libavformat)
[16:07:00]  * video track
[16:07:00]    + decoder: mpeg2video
[16:07:00]      + bitrate 9800 kbps
[16:07:00]    + filters
[16:07:00]      + Framerate Shaper (1:27000000:1080000)
[16:07:00]        + frame rate: 25.000 fps -> constant 25.000 fps
[16:07:00]      + Subtitle renderer (0:0:0:0)
[16:07:00]      + Crop and Scale (720:576:0:0:0:0)
[16:07:00]        + source: 720 * 576, crop (0/0/0/0): 720 * 576, scale: 720 * 576
[16:07:00]    + strict anamorphic
[16:07:00]      + storage dimensions: 720 * 576, mod 0
[16:07:00]      + pixel aspect ratio: 64 / 45
[16:07:00]      + display dimensions: 1024 * 576
[16:07:00]    + encoder: H.264 (libx264)
[16:07:00]      + preset:  fast
[16:07:00]      + options: vbv-maxrate=2000:vbv-bufsize=1000:crf-max=25
[16:07:00]      + quality: 16.00 (RF)
[16:07:00]  * subtitle track 1, English (track 2, id 0x2) Picture [VOBSUB] -> Render/Burn-in, Forced Only
[16:07:00]  * audio track 1
[16:07:00]    + decoder: English (AC3) (5.1 ch) (track 1, id 0x1)
[16:07:00]      + bitrate: 448 kbps, samplerate: 48000 Hz
[16:07:00]    + mixdown: Dolby Pro Logic II
[16:07:00]    + encoder: AAC (Apple AudioToolbox)
[16:07:00]      + bitrate: 160 kbps, samplerate: 48000 Hz
[16:07:00]  * audio track 2
[16:07:00]    + decoder: English (AC3) (5.1 ch) (track 1, id 0x1)
[16:07:00]      + bitrate: 448 kbps, samplerate: 48000 Hz
[16:07:00]    + AC3 Passthru
[16:07:00] encx264: encoding at constant RF 16.000000
[16:07:00] encx264: unparsed options: vbv-maxrate=2000:vbv-bufsize=1000:crf-max=25:ref=2:weightp=1:subme=6:rc-lookahead=30
x264 [info]: using SAR=64/45
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
x264 [info]: profile High, level 3.0
[16:07:00] reader: first SCR 67010400 id 0x0 DTS 67010400
Encoding: task 2 of 2, 98.64 % (126.27 fps, avg 146.36 fps, ETA 00h00m00s)[16:07:44] reader: end of chapter 3 (media 3) reached at media chapter 4
Encoding: task 2 of 2, 99.39 % (126.27 fps, avg 146.36 fps, ETA 00h00m00s)[16:07:44] reader: done. 1 scr changes
Encoding: task 2 of 2, 100.00 % (126.27 fps, avg 146.36 fps, ETA 00h00m00s)[16:07:45] work: average encoding speed for job is 146.362488 fps
Encoding: task 2 of 2, 100.00 % (126.27 fps, avg 146.36 fps, ETA 00h00m00s)[16:07:45] sync: got 6385 frames, 6384 expected
[16:07:45] render: 6385 frames output, 0 dropped and 0 duped for CFR/PFR
[16:07:45] render: lost time: 0 (0 frames)
[16:07:45] render: gained time: 0 (0 frames) (0 not accounted for)
[16:07:45] mpeg2video-decoder done: 6385 frames, 0 decoder errors, 0 drops
x264 [info]: frame I:79    Avg QP:10.59  size: 31166
x264 [info]: frame P:3378  Avg QP:14.48  size:  8364
x264 [info]: frame B:2928  Avg QP:16.42  size:  5070
x264 [info]: consecutive B-frames: 22.2% 46.5% 10.1% 21.1%
x264 [info]: mb I  I16..4: 20.7% 73.4%  5.9%
x264 [info]: mb P  I16..4:  0.6%  3.0%  0.3%  P16..4: 37.0% 22.4%  8.9%  0.0%  0.0%    skip:27.9%
x264 [info]: mb B  I16..4:  6.2% 17.4%  0.1%  B16..8: 18.7%  6.5%  0.3%  direct:13.6%  skip:37.2%  L0:43.2% L1:42.5% BI:14.3%
x264 [info]: 8x8 transform intra:74.0% inter:74.8%
x264 [info]: coded y,uvDC,uvAC intra: 62.4% 67.5% 38.6% inter: 23.2% 29.2% 4.1%
x264 [info]: i16 v,h,dc,p: 50% 17% 22% 12%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 12% 39%  3%  3%  4%  2%  4%  2%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 22% 22%  5%  6%  7%  4%  5%  3%
x264 [info]: i8c dc,h,v,p: 54% 14% 26%  5%
x264 [info]: Weighted P-Frames: Y:0.9% UV:0.3%
x264 [info]: ref P L0: 65.8% 34.2%
x264 [info]: ref B L0: 71.7% 28.3%
x264 [info]: ref B L1: 95.0%  5.0%
x264 [info]: kb/s:1427.12
[16:07:45] ac3-decoder done: 0 frames, 0 decoder errors, 0 drops
[16:07:45] ac3-decoder done: 0 frames, 0 decoder errors, 0 drops
[16:07:45] mux: track 0, 6385 frames, 45557334 bytes, 1427.01 kbps, fifo 2048
[16:07:45] mux: track 1, 11971 frames, 5197573 bytes, 162.81 kbps, fifo 4096
[16:07:45] mux: track 2, 7980 frames, 14300160 bytes, 447.93 kbps, fifo 2048
[16:07:45] libhb: work result = 0

Encode done!
HandBrake has exited.

-o isn't passing through file path

Starting with this output from transcode-video --scan against a DVD folder of the most recent Hitchhiker's Guide (not a .mkv file):

+ title 12:
  + Main Feature
  + vts 2, ttn 1, cells 0->25 (2584340 blocks)
  + duration: 01:48:40
  + size: 720x480, pixel aspect: 32/27, display aspect: 1.78, 29.970 fps
  + chapters:
    + 1: cells 0->0, 107651 blocks, duration 00:03:52
    + 2: cells 1->1, 76584 blocks, duration 00:02:54
    + 3: cells 2->2, 155302 blocks, duration 00:06:10
    + 4: cells 3->3, 44048 blocks, duration 00:01:36
    + 5: cells 4->4, 107001 blocks, duration 00:04:01
    + 6: cells 5->5, 165070 blocks, duration 00:07:06
    + 7: cells 6->6, 111907 blocks, duration 00:04:35
    + 8: cells 7->7, 90249 blocks, duration 00:04:16
    + 9: cells 8->8, 121317 blocks, duration 00:05:33
    + 10: cells 9->9, 100528 blocks, duration 00:03:49
    + 11: cells 10->10, 104069 blocks, duration 00:04:46
    + 12: cells 11->11, 81954 blocks, duration 00:03:52
    + 13: cells 12->12, 97624 blocks, duration 00:04:01
    + 14: cells 13->13, 110054 blocks, duration 00:04:29
    + 15: cells 14->14, 113364 blocks, duration 00:05:12
    + 16: cells 15->16, 93784 blocks, duration 00:04:03
    + 17: cells 17->17, 85576 blocks, duration 00:03:43
    + 18: cells 18->18, 113054 blocks, duration 00:04:36
    + 19: cells 19->19, 115980 blocks, duration 00:04:27
    + 20: cells 20->20, 79622 blocks, duration 00:02:55
    + 21: cells 21->21, 110249 blocks, duration 00:04:45
    + 22: cells 22->22, 128655 blocks, duration 00:05:03
    + 23: cells 23->23, 154794 blocks, duration 00:06:04
    + 24: cells 24->24, 115717 blocks, duration 00:06:53
    + 25: cells 25->25, 187 blocks, duration 00:00:01
  + audio tracks:
    + 1, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 448000bps
    + 2, English (DTS) (5.1 ch) (iso639-2: eng), 48000Hz, 768000bps
    + 3, Francais (AC3) (2.0 ch) (Dolby Surround) (iso639-2: fra), 48000Hz, 192000bps
    + 4, Espanol (AC3) (2.0 ch) (Dolby Surround) (iso639-2: spa), 48000Hz, 192000bps
    + 5, English (AC3) (Director's Commentary 1) (1.0 ch) (iso639-2: eng), 48000Hz, 96000bps
    + 6, English (AC3) (Director's Commentary 2) (1.0 ch) (iso639-2: eng), 48000Hz, 96000bps
  + subtitle tracks:
    + 1, English (Closed Caption) (iso639-2: eng) (Bitmap)(VOBSUB)
    + 2, Francais (iso639-2: fra) (Bitmap)(VOBSUB)
    + 3, Espanol (iso639-2: spa) (Bitmap)(VOBSUB)
    + 4, Francais (iso639-2: fra) (Bitmap)(VOBSUB)
    + 5, Espanol (iso639-2: spa) (Bitmap)(VOBSUB)
    + 6, Closed Captions (iso639-2: eng) (Text)(CC)

I tried this command:

transcode-video --title 12 -o /Volumes/Videos/Converted/HGG0NND1.m4v --m4v --crop detect --add-audio 1 --copy-audio 2 --burn-subtitle scan --add-subtitle 1 --add-subtitle 6 --dry-run /Volumes/HGG0NND1/

And received this output:

HandBrakeCLI --input=/Volumes/HGG0NND1/ --output=/Users/ari/.rvm/rubies/HGG0NND1.m4v --markers --encoder=x264 --quality=16 --title=12 --crop=60:64:0:0 --strict-anamorphic --rate=23.976 --audio=1,1 --aencoder=ca_aac,copy --audio-fallback=ac3 --subtitle=scan,1,6 --subtitle-burned --encopts=vbv-maxrate=2000:vbv-bufsize=1000:crf-max=25

the --audio=1,1 --aencoder=ca_aac,copy section seems wrong. I would have expected something more like --audio=1,1,2 --aencoder=ca_aac,ac3,copy:dts

HandBrakeCLI version unknown

I believe this is happening because I am using a nightly version of HandbrakeCLI, and their repository is now hosted on GitHub. Obviously it's not parsing correctly, but even if it did, I think it's going to fail the version number check (which seems based on a svn commit number)

$ HandBrakeCLI --version
[13:11:17] hb_init: starting libhb thread
[13:11:17] thread 700000081000 started ("libhb")
HandBrake 20151209210633-3443f6a-master

Video-Transcoding 0.2.1 Issue scanning & Transcoding DVD

Mac OSX 10.7.5 / HandBrake svn6897 (2015021301) / Mapro 1.1

When using the transcode command to encode the DVD taking of Pelhan 123 with the following commands:
transcode-video --title 1 --MP4 --big --output /Volumes/TitoDrive/Local_Movies /Volumes/Taking\ of\ Pelham\ 1\ 2\ 3
transcode-video --scan /Volumes/Taking\ of\ Pelham\ 1\ 2\ 3

Getting the following error on the command line:

transcode-video: invalid subtitle track information: + combing detected, may be interlaced or telecined

First Error message after several BD trancoding

transcode-video vs convert-video

been testing convert-video to try ans speed to transcoding to mp4. However encountered an issue that increases the file size significantly of the output mp4. It adds 3 audio streams. I dont know if this is by design or not. However I thought I would raise it

convert-video

--bind-srt-language LANG sets --srt-offset=LANG in generated command line

Running this command:

transcode-video --crop 0:0:0:0 -o /Volumes/Videos/Converted/Up.m4v --add-audio 2 --copy-audio 2 --add-srt Up.srt --bind-srt-language eng --dry-run Up_\(Disc_1\)_t00.mkv

against this file:

+ title 1:
  + stream: Up_(Disc_1)_t00.mkv
  + duration: 01:36:07
  + size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
  + chapters:
    + 1: cells 0->0, 0 blocks, duration 00:02:39
    + 2: cells 0->0, 0 blocks, duration 00:04:35
    + 3: cells 0->0, 0 blocks, duration 00:04:23
    + 4: cells 0->0, 0 blocks, duration 00:01:56
    + 5: cells 0->0, 0 blocks, duration 00:01:49
    + 6: cells 0->0, 0 blocks, duration 00:02:14
    + 7: cells 0->0, 0 blocks, duration 00:02:49
    + 8: cells 0->0, 0 blocks, duration 00:04:06
    + 9: cells 0->0, 0 blocks, duration 00:01:52
    + 10: cells 0->0, 0 blocks, duration 00:01:39
    + 11: cells 0->0, 0 blocks, duration 00:01:38
    + 12: cells 0->0, 0 blocks, duration 00:03:40
    + 13: cells 0->0, 0 blocks, duration 00:01:00
    + 14: cells 0->0, 0 blocks, duration 00:00:54
    + 15: cells 0->0, 0 blocks, duration 00:04:35
    + 16: cells 0->0, 0 blocks, duration 00:02:45
    + 17: cells 0->0, 0 blocks, duration 00:02:06
    + 18: cells 0->0, 0 blocks, duration 00:01:36
    + 19: cells 0->0, 0 blocks, duration 00:03:02
    + 20: cells 0->0, 0 blocks, duration 00:03:02
    + 21: cells 0->0, 0 blocks, duration 00:03:03
    + 22: cells 0->0, 0 blocks, duration 00:05:10
    + 23: cells 0->0, 0 blocks, duration 00:03:46
    + 24: cells 0->0, 0 blocks, duration 00:01:55
    + 25: cells 0->0, 0 blocks, duration 00:02:44
    + 26: cells 0->0, 0 blocks, duration 00:01:23
    + 27: cells 0->0, 0 blocks, duration 00:03:15
    + 28: cells 0->0, 0 blocks, duration 00:01:49
    + 29: cells 0->0, 0 blocks, duration 00:02:28
    + 30: cells 0->0, 0 blocks, duration 00:01:53
    + 31: cells 0->0, 0 blocks, duration 00:02:08
    + 32: cells 0->0, 0 blocks, duration 00:01:29
    + 33: cells 0->0, 0 blocks, duration 00:02:39
    + 34: cells 0->0, 0 blocks, duration 00:03:00
    + 35: cells 0->0, 0 blocks, duration 00:07:05
  + audio tracks:
    + 1, English (FLAC) (5.1 ch) (iso639-2: eng)
    + 2, English (DTS) (5.1 ch) (iso639-2: eng), 48000Hz, 1536000bps
    + 3, English (FLAC) (2.0 ch) (iso639-2: eng)
    + 4, English (DTS) (2.0 ch) (Lt/Rt) (iso639-2: eng), 48000Hz, 1536000bps
  + subtitle tracks:
    + 1, English (iso639-2: eng) (Bitmap)(PGS)

Results in this command getting passed to HandbrakeCLI:

HandBrakeCLI --input=Up_\(Disc_1\)_t00.mkv --output=/Volumes/Videos/Converted/Up.m4v --markers --encoder=x264 --quality=16 --crop=0:0:0:0 --strict-anamorphic --rate=30 --pfr --audio=1,1,2 --aencoder=ca_aac,ac3,copy --audio-fallback=ac3 --ab=,384, --srt-file=Up.srt --srt-offset=eng --srt-lang=eng --encopts=vbv-maxrate=5000:vbv-bufsize=2500:crf-max=25

Note that set-offset is getting set to "eng" when it should be omitted or set to 0.

Removing the bind results in:

transcode-video --crop 0:0:0:0 -o /Volumes/Videos/Converted/Up.m4v --add-audio 2 --copy-audio 2 --add-srt Up.srt --dry-run Up_\(Disc_1\)_t00.mkv 
HandBrakeCLI --input=Up_\(Disc_1\)_t00.mkv --output=/Volumes/Videos/Converted/Up.m4v --markers --encoder=x264 --quality=16 --crop=0:0:0:0 --strict-anamorphic --rate=30 --pfr --audio=1,1,2 --aencoder=ca_aac,ac3,copy --audio-fallback=ac3 --ab=,384, --srt-file=Up.srt --encopts=vbv-maxrate=5000:vbv-bufsize=2500:crf-max=25

Interestingly, explicitly setting the offset while leaving in the bind does not set the offset properly:

transcode-video --crop 0:0:0:0 -o /Volumes/Videos/Converted/Up.m4v --add-audio 2 --copy-audio 2 --add-srt Up.srt --bind-srt-language eng --bind-srt-offset 0 --dry-run Up_\(Disc_1\)_t00.mkv 
HandBrakeCLI --input=Up_\(Disc_1\)_t00.mkv --output=/Volumes/Videos/Converted/Up.m4v --markers --encoder=x264 --quality=16 --crop=0:0:0:0 --strict-anamorphic --rate=30 --pfr --audio=1,1,2 --aencoder=ca_aac,ac3,copy --audio-fallback=ac3 --ab=,384, --srt-file=Up.srt --srt-offset=eng --srt-lang=eng --encopts=vbv-maxrate=5000:vbv-bufsize=2500:crf-max=25
El-Cap-Mini:Up_(Disc_1) mini$ 

And it looks like setting the offset alone doesn't work with 0ms:

transcode-video --crop 0:0:0:0 -o /Volumes/Videos/Converted/Up.m4v --add-audio 2 --copy-audio 2 --add-srt Up.srt --bind-srt-language eng --bind-srt-offset 0 --dry-run Up_\(Disc_1\)_t00.mkv 
HandBrakeCLI --input=Up_\(Disc_1\)_t00.mkv --output=/Volumes/Videos/Converted/Up.m4v --markers --encoder=x264 --quality=16 --crop=0:0:0:0 --strict-anamorphic --rate=30 --pfr --audio=1,1,2 --aencoder=ca_aac,ac3,copy --audio-fallback=ac3 --ab=,384, --srt-file=Up.srt --srt-offset=eng --srt-lang=eng --encopts=vbv-maxrate=5000:vbv-bufsize=2500:crf-max=25

or 100ms:

transcode-video --crop 0:0:0:0 -o /Volumes/Videos/Converted/Up.m4v --add-audio 2 --copy-audio 2 --add-srt Up.srt --bind-srt-offset 100 --dry-run Up_\(Disc_1\)_t00.mkv 
HandBrakeCLI --input=Up_\(Disc_1\)_t00.mkv --output=/Volumes/Videos/Converted/Up.m4v --markers --encoder=x264 --quality=16 --crop=0:0:0:0 --strict-anamorphic --rate=30 --pfr --audio=1,1,2 --aencoder=ca_aac,ac3,copy --audio-fallback=ac3 --ab=,384, --srt-file=Up.srt --encopts=vbv-maxrate=5000:vbv-bufsize=2500:crf-max=25

Trouble Selecting Titles Other Than 1

Hi Don. Thank you for all the work you've put into these scripts. They've been very useful to me.

I had been using the bash scripts for a while and never had any trouble with titles. I've switched to the ruby scripts and can't get the script to use a title other than title 1 when transcoding an .iso file. I keep getting an "invalid title index" message.

For instance, I try the following to transcode title 3:
# transcode-video --title 3 pending/movie.iso
/usr/local/bin/transcode-video: invalid title index: 3
Try /usr/local/bin/transcode-video --help for more information.

If I use HandBrakeCLI to scan the file for titles, it shows that title #3 is present (see attached HandBrakeScanLog.txt).

HandBrakeScanLog.txt

If I go back to the old bash script and specify title 3, it transcodes fine. Is there something I doing wrong with the syntax for the ruby version of the script?

Thanks much!

Scripts fail to start on Cygwin

Scripts fail to start on Cygwin

Description

Upon downloading the scripts, I was able to view the help and the version, to verify that I had the latest version.
Trying to use any of the scripts further, however, resulted in the stack trace given below.

Further details

The identical stack trace appears when using any of the scripts, with or without any parameters.
Uninstalling and reinstalling the Ruby gem results in the same error immediately.
I first noticed this after adding the

/home/Callum/bin

directory to the Windows system environment variable path as

C:/cygwin/Callum/bin

but after removing them from the path the error persists.

System information

  • OS: Win7 x64 Service Pack 1
  • Cygwin version: 2.0.1(0.287/5/3)
  • Ruby version: ruby 2.0.0p598 (2014-11-13) [x86_64-cygwin]

Stack trace

$ transcode-video --help
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require': /home/Callum/.gem/ruby/gems/video_transcoding-0.1.0/lib/video_transcoding/media.rb:11: syntax error, unexpected ',' (SyntaxError)
    def initialize(path:, title: nil, autocrop: false,...
                         ^
/home/Callum/.gem/ruby/gems/video_transcoding-0.1.0/lib/video_transcoding/media.rb:11: Can't assign to nil
...f initialize(path:, title: nil, autocrop: false, extended: t...
...                               ^
/home/Callum/.gem/ruby/gems/video_transcoding-0.1.0/lib/video_transcoding/media.rb:11: Can't assign to false
...:, title: nil, autocrop: false, extended: true, allow_direct...
...                               ^
/home/Callum/.gem/ruby/gems/video_transcoding-0.1.0/lib/video_transcoding/media.rb:11: Can't assign to true
...utocrop: false, extended: true, allow_directory: true)
...                               ^
/home/Callum/.gem/ruby/gems/video_transcoding-0.1.0/lib/video_transcoding/media.rb:323: syntax error, unexpected keyword_end, expecting end-of-input
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/Callum/.gem/ruby/gems/video_transcoding-0.1.0/lib/video_transcoding.rb:15:in `<top (required)>'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/Callum/.gem/ruby/gems/video_transcoding-0.1.0/lib/video_transcoding/cli.rb:8:in `<top (required)>'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/Callum/.gem/ruby/gems/video_transcoding-0.1.0/bin/transcode-video:12:in `<top (required)>'
        from /home/Callum/bin/transcode-video:23:in `load'
        from /home/Callum/bin/transcode-video:23:in `<main>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.