Saturday, April 21, 2012

Better TV show naming for Plex Media Server

Files added to Plex Media Server need to be named a certain way so that Plex can find the right information online. The naming convention is documented online. Movies should be named "Movie name (year).ext", which is perfectly appropriate. However, the TV show "Show name\Season #\Show - s##e## - Optional episode name.ext" naming isn't the best choice. Some shows only have one season, making the "Season 1" directory and "s01" in the filename pointless. Also, the "Show name - " is pointless at the start of the filename, because the file is already under the "Show name" directory. When viewing the folder via DLNA or other means, a long show name can make it harder to view the episode number and name, which is what really matters. Fortunately, it is possible to simply use "Show name\E## - Episode name.ext". When there are multiple seasons, it's also possible to not use the "Season #" directories, but I do not recommend this. The season number can be a single digit, but episode numbers must be two digits. The " - Episode name" part is ignored by Plex. However, it is useful when viewing the files via other means, so I recommend including it. If you have a show with no online metadata, you can use a Perl script to import episode names from the file name into Plex.

I automatically renamed all my shows to this more sensible naming convention, and Plex Media Server automatically picked up the changes without any problems. Here are the commands I used. They create a shell script which does renaming. You can just add | sh to the end but it's better to look through the output a bit first, to make sure that it's sensible.

find . -type f -iname "*[Ee][0-9][0-9] - *" | sed -n 's|^\(.*/\)\([^/]*\)\(/Season [0-9]*/\)\2 - \(.*\)$|mv "&" "\1\2\3\4"|p'
find . -type f -iname "*[Ee][0-9][0-9] - *" | sed -n 's|^\(.*/\)\([^/]*\)/\2 - \(.*\)$|mv "&" "\1\2/\3"|p'

Cogeco clear QAM list for Windsor, Ontario

Here is a list of clear QAM channels I could receive via Cogeco cable in Windsor on April 21st, 2012. It is based on an old list I found, but a lot has changed since then. Clear QAM is not an official offering from Cogeco, and channels can be moved, removed or added at any time without any notification. It's a good idea to re-do auto tuning regularly to pick up any new channels. Almost all channels are SD and there are channels which cannot be received via analog or clear QAM. As a result, clear QAM is not a good alternative to a Cogeco receiver. Note that in some cases, the second number of the channel corresponds to the channel number in the official Cogeco lineup.

[ Updated January 10th 2013 ]

Note: It seems channels which are available for free preview for the month are available via clear QAM. For example, the four channels from the High Fidelity HDTV network are listed here.

QAM Number Call sign Long name HD
46-774774OASHDOasisHD HD
47-275741SCRHDThe Score HDHD
65-117950BETBET - Canada
65-710710TVOTVO (TV Ontario) HDHD
65-803803CTV2LCTV Two Windsor, ON HDHD
91-1714MMMuch Music
91-3668SCOREThe Score
91-5726SLICESlice
91-7021CTVNNCTV News Channel
92-1212CBLFTSRC (CBLFT) Toronto
92-2817CBCNNCBC News Network
92-4058SHOPShopping Channel
92-6013CKCOCTV (CKCO) Kitchener, ON
92-6620TFOTFO - Chaine Francaise
92-7323TREETreehouse
92-10549SPEEDSpeed Channel Canada
92-924924TSNTSN
92-9519HOMESReal Estate Channel
93-22TVOTVO (TV Ontario)
93-5670CPACCPAC Ottawa
93-5819VISIOVision TV
93-8625TV5TV5 International
93-123123BITEBite TV
94-2716YTVYTV (Youth Television) - East
94-6857CFTMTVA (CFTM) Montréal
94-7169OLAOntario Legislature
94-7476APTNAPTN - East
94-9164OWNOprah Winfrey Network Canada
94-93111BNNBNN - Business News Network
94-145145ACTNAction
102-38045TOONTeletoon - East
104-524911TVCCogeco WindsorHD
105-306134GOLDComedy Gold
124-33CIIIGlobal (CIII) Ontario
124-761CITYCITY TV Toronto, ON
124-1059CHCHCHCH Hamilton, ON
124-93918TWNWeather Network
124-9416CTV2LCTV Two Windsor, ON
124-94862WMYDMNT (WMYD) Detroit, MI
124-979979TVLISTV Listings
125-463OMNIOMNI Television
125-783CIIIGlobal (CIII) Ontario
125-79
125-80Global
125-8167WTVSPBS (WTVS) Detroit, MI
125-10353GOLFGolf Channel Canada
125-92711TVCCogeco Windsor
125-9457WJBKFOX (WJBK) Detroit, MI
125-946CBC
125-94760WKBDCW (WKBD) Detroit, MI
126-6722RDIRDI (News)
126-9770CPACCPAC Ottawa
126-118118GTVGame TV
126-151151RSESportsnet (East) - Satellite/Digital
126-152152SNWSportsnet (West) - Satellite/Digital
126-153153RSN-PSportsnet (Pacific) - Satellite/Digital
126-184184EWTNEWTN Canada
126-185185SALT&Salt & Light
126-555555AMI-tAMI-tv East
127-10848FOODFood Network Canada
127-11042STAR!E! Canada
127-11232MMMMuch More Music
127-114114MTVMTV Canada
127-156156TSN2TSN2
128-11VODPVOD Preview
128-149149WMOVW Movies
128-151151RSESportsnet (East) - Satellite/Digital
130-775775RadXHRadXHDHD
130-776776EQHDeqhdHD
131-764764FOODFood Network CanadaHD
137-777777HIFIHIFIHD

Monday, April 02, 2012

LG Smart TVs are kind of stupid

Here are some stupid things about the 47LW5600, a 2011 LG "Smart TV":
  • In SmartShare (USB and DLNA mode) only a short bit of the file name is initially visible. When episode file names start with the show name (like Plex recommends), I only see the show name. My photo folders start with the date, and there I only see the date. To see more, it's necessary to highlight one item and wait for text to slowly scroll.
  • When switching between photos in SmartShare, the screen abruptly goes black and stays black until the next photo appears. Loading of 4MP photos takes over a second. That's ridiculously slow! They could have made it instant by pre-loading the next photo. It's a lot better in LG Media Link. There, only very large photos display a loading animation, and the slide show has fades.
  • High bitrate spikes will cause playback interruptions when streaming over the network via SmartShare or LG Media Link. The TV can peak at around 86% network utilization, but it can't sustain that and there is very little buffer space to accommodate peaks. Sustained H.264 bandwidth exceeding 50 MBps is sufficient to cause video interruptions. These problems don't happen when playing from USB.
  • The lack of DTS support is stupid because the format is popular. It can be transcoded while streaming, but that doesn't work correctly. When using Serviio, seeking becomes impossible. This seems to be because the TV can only seek based on file offsets, but those are not known while transcoding. When using Plex Media Server, video gets transcoded. Even when that is fixed, there are pauses, apparently due to excessive CPU usage and inefficient multithreading in the server. The only good solution is transcoding audio beforehand. When using MKV files, that's easy to do via MKV2AC3. It kind of makes sense because AC3 offers almost the same quality at less than half the bitrate, but I don't like transcoding from one lossless format to another. The best solution is encoding the DTS-HD lossless track to AC3 when ripping, but I'm not sure how to do that.
  • The TV mysteriously rejects some AVI files. Fortunately, that's easy to fix by converting to MKV using mkvmerge. As a bonus, that decreases file size a bit without losing anything.
  • When playing files, it's not possible to switch audio tracks or use MKV chapters. Subtitles embedded in MKV files are only supported when playing from USB. When a file of sufficient length is played from USB, the red remote button can be used to switch chapters, but those are just the file divided into 10 equal sized parts; they have nothing to do with MKV chapters.
  • No idx/sub subtitle support. (The "*.sub (MicroDVD, SubViewer 1.0/2.0)" mentioned in the manual is not the same thing.) You must use OCR to convert graphical subtitles to text-based subtitles such as .srt.
  • The web browser is slow and it lacks Flash support. You can't stream any video using it, and so you're forced to rely on what's available via apps and LG Media Link. If you just want to look up some basic information, it's certainly usable. However, getting up, waking a computer from standby and looking it up on the computer is faster.
  • The YouTube app does not show much information about videos, so it's hard to choose which video to play. Again, LG Media Link does it better. There is one good thing about the built-in YouTube app: it will play YouTube 3D content in 3D.
  • SmartShare seems to occasionally drop frames even when playing 30fps SD content and not experiencing any buffering issues. It's not a big deal; I just think it ought to be perfect. I wonder if it's just an AVI issue. It's possible to play 640x480 H.264 at 60 fields per second interlaced in an AVI in both SmartShare and LG Media Link, but both result in horrible frame dropping. If I simply remux it to MKV, it's super smooth. (The TV also seems to deinterlace really well. The image is so good that I'm very happy with my decision to encode NTSC video to interlaced H.264.)
  • Some settings are not remembered properly. Audio can become un-muted when switching between modes. In LG Media Link, all files start playing stretched to the whole screen, requiring a few clicks to get the proper aspect ratio.
  • The interface is inconsistent. Different modes have different looks and different ways of changing settings. Most notably, SmartShare and LG Media Link have two different video playback screens (overlays). That's understandable because they're two different applications. However, they're built in applications in the same product. The user interface should be consistent. (I'm not complaining about how the file browsing screens are different. That's part of the fundamental nature of the applications.) 
  • There is no support for common Bluetooth or USB devices like headphones or keyboards. The TV does have Bluetooth for the Magic Motion Remote. It would be nice to be able to use Bluetooth headphones or wireless keyboards. That would be truly smart.
  • It's not possible to zoom 4:3 content while preserving the aspect ratio. This means if you encounter 16:9 content that has been letterboxed to 4:3, you can't expand the content to fill the screen. (No, it's not really a Smart TV issue, but it is definitely a software issue.)
The only really impressive part that deserves to be called smart is LG Media Link and Plex Media Server. It can present beautiful indexes of content, with covers, other artwork, and various information. Plex also provides a gateway to many sources of online streaming video. Even in Canada, many full TV shows can be streamed from TV channels via Plex. However, there are various bugs and issues. Also, Plex isn't very nice when it can't find online data about a show, making SmartShare better in those cases.

I like the picture quality. The higher black level of the IPS panel can seem a bit disappointing in bars around the image, but the image is vivid and not washed out. It's so good it can feel like actually being there.

The LG passive 3D is great too. The glasses feel like cheap crap that would deserve a bad review on DealExtreme, but they're light and very comfortable. If they break, they would be inexpensive to replace. As long as you're within the very limited vertical viewing angle, there is no crosstalk. The horizontal viewing angle is wide.

Overall, it's a nice TV, except for the "Smart" features. They feel more like an alpha or maybe beta, and definitely not like a final release. While they are usable, they can't fully replace the direct connection of a computer to the TV. The hardware is certainly capable of much more, but I don't think any TV manufacturer is going to spend much effort on improving firmware once a model isn't sold anymore.

Monday, March 26, 2012

Hitachi 26AX10BC chassis M1CLUX-H TV vertical foldover fix

This is a Hitachi CRT TV from 1995, model 26AX10BC with chassis M1CLUX-H. When first turned on, the top of the image is vertically stretched, upside down, and overlapping at the top of the screen. This means the vertical retrace does not finish before it's time to start displaying the next field. It's called vertical foldover. Here's a picture. (Sorry, it's just a blue screen, so you can't see how the overlapping part is upside down.)
After a few minutes, the problem area starts shrinking, and after about 10 minutes it's gone. However, it always comes back if the TV has been off for a while. This makes it seem like the problem goes away when some component warms up.

It's an easy fix. However, note that the internals can retain dangerous voltages even when the TV is off. They could maybe even kill you. Make sure you understand what you're getting yourself into. Read about the risks and how to stay safe, intelligently decide whether to do this yourself, and be very careful.

The back is pretty easy to remove. Many screws around the edge connect it to the plastic front, and three screws above the back connector panel connect it to the main board assembly. The TV can stand on just the plastic front, so the back can be removed while it is upright. I kept it near the edge of a workbench. This allowed access to the screw at the bottom, and when the back was removed it allowed access to the bottom of the main board. That position seems precarious, but the TV is not too close to tipping over. Make sure that the table is not close to tipping over. Also, when removing the back, make sure that it does not fall and strike the board at the back of the picture tube neck. If you need a service manual, the 27AX5BX manual will probably suffice.

Here is a the main board. It is on rails, and held to the front plastic with two screws at either side. If you unscrew those, you can slide the board out a bit for better access to the bottom. It's worth doing that, because working on the bottom is much easier then. You could even unplug cables and take the board out, but it's not necessary for access to the vertical deflection circuit.
The vertical deflection chip is attached to the C shaped heat sink that's just above where the red high voltage cable bends first after exiting the flyback transformer. Here is a closeup of the area:
You can easily see the brown ring on the top of C625 (47µF/16V) the closest electrolytic capacitor on the right inside the heat sink. That's electrolyte leakage and the capacitor is bad. Another suspect is C627 (100µF/35V on the schematic, with a 50V capacitor installed) the larger and darker capacitor to the left near the nut and bolt attaching the chip to the heat sink. There is a darker area on the circuit board below, like a puddle.

C627 is the pump-up capacitor for the LA7838 vertical deflection chip, and it is the main suspect. It is part of a charge pump. The chip first connects the capacitor to the power supply to charge it, and then it connects the capacitor in series with the power supply, to provide twice the power supply voltage. This higher voltage is used to quickly move the beam back to the top. A problem with the capacitor will mean less power is available for moving the beam back to the top. This will slow down the move, and the beam won't be able to reach the top before it's time to start displaying the next frame. C625 The small capacitor with the brown ring is a power supply filtering capacitor. It could contribute to the problem if the power supply dips when the vertical deflection chip uses a lot of current.

When I looked under the board, I saw a surprise. The trace between the pump-up capacitor and the chip was missing, and one of the capacitor leads was used to make the connection. This plus the different look of C627 made me wonder if this was a previous repair. Could the pump-up capacitor be good, and could the puddle-like mark on the board be from a failed previous pump-up capacitor?
The Yubright capacitor brand and the nature of the failure made me curious, so I tested the ESR of the pump-up capacitor. Although the capacitor still had most of its capacity, the ESR was ridiculously high, and so the capacitor was obviously bad. There was no need to test the small capacitor, because it was leaking badly. After I removed it, there were drops of electrolyte on it.

After cleaning the board and replacing C625 and C627, the TV worked properly. I chose to not replace more capacitors. Yes, it's probable that some other ones are degraded, but there are very many and it's not worth the effort. The real problem here is that a lot of electrolytic capacitors are located very close to heat sinks. Hitachi even used 85°C capacitors there!

Plex Media Server DTS transcoding fix

Plex Media Server 0.9.5.3 unnecessarily transcodes video when transcoding audio for LG clients which can't play DTS. This increases CPU utilization, and it can cause buffering pauses in video if the CPU isn't fast enough. The issue has been in the Plex forums in this thread and others.

This solves the problem. When "Plex Media Server.exe" runs another executable, the attempt is intercepted, and the command line is changed, as described by enachemc on the Plex forum. The command line change tells the transcoder that the device can accept H.264 video at up high profile, 1080p, and level 4.1.

The interception is done using Detours from Microsoft Research. I chose Detours 2.1 because I had problems with Detours 3.0. The code is compiled from PlexTranscodeDetour.c, creating PlexTranscodeDetour.dll. That DLL needs to be inserted into the "Plex Media Server.exe" process. I recommend insertion via withdll-silent.exe. It supports the same switches as the ordinary Detours withdll.exe, but doesn't open a console window. For example, if Plex Media Server is installed in "C:\Program Files\Plex\Plex Media Server" and these files are in "C:\Program Files\Plex\PlexTranscodeDetour", then you can change the Plex Media Server shortcut target to:
"C:\Program Files\Plex\PlexTranscodeDetour\withdll-silent.exe" "/d:C:\Program Files\Plex\PlexTranscodeDetour\PlexTranscodeDetour.dll" "C:\Program Files\Plex\Plex Media Server\Plex Media Server.exe"

I am also including an unmodified withdll.exe, which produces diagnostic output to the console. You only need to try that if you have problems. Alternatively, you could maybe edit "Plex Media Server.exe" to include the DLL via setdll.exe. I don't know if that works.

I recommend using Microsoft compilers such as Visual C++ from Visual Studio Express 2010. Detours does not come with binaries, and if you want to compile it, you must use a Microsoft compiler. You can't even statically link with detours.lib from the GNU toolchain because the linker cannot resolve some of the symbols in detours.lib. If you want to use the GNU toolchain, you can use the instructions I posted earlier to create a detours.dll that you can use. I felt forced to use Visual Studio Express because I didn't think I was allowed to distribute the detours.dll that I created using those instructions.

You can download PlexTranscodeDetour from Dropbox. You are free to do whatever you want with my code here. Detours components are distributed according to the license from Microsoft Research. This code and program comes with absolutely no warranty. Use at your own risk.

Monday, March 12, 2012

Honda keys suck

The battery contacts are covered with grease which results in a bad connection. What at first seems like bad buttons on the module or a low battery is more likely that problem. The positive connection is made by the two contacts at the top of the right half touching the gold pad at the top of the left half. The negative connection uses four contacts in the centre of the left half which touch the battery. All of these are covered by the grease. You can easily see the four grease spots on the battery, and if you look at the full resolution photo, you'll also be able to see grease on the other contacts.

Unfortunately, to fix the problem you need to unscrew the small screw which holds the key halves together. The threads are coated with blue thread locking fluid. If that's Loctite, it's supposed to be possible to disassemble using normal tools. Unfortunately it's not very easy. You need a good screwdriver that fits well, a lot of downward force to prevent slipping, and strong turning force. Heating the screw with a soldering iron might help, and if done carefully, it doesn't seem to damage the plastic. I first got the screw to turn a bit, but it wouldn't go any further. What finally helped was spinning the screw back and forth a bit continuously while unscrewing.

This is a ridiculous design. Changing a battery shouldn't be that difficult. This deserves a recall.

If you want more information on the procedure, here's another guide. The only other tricky thing I encountered was separating the two key halves at the key ring end. They refused to simply pop apart, but wiggling from side to side (ie. rotation around the axis through the key ring hole) allowed the halves to separate. The battery is a CR1616. Some parts of the photo are blacked out because I don't know if any of those numbers are codes for remote unlock or the immobilizer.

Tuesday, February 14, 2012

Impressive iPod battery life

I just replaced the battery in my 30 GB 5th generation iPod. The decreased play time with the old battery wasn't a problem for me, but the increased internal resistance was. Combined with the higher internal resistance at low temperatures, it could cause a shutdown even if the battery was over half full and the temperature was well above freezing.

There are many choices, many different prices, and little information on what's actually good. After some research, I decided to buy a 580 mAh battery from richmondliu88 on eBay for $3.99.

It arrived in Canada in under 2 weeks. The battery was packed in plenty of bubble wrap, and it arrived with two blue plastic tools. The tools made it easy to open my iPod, and they weren't destroyed by the process. It was easier to open the iPod because of past openings, but nevertheless, it seemed like the tools were of above average quality.

I just measured the battery using Rockbox battery_bench. First, I charged it until current in the battery debug screen dropped to zero. For the test, I played Dark Side of the Moon in MP3 format, encoded with LAME using preset standard, with repeat all enabled and JPEG album art. I tested it using my typical listening conditions, with the EP-630 headphones, an inline volume control which raises resistance to 70Ω, the screen off, and hold on. I'm running the PP502x cache bug and ATA DMA test build, which is based on e362e34. The battery lasted an impressive 19 hours and 45 minutes.

Here are some photos of my battery. The same eBay item currently shows a different looking battery. Note the paper on the back, which needs to be peeled back to uncover a sticky area for attaching the battery to the iPod back. It's a nice touch, although it was unnecessary for me because the glue that was already present on the iPod back was very sticky and hard to remove.

 

Wednesday, January 25, 2012

In OS X, SDL only delivers messages to the first thread?

I was trying to get a Rockbox simulator working in OS X. After dealing with a bunch of other issues, I got an executable which displays a beachball cursor and doesn't respond to input.  I found a post that claimed events sent to the app are only dispatched to the main thread. Then I rearranged code so the main thread initializes the video and handles messages and input worked properly.

The SDL documentation claims SDL_WaitEvent() can only be called from "thread that set the video mode". This is apparently not a sufficient condition for OS X.