Thursday, September 27, 2012

Encoding content for Roku 2 and MyMeida

There are many sources on the Internet that explain how to encode content for Roku 2. Unfortunately most of the sources are obsolete and use outdated versions of tools. I will try to share my experiences in this post.

The simplest way to encode content for Roku is to use Handbrake. The current version 0.9.8 includes Normal preset which works well with Roku. The High preset also works but sometimes produces out of sync video and audio. It also takes significantly longer time to encode with the High preset. Selecting MP4 container and leaving all other options in their default state works well and gives reasonably fast encode with good quality video. Please note that Normal preset does not support multichannel audio by default.
Encoding with ffmpeg is a little bit more involved but gives a great deal of control over encoding time as well as encoding quality. This is example command line that works with ffmpeg version 20120924-git-bbe9fe4:
ffmpeg.exe -i "video.avi" -acodec libvo_aacenc -ab 128k -ac 2 -vcodec libx264 -preset veryfast -profile main -crf 18 -threads 0  -y "video.mp4"
This will produce video compatible with Roku but the bit rate would be on the higher side. To decrease bit rate different preset can be used. Following presets are available - ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo. Start with medium (default) and go faster until the balance between encoding speed and bit rate is satisfactory. You can also use high profile but it will slowdown your encoding. When using high profile specify -level 4 option because Roku does not support anything above level 4:
ffmpeg.exe -i "video.avi" -acodec libvo_aacenc -ab 128k -ac 2 -vcodec libx264 -preset veryfast -profile high -level 4 -crf 18 -threads 0  -y "video.mp4"
Faster presets generate larger files and slower presets generate smaller files. Try it out to see which one works well with your computer and gives you smallest file in an acceptable time. The veryslow and placebo presets together with high profile do not work with Roku and cause macroblocks and frozen picture during decode

To my surprise Roku can also decode MPEG-4 Part 2 (Xvid). Any avi file that is encoded with this codec can be quickly converted in to MP4 file without re-encoding the video. Audio most likely has to be re-encoded but this takes much less time than video encoding. Roku only supports AAC audio and Xvid files usually contains MP3 or AC3 audio. To convert compatible Xvid file use this command:
ffmpeg.exe -i "video.avi" -acodec libvo_aacenc -ab 128k -ac 2 -vcodec copy -threads 0 -t 120 -y "video.mp4"
To test if your file would work without completely converting it use -t 120 command line switch. This would convert first 120 seconds of video and allow you to test it out with your Roku. Remove this switch from command line after you satisfied that the resulting video works. Xvid was and still is a very popular codec and people accumulated a lot of content encoded with this codec. DivX codec should also be compliant with MPEG-4 Part 2 but I have not tried converting this type of files as I have none.

I found that Roku MKV support is very poor when streaming over the network. The device often crashes when starting video playback or trying to seek within the content. When played from the USB stick there are no such problems. To avoid any issues it is best to convert mkv files in to mp4 which can be done without re-encoding video and audio in most cases. You need to make sure that your mkv file contains h264 video and AAC audio. You can do this by using ffprobe which is a part of ffmpeg package. You can convert container with ffmpeg or mp4box tool. Following command line works with ffmpeg:
ffmpeg.exe -i "video.mkv" -codec copy "video.mp4"

Stay tuned for more Roku information.

Sunday, September 23, 2012

Handbrake Lipsync and Roku

I occasionally have lipsync problems with Roku when encoding videos with Hanbrake. Handbrake does not appear to give you any control over audio or video delay. In theory, if the source is correctly synchronized the output should be synchronized as well. In practice that works only with VLC but not with Roku.
I found that the profile selection affects lipsync the most. I am not sure why that is, but Roku handles high profile poorly as far as audio synchronization goes. I performed several tests and all of them came out with the same result - audio is ahead by about 1 second. VLC plays these videos correctly but in Windows Media Player lipsync is off the same way as Roku. This can serve as a test - if WMP plays video correctly, Roku will too.
What is interesting that the "Preview" does not show any issues in WMP or VLC, therefore checking just preview alone would not help. You would need to encode about 10 minutes of video to judge correctly.
If you are encoding lower quality file, it does not make sense to encode in high profile as the source is already low quality. If you want to preserve quality as much as you can, adjust "Quality" slider in the "Video" tab to 18-19. You will get a bit better quality at the expense of the file size.
At this moment my recommendation would be to stick with "Normal" preset when encoding for Roku, especially for lower quality content.

Saturday, September 22, 2012

WDTV Live has many problems

Today I sent WDTV Live device back to the store. It was an easy decision and I understand why it was returned the first time around. Below is incomplete list of problems that were encountered during the week WDTV was in my possession.

The avi files do not play well over DLNA or Samba share. To be honest, some files do play but most  stutter. The high bitrate mp4 files do not play well at all. Roku plays these same files without any hitch. The wmv files also hit and miss. Some do play really well, some do not play at all.

User interface is very clunky and slow. If the DLNA server crashes, the box completely freezes or becomes so unresponsive that it is useless. At this time the box must be rebooted to bring it back in to the working state.

Different video controls are available depending on the type of the video file which makes the UI inconsistent. The mp4 files and the mkv files can be positioned to a time point, the wmv and the avi files cannot. Files or all types can be fast forwarded but the max speed is only 16x and it seems much slower than that in practice.

Hulu application is much worse than the one on Roku. This is one of the most used services in our household because we do not have cable so it is important that Hulu app works. With WDTV  only few shows can be played and then application needs to be restarted in order for it to work. The ad insertion on Roku is almost like in broadcast tv. On WDTV the ads buffer separately and there is a significant pause before and after the ad. It makes duration of the show to be almost as long as over the cable. The only useful feature of WDTV Hulu app is that one can force maximum bitrate . The app on Roku is much newer version than the WDTV and that may explain the difference.

The "channel" selection on WDTV is  much smaller than on Roku and the box looses big in this respect. The server software for Roku is very simple, MyMedia being an excellent server. The server software I used for WDTV was the PS3 Media Server. This server is very reasonable but it gets huge after running for a while and has to be restarted. It also takes a bit of knowledge to configure this software correctly. Live transcoding mode supported by this server does not work well on my quad core Phenom so I have to transcode offline which negates some of the convenience.
At the end I could not figure out a format that would be well supported by both Roku and WDTV and as a result each file should be encoded in two formats. If you would like to watch content on both devices the size of your library would double.

Given all of the above my derision was to standardize on Roku boxes to minimize size of the library and improve over all experience. Too bad no company can figure out how to do networked media player correctly.

Tuesday, September 18, 2012

Update on WDTV subtitles and more

I have been trying to get WDTV subtitles working with mp4 format so I don't have to keep separate format for Roku. So far I learned a few things. First is that WDTV does not appear to understand internal subtitles inside mp4 container. I was able to multiplex subtitles using ffmpeg as well as mp4box. In both cases VLC was able to play subtitles but WDTV was not. The second thing I learned is that Roku does not appear to understand multiplexed subtitles ether. This fact is apparently documented on Roku forums and elsewhere online. The third thing I learned is that WDTV is pretty bad at playing mp4 files. Somehow the playback is very choppy and the video freezes a lot. Monitoring consumed bandwidth I found that it is very low and is not enough to play the content smoothly. Converting the file in to mkv container without transcoding, fixed all playback problems. The bandwidth consumption became much more even and video played without any issues. This was a bit surprising as Roku played the same mp4 file rather well.

Monday, September 17, 2012

WDTV subtitles from DLNA server

So far I could not figure out how to stream external subtitles from DLNA server. However WDTV supports MKV container and subtitles can be embedded in to the video file. To do this use mkvmerge tool from the mkvtoolnix set. Obtain the srt subtiles for the content you want to watch and then run following command to merge the subtitles and the video in to one mkv file:

mkvmerge.exe -o output.mkv input.mp4 input.srt

This will produce the mkv file that can be streamed over DLNA and your WDTV will be able to display the subtitles. Roku on the other hand can not display subtitles from the MKV container and needs an external file. Given that Roku often crashes when playing or navigating in the MKV file, you would need to keep a separate mp4 file and a srt file for the playback on Roku.

WDTV Live again

I took my replacement Roku back to Costco and decided to give WDTV Live a second try. The box arrived from Amazon and I was excited to to open it and start comparing it to Roku (again).


The WDTV box is obviously larger than Roku but that does not bother me. Ether box is small enough to be placed somewhere near your TV.  The WDTV is also more power hungry than Roku, it has a larger power supply and runs much warmer. The WDTV is noticeably warm on touch even when in the off state. The box is running Linux and clearly does not power off, other than turning off the video output and the led. Nether does Roku but the chip it uses is less power hungry.

After spending 2 days with the WDTV, I am back to thinking that Roku has more polished product, despite all of the shortcomings. But let me describe things in order.
Configuring WDTV box takes about the same time as Roku - you need to configure network and your TV output format. The WDTV has few more customizable options that allow you to set various things but over all experience is close. The WDTV does not have any downloadable apps so the configuration ends here.
We only have Hulu Plus so I registered box with the Hulu site and tried watching some content. The Hulu app on WDTV is somewhat different from the Roku version. Queue display is different and also the WDTV app allows you to set the bitrate, which is a great feature! Roku app often stutters because the bitrate of the content is too high and there is no way to get it down. When I run in to this problem I will try to compare the two boxes and post my observations.
The local content playback is the area where WDTV suppose to shine. It does play any format that I have tried. It played all the MKV files, that caused Roku to reboot, without any problems. There were however few issues.
First problem was to get Windows7 to share the files. This task should become simpler to accomplish with Windows7, in reality it was more complicated than XP. For some reasons after enabling Home Group sharing the WDTV still did not see the the directories. Eventually after some fiddling with the settings, the box could see the shares and play the videos. It worked OK for the lower bitrate videos but somehow higher bitrate made it stutter. I assume the problem is with Windows networking being too chatty. Same videos over DLNA worked just fine.
The second problem is finding a good DLNA server. I have tried every free DLNA server running on Windows that is listed on Wikipedia. I wanted a small footprint DLNA server since at the base of DLNA is just a simple web server. Most of the servers are large and some of them are unstable. When the DLNA server crashes the WDTV box gets very unhappy! The menu is completely unresponsive and the only reasonable solution is to pull the power plug.
At the end I settled on two candidates - PS3 Media Server and Serviio. Both seem to behave more or less OK although both use copious amounts of memory, with Serviio being a little smaller.
One thing I wanted to mention in conclusion - I could not get external subtitles to work with the DLNA server. If subtitles are important to you Roku seems to be easier to get working with the external subtitles.
I will keep this blog updated on my experience with WDTV over the next few weeks.

Saturday, September 8, 2012

Roku: review after few months of use

We have used our Roku XS devices for a few months and there are few things I wanted to say.

The honeymoon is over

 I liked this device initially but as I used it more and more my opinion about it plummeted. Now the initial good impression is completely displaced by its problems and quirks. For starters there are a lot of problems with the hardware and the software. My first Roku XS remote is died within a week and I took the device back to Costco for a replacement. My second Roku XS was rebooting randomly when in the sleep mode and not booting back after that without power cycle. I took that one back to Costco too. I did not even unpack the replacement Roku and will take it back this weekend after more frustrations with the current unit.

Roku problems

Where do I begin? 
Automatic updates to the software - this has to go. Roku updates itself to the new version of the software without any way to revert back. The new software at times is worse than the previous but there is no way to stop the update. If you find a good version of the software you can't keep it on your device. The bottom line is that this feature will bite Roku (the company) in the rear one day.

HuluPlus - we have been using this service to watch TV after dropping the satellite. The app is bad from usability standpoint and also the service is slow. I have no problems with their content, if one does not like the content, one does not have to subscribe. I do have a lot of problem with their inability to deliver it. Half of the movies that I tried from Criterion collection fail to play smoothly. Hulu states that I need 3Mb/s service for HD quality. Well, I have 19Mb/s at all times and I want to watch SD. There is no way to select SD on Roku and videos do not play well. The transition between commercials and content often result in macroblocking for a few seconds. Browsing content is also terrible as it is very slow on the Roku app. The app itself is huge memory hog and does not stop running when you exit from it. Because of this all other apps suffer when Hulu is started.

Codec and container support on Roku is terrible. They should fire the QA department and get a new one. The only codecs they claim to support is the h264 and the WMV. That is a blatant lie. WMV is not well supported and a lot of videos do not play and worse cause Roku to lockup and reboot after watchdog is expired. Same with the container support. The mp4 container is OK. Files are recognized and played correctly most of the time, except some files produce lipsync problems which can not be fixed by transcoding. PC plays these files just fine but not Roku. The mkv container is also on the list of supported containers but this is a blatant lie as well. The files in the mkv container often cause Roku to lockup and reboot and even if the file can be played, seeking in the file causes reboots. This is my biggest problem with Roku.

Roku also claims that device supports subtitles. Technically it is true but the support is very finicky as the file must be formatted just right. VLC has no problems with the file but Roku will not play it if it is encoded in Unix format or has no empty line at the end or numbers do not start with 1 or many other reasons.

Another bad miss is absence of the parental control, as well as the inability to select applications that are loaded on the specific device under the same account. If application was removed from one device it will be removed from another linked to the same account.

Now to the general content selection. It is true that Roku has many more channels than say WDTV or a networked DVD player but most of the channels are junk, just like your cable or satellite. Hulu, Netflix, Amazon are available on most of the other devices so Roku does not get any credit here. On other devices the quality of streaming is better however. The other channels like HBOGO require subscription to the HBO on cable?! If I have a subscription to cable why would I need Roku to watch it? Private channels do add to the selection but they come and go - stop working for no reason and then start working again. Of course most of them are not getting paid but then why bother?

The user interface on the device is too simplistic and often fails to respond to the remote. I am not sure if this is app problem or in general Roku problem but with closed source system we will never know.

At the end the only app I really like is MyMedia which allows you to stream content from your PC. That app works OK and you can stream your pictures movies and music collection to the TV. It is also open source so you can modify the app or the server and add the features that you want.

Conclusion

Would I recommend Roku after a few months? Maybe, most likely not. If you want to play movies that you took with your camera or ripped from DVDs, the answer is HELL NO. If you want to watch Netflix or Hulu, the answer is maybe. I would get a networked blue-ray for that. For the same $100 you will get more functionality.
Roku is clearly used the wrong chip for their product! They should have used a chip that is capable of playing many more formats. Even the same Broadcom can supply a number of chips that are much more capable. In any event they should test the software better to make sure simply playing a file to the device would not cause a reboot!