Solved Slow HandBrake

Why HandBrake is so slow on FreeBSD?

The same system is used for comparing FreeBSD and Fedora 23:

Code:
CPU: Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz (3292.60-MHz K8-class CPU)
16GB RAM
SSD drive
FreeBSD bclinton 10.2-STABLE FreeBSD 10.2-STABLE #0 r291083: Sun Nov 22 21:34:30 PST 2015  toor@bclinton:/usr/obj/usr/src/sys/GENERIC  amd64

FreeBSD: handbrake-0.10.2_2 installed from the official repo.
F23: HandBrake-cli-1.0-13.ed8c11e.fc23.x86_64

test.ts is 2.8 GB file.

Command: HandBrakeCLI -i test.ts -o test.mp4 -e x264 -x :threads=4 -q 26

Time to encode:

FreeBSD: 26 mins 44 seconds
Fedora 23: 10 mins 5 seconds

Hard to believe that HandBrake version 1.0-13 is more than 2 times faster than 0.10.2


FreeBSD log:

Code:
test.ts -> test-26.mp4
[22:22:45] hb_init: starting libhb thread
HandBrake 0.10.2 (2015122700) - FreeBSD amd64 - https://handbrake.fr
4 CPUs detected
Opening test.ts...
[22:22:45] CPU:
[22:22:45]  - logical processor count: 4
[22:22:45] OpenCL: library not available
[22:22:45] hb_scan: path=test.ts, title_index=1
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening test.ts/BDMV/index.bdmv
libbluray/bdnav/index_parse.c:162: indx_parse(): error opening test.ts/BDMV/BACKUP/index.bdmv
libbluray/bluray.c:2182: nav_get_title_list(test.ts) failed
[22:22:45] 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
[22:22:45] dvd: not a dvd - trying as a stream/file instead
[22:22:45] file is MPEG Transport Stream with 188 byte packets offset 0 bytes
[22:22:45] Found the following PIDS
[22:22:45]  Video PIDS :
[22:22:45]  0x1011 type MPEG2 (0x2) (PCR)
[22:22:45]  Audio PIDS :
[22:22:45]  0x1100 type AC3 (0x81)
[22:22:45]  0x1101 type AC3 (0x81)
[22:22:45]  Subtitle PIDS :
[22:22:45]  Other PIDS :
[22:22:45] stream id 0x1100 (type 0x81 substream 0x0) audio 0x1100
[22:22:45] stream id 0x1101 (type 0x81 substream 0x0) audio 0x1101
[22:22:45] scan: decoding previews for title 1
[22:22:45] file is MPEG Transport Stream with 188 byte packets offset 0 bytes
[22:22:45] scan: audio 0x1100: ac3, rate=48000Hz, bitrate=384000 Russian (AC3) (5.1 ch)
[22:22:45] scan: audio 0x1101: ac3, rate=48000Hz, bitrate=384000 English (AC3) (5.1 ch)
[22:22:45] 164.109283s: Video -> Film
Scanning title 1 of 1, preview 10, 100.00 %[22:22:46] stream: 13 good frames, 0 errors (0%)
[22:22:46] scan: 10 previews, 1920x1080, 23.976 fps, autocrop = 8/0/0/0, aspect 16:9, PAR 1:1
[22:22:46] libhb: scan thread found 1 valid title(s)
+ title 1:
  + stream: test.ts
  + duration: 00:29:55
  + size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
  + autocrop: 8/0/0/0
  + support opencl: no
  + support hwd: not built-in
  + chapters:
  + 1: cells 0->0, 0 blocks, duration 00:29:55
  + audio tracks:
  + 1, Russian (AC3) (5.1 ch) (iso639-2: rus), 48000Hz, 384000bps
  + 2, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 384000bps
  + subtitle tracks:
  + 1, Closed Captions (iso639-2: rus) (Text)(CC)
[22:22:46] 1 job(s) to process
[22:22:46] starting job
[22:22:46] work: mixdown not specified, track 1 setting mixdown Dolby Pro Logic II
[22:22:46] work: bitrate not specified, track 1 setting bitrate 160 Kbps
[22:22:46] sync: expecting 43039 video frames
[22:22:46] job configuration:
[22:22:46]  * source
[22:22:46]  + test.ts
[22:22:46]  + title 1, chapter(s) 1 to 1
[22:22:46]  * destination
[22:22:46]  + test-26.mp4
[22:22:46]  + container: MPEG-4 (libavformat)
[22:22:46]  * video track
[22:22:46]  + decoder: mpeg2video
[22:22:46]  + bitrate 24000 kbps
[22:22:46]  + filters
[22:22:46]  + Framerate Shaper (0:27000000:1126125)
[22:22:46]  + frame rate: same as source (around 23.976 fps)
[22:22:46]  + Crop and Scale (1920:1072:8:0:0:0)
[22:22:46]  + source: 1920 * 1080, crop (8/0/0/0): 1920 * 1072, scale: 1920 * 1072
[22:22:46]  + dimensions: 1920 * 1072, mod 0
[22:22:46]  + encoder: H.264 (libx264)
[22:22:46]  + options: :threads=4
[22:22:46]  + quality: 26.00 (RF)
[22:22:46]  * audio track 1
[22:22:46]  + decoder: Russian (AC3) (5.1 ch) (track 1, id 0x1100)
[22:22:46]  + bitrate: 384 kbps, samplerate: 48000 Hz
[22:22:46]  + mixdown: Dolby Pro Logic II
[22:22:46]  + encoder: AAC (libavcodec)
[22:22:46]  + bitrate: 160 kbps, samplerate: 48000 Hz
[22:22:46] file is MPEG Transport Stream with 188 byte packets offset 0 bytes
[22:22:46] encx264: min-keyint: 24, keyint: 240
[22:22:46] encx264: encoding at constant RF 26.000000
[22:22:46] encx264: unparsed options: threads=4
[22:22:46] reader: first SCR 914 id 0x1011 DTS 34114
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
x264 [info]: profile High, level 4.0
[22:22:46] mpeg2video: "Chapter 1" (1) at frame 0 time 3003
[22:22:46] sync: first pts is 3003
[22:22:46] 0.767433s: Video -> Film
Encoding: task 1 of 1, 0.25 %[22:22:49] 5.171834s: Film -> Video

F23 log:

Code:
test.ts -> test-26.mp4
[22:32:39] hb_init: starting libhb thread
[22:32:39] thread 7f5e94fb7700 started ("libhb")
HandBrake 20160116154708-ed8c11e-unknown (2016011601) - Linux x86_64 - https://handbrake.fr
4 CPUs detected
Opening test.ts...
[22:32:39] CPU: Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz
[22:32:39]  - Intel microarchitecture Sandy Bridge
[22:32:39]  - logical processor count: 4
[22:32:39] OpenCL: library not available
[22:32:39] Intel Quick Sync Video support: no
[22:32:39] hb_scan: path=test.ts, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:269: failed opening UDF image test.ts
disc.c:350: error opening file BDMV/index.bdmv
disc.c:350: error opening file BDMV/BACKUP/index.bdmv
[22:32:39] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 5.0.3
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
[22:32:39] dvd: not a dvd - trying as a stream/file instead
[22:32:39] file is MPEG Transport Stream with 188 byte packets offset 0 bytes
[22:32:39] Found the following PIDS
[22:32:39]  Video PIDS :
[22:32:39]  0x1011 type MPEG2 (0x2) (PCR)
[22:32:39]  Audio PIDS :
[22:32:39]  0x1100 type AC3 (0x81)
[22:32:39]  0x1101 type AC3 (0x81)
[22:32:39]  Subtitle PIDS :
[22:32:39]  Other PIDS :
[22:32:39] stream id 0x1100 (type 0x81 substream 0x0) audio 0x1100
[22:32:39] stream id 0x1101 (type 0x81 substream 0x0) audio 0x1101
[22:32:39] scan: decoding previews for title 1
[22:32:39] file is MPEG Transport Stream with 188 byte packets offset 0 bytes
[22:32:39] scan: audio 0x1100: ac3, rate=48000Hz, bitrate=384000 Russian (AC3) (5.1 ch)
[22:32:39] scan: audio 0x1101: ac3, rate=48000Hz, bitrate=384000 English (AC3) (5.1 ch)
[22:32:39] 164.109283s: Video -> Film
Scanning title 1 of 1, preview 4, 40.00 %[22:32:39] stream: 12 good frames, 0 errors (0%)
[22:32:39] scan: 10 previews, 1920x1080, 23.976 fps, autocrop = 8/0/0/0, aspect 16:9, PAR 1:1
[22:32:39] libhb: scan thread found 1 valid title(s)
+ Using preset: Normal
+ title 1:
  + stream: test.ts
  + duration: 00:29:55
  + size: 1920x1080, pixel aspect: 1/1, display aspect: 1.78, 23.976 fps
  + autocrop: 8/0/0/0
  + support opencl: no
  + chapters:
  + 1: cells 0->0, 0 blocks, duration 00:29:55
  + audio tracks:
  + 1, Russian (AC3) (5.1 ch) (iso639-2: rus), 48000Hz, 384000bps
  + 2, English (AC3) (5.1 ch) (iso639-2: eng), 48000Hz, 384000bps
  + subtitle tracks:
  + 1, Closed Captions (iso639-2: rus) (Text)(CC)
[22:32:40] 1 job(s) to process
[22:32:40] json job:
{
  "Audio": {
  "AudioList": [
  {
  "Bitrate": 160,
  "CompressionLevel": -1.0,
  "DRC": 0.0,
  "DitherMethod": "auto",
  "Encoder": "fdk_aac",
  "Gain": 0.0,
  "Mixdown": "dpl2",
  "NormalizeMixLevel": false,
  "PresetEncoder": "fdk_aac",
  "Samplerate": "auto",
  "Track": 0
  }
  ],
  "CopyMask": [
  "copy:aac",
  "copy:ac3",
  "copy:dts",
  "copy:dtshd",
  "copy:eac3",
  "copy:flac",
  "copy:mp3",
  "copy:truehd"
  ],
  "FallbackEncoder": "ac3"
  },
  "Destination": {
  "ChapterList": [
  {
  "Name": "Chapter 1"
  }
  ],
  "ChapterMarkers": false,
  "File": "test-26.mp4",
  "Mp4Options": {
  "IpodAtom": false,
  "Mp4Optimize": false
  },
  "Mux": "m4v"
  },
  "Filters": {
  "FilterList": [
  {
  "ID": 5,
  "Settings": "0"
  },
  {
  "ID": 10,
  "Settings": "1920:1072:8:0:0:0"
  }
  ]
  },
  "Metadata": {},
  "PAR": {
  "Den": 1,
  "Num": 1
  },
  "SequenceID": 0,
  "Source": {
  "Angle": 0,
  "Path": "test.ts",
  "Range": {
  "End": 1,
  "Start": 1,
  "Type": "chapter"
  },
  "Title": 1
  },
  "Subtitle": {
  "Search": {
  "Burn": true,
  "Default": false,
  "Enable": false,
  "Forced": false
  },
  "SubtitleList": []
  },
  "Video": {
  "Bitrate": -1,
  "ColorMatrixCode": 0,
  "Encoder": "x264",
  "HWDecode": false,
  "Level": "4.0",
  "OpenCL": false,
  "Options": ":threads=4",
  "Preset": "veryfast",
  "Profile": "main",
  "QSV": {
  "AsyncDepth": 4,
  "Decode": false
  },
  "Quality": 26.0,
  "Tune": "",
  "Turbo": false,
  "TwoPass": false
  }
}
[22:32:40] starting job
[22:32:40] job configuration:
[22:32:40]  * source
[22:32:40]  + test.ts
[22:32:40]  + title 1, chapter(s) 1 to 1
[22:32:40]  * destination
[22:32:40]  + test-26.mp4
[22:32:40]  + container: MPEG-4 (libavformat)
[22:32:40]  * video track
[22:32:40]  + decoder: mpeg2video
[22:32:40]  + bitrate 24000 kbps
[22:32:40]  + filters
[22:32:40]  + Framerate Shaper (0)
[22:32:40]  + frame rate: same as source (around 23.976 fps)
[22:32:40]  + Crop and Scale (1920:1072:8:0:0:0)
[22:32:40]  + source: 1920 * 1080, crop (8/0/0/0): 1920 * 1072, scale: 1920 * 1072
[22:32:40]  + Output geometry
[22:32:40]  + storage dimensions: 1920 x 1072
[22:32:40]  + pixel aspect ratio: 1 : 1
[22:32:40]  + display dimensions: 1920 x 1072
[22:32:40]  + encoder: H.264 (libx264)
[22:32:40]  + preset:  veryfast
[22:32:40]  + options: :threads=4
[22:32:40]  + profile: main
[22:32:40]  + level:  4.0
[22:32:40]  + quality: 26.00 (RF)
[22:32:40]  * audio track 1
[22:32:40]  + decoder: Russian (AC3) (5.1 ch) (track 1, id 0x1100)
[22:32:40]  + bitrate: 384 kbps, samplerate: 48000 Hz
[22:32:40]  + mixdown: Dolby Pro Logic II
[22:32:40]  + dither: triangular
[22:32:40]  + encoder: AAC (libfdk_aac)
[22:32:40]  + bitrate: 160 kbps, samplerate: 48000 Hz
[22:32:40] file is MPEG Transport Stream with 188 byte packets offset 0 bytes
[22:32:40] sync: expecting 43039 video frames
[22:32:40] x264 options: Unknown suboption
[22:32:40] encx264: min-keyint: 24, keyint: 240
[22:32:40] encx264: encoding at constant RF 26.000000
[22:32:40] encx264: unparsed options: :threads=4:ref=1:weightp=1:level=4.0:8x8dct=0:subme=2:mixed-refs=0:trellis=0:rc-lookahead=10:vbv-bufsize=25000:vbv-maxrate=20000
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
x264 [info]: profile Main, level 4.0
[22:32:40] reader: first SCR 914 id 0x1011 DTS 34114
[22:32:40] mpeg2video: "Chapter 1" (1) at frame 0 time 3003
[22:32:40] sync: first pts is 3003
[22:32:40] 0.767433s: Video -> Film
 
Last edited by a moderator:
In Fedora you are using the H.264 preset veryfast:
Code:
[22:32:40]  + encoder: H.264 (libx264)
[22:32:40]  + preset:  veryfast

In FreeBSD you are not setting a preset so it will probably be defaulting to the medium preset - useful link and quote:

The general guideline is to use the slowest preset that you have patience for. Current presets in descending order of speed are: ultrafast,superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. The default preset is medium.
 
For what it's worth, I remember at one point, ffmpeg was much slower in FreeBSD when compared to Fedora. It turned out at the time that I was using a much older version--eventually, the port for multimedia/ffmpeg caught up, and while FreeBSD was still a bit slower, there was far less of a difference. The 1.something version was close to twice as fast as the 0.something version.

Generally speaking, I've found Fedora to be faster than FreeBSD with encoding, but at the time, the BIG difference was the version numbers. Now that ffmpeg has caught up, or at least gotten close in versions, the difference is much less. I haven't researched it too deeply though.
 
Back
Top