octothorpe: (Default)
[personal profile] octothorpe
So [personal profile] notdefined and [personal profile] mh58 are building a tiny, cool PC to act as a streaming media client for their TV, using the PLEX client/server applications. I've been watching PLEX for awhile, and while their earlier incarnations seemed quite flawed in their usability, the modern ones seem to do well, coupled with the speed of modern hardware to decode complex media and output 1080p signals to a TV via HDMI. Now, they also have IOS/Android apps to both act as clients, or as remote controls for other clients. Suddenly we have convergence.

I'm taking a slightly different tactic: I'm not going to build a micro PC, I'm going to buy one of the new Mac minis which use very little power, and almost no power when sleeping. The form factor is perfect, and it has HDMI-out. In the past, people have hacked earlier minis to be media servers, but with varied success (they were underpowered, and they didn't have HDMI, so getting it to the TV was a pain, and they often couldn't decode a proper 1080p/24 file without stuttering).

Why not an Apple TV? They're great toys, but they're closed devices. They don't do 1080p, and they only do a limited subset of H264 decoding (luckily it's done in hardware). With the mini, I can read any file any mac can read, which includes the ubiquitous .MKV files the kids get off the interwebs, and with the new multi-core i5/i7 processors, and dedicated GPU, I'll always be able to send 1080p content to my TV.

So over the week-end, I started ripping my DVD collection. It's small by some standards, but it's not inconsequential. I have a mix of old, unrestored films, B&W films, foreign films, some modern digital transfers, and both old and new animation. Logically, this means I had to do some homework to figure out what settings were best for the source material. Finding proper encode settings however, was like pulling teeth — painful, messy, and occasionally, inaccurate ;-). I rip all my DVDs to the hard drive prior to transcoding to H264, then batch transcode overnight. Here are some insights:
  • Ripping (transferring but not transcoding data from the DVD to the hard drive) is far slower than merely copying bit-for-bit. This is due to the bullshit copy protection where they purposely corrupt sectors in the DVD, making the read-head dance from track to track trying to follow the programme material. Nothing can speed this up, as the DVD drive is the bottleneck, and you can't have a read-head move much faster.
  • Transcoding is resource intensive. You're CPU bound, and potentially memory/disk IO bound, but there are workarounds…
  • Rip to one disk, transcode to another. All disks should be fast. Don't use anything USB, unless it's USB3 (even then, just don't). Use Firewire 800 (minimum), or SATA/eSATA, or in my case, Fibre Channel (FC, fuck yeah!). This will have a massive impact on how many frames per second you can transcode. Nothing sucks more than having to read from one area of the drive, and write to another area of the same drive.
  • Use fast, 64bit apps. Transcoding is a lot of very scary maths. In 64bit mode, not only can you twiddle giant numbers without rounding/truncating (or being forced to use double cycles to perform the operation), you also get access to *way* more registers, which means more efficient use of the CPU (32bit mode uses the legacy register system from the old 8088 days which is crippling in a modern compute environment). If your transcoding apps aren't multicore aware, get new ones.
  • If your primary target device is IOS-based, amp up the bits-per-second, as each IOS device seems to be able to understand different bits of the various H264 profiles, and they're not merely additive (ie, AppleTV2 isn't 'everything the iPhone4 can do, plus some'). Throwing more bits-per-frame will always give you a better picture. All those fancy features are ways to achieve higher quality at a lower bitrate. Give yourself a big bitrate, and you don't need to rely on the fancy bits that will make your file unreadable on your target device.
  • Check your audio tracks! Sometimes the 0 track is not the main audio track. If you're not encoding all the audio tracks, double check that you're bringing in the correct one. Personally, I encode a number of audio tracks, including an AC3 passthrough of the original audio. For commentary tracks, and down-mixed main audio, I use AAC at 256kbit/sec.
  • Do yourself a favour, and DO  NOT burn-in your subtitles. Just trust me on that one. 


For transcoding, I prefer using the latest Handbrake, as it uses the very fast x264 engine for encoding to either .m4v or .mkv H264 containers. I looked around to find a good optimal encoder setting as a jumping-off point, but most sites had old information which wasn't directly applicable to the latest version of the app. I did however, learn about some of the advanced options which did have a relevance. 

I settled on starting with the "AppleTV 2" preset for my non-animated DVD content, but that yielded an image that I found unacceptable in most of my test material. In most scenes, the entire screen seemed like it was underwater. The macroblocks would shimmer and shake, making it difficult to concentrate on the material. From this, I made some minor adjustments, and I am pretty happy with the results.
  • First thing I did was raise the 'constant quality' slider from the default position of 20, to 18. This is actually a logarithmic slider where the smaller number indicates higher quality.
  • I also ticked the "No DTC Decimation" box which helped in areas where there are large areas of a single colour (or subtle fade)
  • Set the "Adaptive B-frames" to "Optimal" which gives a boost in efficiency to the Pyramidal B-Frames.
  • For cel animation, I increased the number of reference frames and B-frames to 6, and amped the 'constant quality' slider to 16
  • For B&W source material, I used a variant of my cel animation settings, but brought the B-frames back down to 3, and used the Greyscale filter in the Picture Settings sub-menu. This greatly reduced macroblock collapse which often happens in B&W and cel animation transcoding (large splotches of the same colour).

Now all I have to do is pop the resulting files onto the server, and ingest them into PLEX's database.

Date: 2011-08-16 06:25 pm (UTC)
From: [identity profile] mh58.livejournal.com
Another thing to consider is foreign language. I have some that I had to process thru Handbrake again due to forgetting about adding subtitles. DOH! I'll email you my Roku preset due to its length.

Date: 2011-08-16 07:10 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
Yeah, I'm good at adding the subs (I have a lot of foreign films), but it's making sure to TURN OFF "burn in", which inexplicably seems to be turned on by default.

Date: 2011-08-16 07:32 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
I read your Roku settings. That's for SD material yes? That's kinda-similar-but-different-from the "normal" preset (which is similar to the ATV2 preset), which I found to be difficult to watch. Is the Roku underpowered? I wondered how it'd be able to handle, say, 'found' MKV 1080p content. I considered a Roku as a streamer, but I found it didn't 'feel' right to me.

In all this transcoding research, the thing that annoys me most about IOS products is their total lack of B-frame support. How on earth do you have a mobile platform, and NOT use B-frames, which can give you much higher quality at any given bitrate? The only thing I can think of is the ASICs they're using to decode H264 aren't beefy enough to deal with them (or 1080p).

Date: 2011-08-16 07:39 pm (UTC)
From: [identity profile] mh58.livejournal.com
Yes, just DVDs as I have no HD DVD ripping capability as yet. Other items (TV Shows, etc.) are usually in MKV containers and varying resolutions (480 to 1080). The Roku will handle HD content fine if it has enough bandwidth. We are using Wireless (802.11n) now and it seems fine, except when a download is going at the same time.

Date: 2011-08-16 07:56 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
Yeah, external BR drives are getting cheap, and there is plenty of Mac-based software that will rip/transcode them.

Date: 2011-08-16 06:30 pm (UTC)
From: [identity profile] bootedintexas.livejournal.com
apple tv isn't HD? i thought that was the whole reason to use an HDMI cable with it, was because it was 1080p and in HD quality...

Date: 2011-08-16 06:59 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
the ATV2 tops out at 720p. Technically HD, but not good enough for me
(deleted comment)

Date: 2011-08-16 07:48 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
Yeah, I think your approach is a good one. I have noticed though, that my Core i7 2.7GHz (SandyBridge) SUCKS at transcoding using my Handbrake settings. I'm pretty sure however, the problem is diskIO, and possibly memIO as well. I'm averaging 40-60fps, whereas my giant Mac Pro with the hexacore Westmere (server) chip running at 3.33GHz tops out at over 300fps, and sustains 200+. The speed difference shouldn't be that severe.

Date: 2011-08-16 08:48 pm (UTC)
From: [identity profile] notdefined.livejournal.com
The chip I'm using (right now) is an i3-2100 3.1GHz

Date: 2011-08-16 09:00 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
Out of curiosity, if you use the Handbrake settings I outlined in the post, what kind of FPS do you get from transcoding a ripped-but-not-transcoded source on a harddrive?

Date: 2011-08-16 09:02 pm (UTC)
From: [identity profile] notdefined.livejournal.com
I'll leave that bit to Morgan because Plex is running on an Ubuntu machine and thus cannot run handbrake.

Date: 2011-08-16 09:04 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
HB can run on Linux… Ubuntu specifically (and Fedora) =)

Date: 2011-08-16 07:32 pm (UTC)
From: [identity profile] greatbearmd.livejournal.com
I like all that Plex has to offer, and I had downloaded it a little while ago. I am not lacking in any means for hard drive space on the LAN, and my 8-core Xeon can fly through transcodes (15k RPM SAS drives and an Adaptec RAID controller goodness!). My home theater PC is a bit long in the tooth, but it still performs adequately at 1080p. Since it won't be doing much more than storing and playing content, it should last me a while longer. The only thing I am lacking right not is the desire to much with all that stuff at the moment. PC stuff, unless there's a problem, tends to be a winter activity for me.

Date: 2011-08-16 07:39 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
I love PLEX these days. It also has an RSS reader, so I can watch all the TWiT network stuff on it in full HD (actually, I don't think they're doing 1080p feeds anymore, but it's better than SD)!

Are you using PLEX as your server/client, or are you using MS' solution (IIRC, they had a HTPC version of Windows)? The latest builds of PLEX really do work far better than their earlier counterparts. The idea of separating out the client from the server really allowed amazing stuff to happen (like remote-controlling, and JIT transcoding/streaming to IOS over the internet).

Date: 2011-08-17 04:07 am (UTC)
From: [identity profile] greatbearmd.livejournal.com
I will most likely be using PLEX on all of the PCs eventually. Most of the PCs are using Vista (I know...) Ultimate or Win 7, the HTPC has MCE XP, which was the forerunner to the media centers in the Longhorn based things. It's actually quite a friendly environment IMO. On the non-MC units I have later builds of Winamp, which do remarkably well, and can be extended with so many aftermarket codecs.

My media streaming setups have languished a bit since dealing with my health issues, and I am slowly taking care of things that became a bit more pressing. My main display flamed out on me (literally) a couple months ago, tonight I pulled the trigger on a Dell 30" IPS display. For the cost it was the best I could find in the size, there were far more expensive units (I liked an NEC as well, but it was practically double in cost) but this one had lots of features and good specs at the price point. The Apple Cinema display also was considered, but it lacked in the way of input choices. This PC is dual-link DVI, its replacement is DisplayPort (six of them if I am so inclined). The Dell has pairs of DP, DVI and HDMI, as well as composite and analog RGB, which can come in handy with the studio setup, and the inputs selected individually via the monitor OSD. Plus it will juuust fit in the space on this desk.

The new PC will get put into play once I heave all its parts into a more desktop-friendly chassis. It currently looks like the "Claw" stage setup that U2 has been touring with. COol to look at, but takes up way too much room, not to mention wide open.

Date: 2011-08-16 07:52 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
Indeed… I considered not transcoding at all, and just keeping full copies of the DVDs on the NAS, but I decided against it, as my 802.11n connection to the mini will be very saturated trying to deal with that much data while others are on the network. So I decided on a quality level that's fairly transparent from the original, but at 1/3 the total file size.

Date: 2011-08-17 03:51 am (UTC)
From: [identity profile] greatbearmd.livejournal.com
By compressing, you've also made the content a little bit friendlier to non-PC devices. Depending on your wired LAN speed you can toss that data to several clients without saturating. You can also get more than one stream out of n-wifi in most cases.

Date: 2011-08-17 06:37 am (UTC)
ext_173199: (TeeVee)
From: [identity profile] furr-a-bruin.livejournal.com
I was wondering why you were transcoding it all - I happen to like having the original DVD experience, and that's why I went with ISO images. (That, and it's an effective backup of the actual disks. If there's a fire, I can grab my Drobo and run. ;)

I know nothing about Plex, but if you need a worthy media extender for another TV, look at the WD TV Live Plus; I don't do HD myself, but I've played back 1080p content on a friend's TV and it worked beautifully, though admittedly that was from local USB-connected storage. For that matter, it's played back 1080p content scaled for my SD television without a hiccup - and yes, it does B-frames. ;)

Oh, and the bandwidth issue vanishes like mist in the sun with a length of Gigabit Ethernet cable. ;)
Edited Date: 2011-08-17 06:50 am (UTC)

Date: 2011-08-17 11:50 am (UTC)
From: [identity profile] theoctothorpe.livejournal.com
It's interesting that you'd prefer the 'original dvd experience', as most of my DVDs have horrible menu systems, or other non-skippable content/preroll, and that's the *last* thing I want to deal with.

My approach wasn't to have this as a true archive, but more a convenience than having to dig out the discs every time I want to watch something.

As for PLEX, you should check it out… it's basically a better XBMC (it's based off the same code), and has a pretty good (python based) plugin architecture. I now watch all my TWiT stuff through it (streaming).

Date: 2011-08-17 02:03 pm (UTC)
ext_173199: (TeeVee)
From: [identity profile] furr-a-bruin.livejournal.com
Some DVDs do indeed have lousy menu systems - but told to do so, DVDDecrypter will rip out all the prohibited user ops and one can then skip the formerly non-skippable content.

A good example of why I wanted to keep the DVD structure are the Star Trek: Deep Space Nine DVDs. There are a TON of easter-egg extras ("Section 31 Files") on the discs that I wanted to preserve. And like I said - in my case, this is intended both as an archive and as a convenience.

As for TWiT content - I prefer to download and transcode it - I apply a speedup to it and make some tweaks for better presentation on my particular TV.
Edited Date: 2011-08-17 02:04 pm (UTC)

Date: 2011-08-17 02:31 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
You speed up the video? Iiinteresting.

I still do the podcasts and such, but sometimes it's nice to just 'turn on TWiT' and see what's on (as if it were normal television)

I still want Leo to give us feeds of all the cameras (including the managed/switched feed), and let us pick =). I really like what he's done with the network. Interestingly, other networks are missing major components of what he's got, and consequently, aren't compelling to me.

Out of curiosity, which TWiT network stuff do you get/enjoy? Right now, I casually check TWiT, TNT, Dr. Kiki's Science Hour, Ham Nation, and TWiCH. Truth be told, I've become *really* bored with MBW, so while I still DL the podcast (audio only), I have about 6 I will probably just 'mark as read'. I also follow Alex Lindsay's Pixel Corps stuff, but sadly, not as regularly.

Date: 2011-08-18 12:40 am (UTC)
ext_173199: (TeeVee)
From: [identity profile] furr-a-bruin.livejournal.com
I speed up a lot of stuff - I tried to swear off it a while back, but it makes it possible to get through more media. I do the same thing to all my audio netcasts; that's actually where I started doing this. My netcast reprocessing script is set up so I can set an acceleration factor suited to the show (some hosts talk faster than others).

The easiest speedup is 25fps material to 29.97fps; 29.97fps gets accelerated more, to 39.96fps, then transcoded back to 29.97fps. (My WD TV Live+ will actually play the 39.96fps version, but it's smoother to transcode it.)

The basic process is:
  • Pull the video stream out with FFMPEG
  • Use the CLI interface of AVIdemux to recopy that stream with a new FPS
  • Pull the audio stream
  • Use SoundStretch to apply the corresponding tempo shift
  • Final transcode/reassembly via FFMPEG.
That last step adds some padding so modern material created with TVs that don't overscan in mind doesn't get "wasted" on my SD CRT, as well as having most of the "letterboxing" at the bottom, as for some reason I prefer that to having the image centered in the tube.

This is all accomplished by a DOS batch script so it wouldn't be directly usable by you, but I can get you a copy if you're curious about what I'm doing. I realize that copying the video stream twice is less than efficient - but I haven't been able to find a scriptable tool that can reset the FPS of a video file. (There's a GUI tool I found, but even AutoHotkey can't reliably script-ify it. *grumble*)

Date: 2011-08-18 01:50 am (UTC)
From: [identity profile] theoctothorpe.livejournal.com
Hmm… FFMPEG can't conform (to a new fps) a video? I kinda figured it could.

I've tried the speedup, and even with pitch correction, it just makes me tense ;-) Also, I tend to watch/listen to stuff when I have ample time, so I don't feel a need to 'get through' content. In fact, by the end of the week, I'm usually out of content for the commute.

Right now, I'm ripping my Square Pegs DVD =)

Date: 2011-08-18 02:15 am (UTC)
ext_173199: (BonkBonk)
From: [identity profile] furr-a-bruin.livejournal.com
FFMPEG will create a video of the same run-time with the new FPS - it won't simply change the FPS to allow the video to run faster. If there's an option to do what I'm currently using AVIdemux for, I haven't been able to find it in the craptastic excuse for documentation that FFMPEG suffers with. If such a thing exists or is eventually added, it'll take an extra step out of the process.

I guess there's just too much I'm semi-committed to - on a week-daily basis there's Countdown, The Last Word, The Rachel Maddow Show, The Ed Show, The Daily Show and Tech News Today in video, and The Stephanie Miller Show in audio.

Date: 2011-08-18 02:28 am (UTC)
From: [identity profile] theoctothorpe.livejournal.com
Ah, yeah, most of my stuff is weekly, not daily. By about wednesday/thursday I'm usually lacking.

Taking inventory of the downloaded podcasts, (all of them are audio, as it's just on the ipod) I've got:

* MacBreak Weekly (and as I said, I don't really listen to it much)
* ThisIsMyNext Podcast
* Beer School (barely alive)
* Hypercritical (John Siracusa formerly of Ars Technica)
* Know Tech (defunct)
* A Life Well Wasted (defunct)
* NPR Planet Money
* Scruffy Thinking (John Flowers' new odd podcast)
* Sound Opinions
* That Post Show (another John Flowers show he recently resurrected
* This American Life

Many of these are weekly, Planet Money is I think 2 or 3x a week, but some of them are "whenever" (beer school, scruffy thinking, that post show). I usually listen to a 90 minute show in, and another 90 min show coming back (it bleeds into my office time/home time).

Date: 2011-08-17 04:44 am (UTC)
From: [identity profile] danlmarmot.livejournal.com
What about sound formats?

1080p is all fine and dandy, but if sound is downsampled to 2 channel, it's not a win.

Date: 2011-08-17 04:51 am (UTC)
From: [identity profile] theoctothorpe.livejournal.com
I attach several audio tracks to a video. The usual setup is this:

1) 256kbit AAC stereo downmix of the main audio track (or mono if originally mono)
2) AC3 Passthrough of the main audio track (ie, no re-encoding, keep the original audio source)
3) 256kbit AAC stereo downmix of all commentary tracks (I could go mono with these, but I don't)

So all the vids have at least 2 audio tracks: downmixed for IOS devices/my TV (as it's currently not hooked up to a receiver/speakers), and the original audio for when I eventually get my shit together (5.1 dolby digital, or DTS, unaltered from the original source — which is sometimes stereo and mono — I tend not to care about upconverted audio tracks)

Date: 2011-08-17 04:52 am (UTC)
From: [identity profile] theoctothorpe.livejournal.com
Also, the above settings are for SD material. I haven't attempted to rip/transcode a BR disc, as I don't have a BR drive. I am however, considering getting one.

Date: 2011-08-17 10:21 am (UTC)
ext_173199: (Art!)
From: [identity profile] furr-a-bruin.livejournal.com
As far as Handbrake/x264 goes - when I started making my "lifeline" video collection, I decided that I would accept long encodes in return for good quality small files. Your mileage may vary, but here's the parameters I used:

Reference Frames - 5; Maximum B-Frames - 5
CABAC, 8x8 Transform and Weighted P-Frames - ON
Pyrimidal B-Frames - Default
No DCT-Decimate - OFF

Adaptive B-Frames - Optimal
Adaptive Direct Mode - Automatic
Motion Estimation - Uneven Multi-Hexagon
Subpixel ME & MD - Level 10
Motion Estimation Range - 16
AQS, PRD and PT all left at default

Partition Type - All
Trellis - Always
Deblocking left at default

This helps put an hour long episode (along with 96kbps Vorbis stereo audio) into a 175MB file that - to me, on my SD tv - looks damn close to the original DVD. You may well want to use more bandwidth - but there truly are serious benefits to letting the cpu really GRIND on an encode like this, especially when it's something you intend to keep on your network, not a throwaway transcode.

I concede I'm no expert on this, but I did do quite a bit of reading before I came up with this setup.

Date: 2011-08-17 11:45 am (UTC)
From: [identity profile] theoctothorpe.livejournal.com
File size isn't too much of an issue, so I wasn't concerned too much with getting the best quality out of a small bitrate, but I *did* want transparent-from-DVD quality A/V. Crushing the audio, say, to 96kbits wouldn't have achieved what I was looking for.

For example, Wizards, which is not quite an 90mins long, is nearly 2GB with the 3 audio tracks. They never really did any restoration, and throwing more bits at the problem prevented it from looking like arse.

In contrast, a new digital xfer Batman Begins, which is over 2.25h, with 4 audio tracks, is only 1.7GB

Date: 2011-08-17 02:12 pm (UTC)
ext_173199: (Dingbot Prime)
From: [identity profile] furr-a-bruin.livejournal.com
I realize we had two different goals here - but my point is that the more computationally intense options in x264 aren't there just to help keep your house warm by maxing out your CPUs - they really, truly do affect the picture quality.

As the saying goes - "small file size, fast encode, excellent picture quality - pick two." In the case of my "emergency" video archive, I threw "fast encode" out the window, and used intense encode options to ensure I kept the other two. (And for standard TV episodes, frankly - 96kbit stereo in Vorbis is fine. For a movie with more dynamic range and especially to retain surround - obviously you need more.)

Date: 2011-08-17 03:26 pm (UTC)
From: [identity profile] uncle-dan-nyc.livejournal.com
Most. useful. Post. Ever. I've been wrestling with this for years.

Date: 2011-08-17 03:44 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
Cheers!

That's why I had to post it. No where have I found this kind of information in one place. Of course, my usage of these apps/settings work for me, but they may not be what you need, depending on what you're trying to accomplish. For example, [livejournal.com profile] furr_a_bruin is getting all his discs onto disks for archival purposes. I'm merely doing it for convenience.

When starting to transcode your material, start with one of the presets, then queue up a transcode… then with the same source material, tweak the settings a bunch of times, creating new presets (in case one works really well), and add them to your queue (you'll want to give the files unique names)… then let 'er rip! In the morning, you can then do a proper comparison between video/audio quality and presets. Pick the one that's best for you, and use it. Keep in mind, for different programme material, you'll want to alter the settings.

Date: 2011-08-17 03:56 pm (UTC)
From: [identity profile] cpj.livejournal.com
Fiber-channel disk in the home? I'm jealous.

Date: 2011-08-17 05:36 pm (UTC)
From: [identity profile] theoctothorpe.livejournal.com
Ayup. For my HD video editing stuff.

Actually, 5 of them, in an array.
Edited Date: 2011-08-17 05:36 pm (UTC)

Date: 2011-08-17 10:04 pm (UTC)
From: [identity profile] cuboz.livejournal.com

Oh my...

I don't consider myself a dumb person, and I like to think that I'm pretty good with technology - but I think something sizzled and sputtered out in my brain when I read this post... You are obviously a very, VERY clever man indeed!

The best I can do is use Handbrake on the iPad preset to get the best quality for watching movies and TV shows on my iPad! And that's about it! LOL

Date: 2011-08-18 02:35 am (UTC)
From: [identity profile] theoctothorpe.livejournal.com
HB's presets are really quite nice. As I mentioned, I used them as a starting point, then just tried out a bunch of stuff. My main machine (Gilgamesh) is a monster that can transcode obscenely fast. I just did a bunch of test runs, and compared them. The best one was chosen for that type of programme material, and that's the one I use =) I am *sure* (as [livejournal.com profile] furr_a_bruin has mentioned) there are ways to get roughly the same quality level that I have, but use much less space on disk, but I have an obscene amount of drive space, so it wasn't super-high priority goal of mine to achieve maximum efficiency.

Profile

octothorpe: (Default)
octothorpe

Expand Cut Tags

No cut tags