Coding for Mobile Platforms

Random thoughts, sometimes relevant to mobile programming.

  • Mobile Coder

  • Subscribe to Mobile Coder and receive notifications of new posts by email.

    Join 183 other followers

Play mkv, avi, flv and wmv files on webOS Touchpad

Posted by error454 on 08/26/2011


This article is no longer maintained, please see TouchPlayer Documentation.

One thing the touchpad clearly lacks is the number of supported video formats available. Out of the box, the mp4 container with h.264 codec is pretty much it.  If all of your videos are in this format already, you can benefit from the hardware acceleration that the stock video player provides for this codec.

If you want to play any other format, you have a few options:

  1. Convert your existing media to mp4 h.264 with an app like Handbrake. Leave it running overnight to take advantage of spare CPU cycles.
  2. Run a media server like Playon that transcodes media on the fly.  You need a reasonably fast cpu to do this (atom powered servers do not apply) as you are converting and serving the video real-time.
  3. Get a new video player for your touchpad.

This article is going to explore the 3rd option in more detail.

Presenting TouchPlayer

I have taken the FFmpeg project, thrown a crappy wrapper on it and compiled it for the Touchpad.  If you aren’t familiar with FFmpeg, the library that comes from it (libavcodec) powers mplayer and vlc.  You can find my app in Preware, it is called TouchPlayer.

TouchPlayer Limitations

Update 10/16/2011

1.0.4 is now available.

Update 10/14/2011

First off, let me say that if you are looking to play MKV files, you should really check out KalemSoft Media Player.  I use it, it’s fast, it’s beautiful etc.

There are limitations with KalemSoft though, such as reading files from an NFS/CIFS/SSHFS mounted filesystem.  Also, no subtitles.

I have abandoned the ffplay version of this project in favor of mplayer.  Progress is steady, you can read progress updates if you’d like.  An update has not yet been pushed, the mplayer version is all or nothing, meaning if I released it as-is there would be no controls.

Update 9/23/2011

It’s possible that I don’t know what I’m talking about below.  KalemSoft media player can play most of my HD MKV files quite well.  The big difference here is that they seem to draw to the screen using openGL rather than SDL.  This may not be the only factor but I’m sure it is a large factor.

As ffplay is something of a dead-end, I am now working on replacing it with mplayer.  There are a couple reasons, first there is already an openGL ES patch for mplayer from either WOSI or Chomper (hard to track the attribution for the patch).  Also, mplayer has an OSD and a GUI with several skins available.

The project is building but I haven’t had the time to test it on the Touchpad.  You can find the source on my github page if you are eager.

Old Content

TouchPlayer cannot play 720P mkv videos with AC3 audio at 30 fps.  It never will unless the Touchpad gets more hardware accelerated codecs. Who knows, maybe it will someday.

Keep in mind that every video played in TouchPlayer gets decoded by the CPU.  Decoding 720p with multi-channel audio on the CPU is too big of a task for any tablet.  If your primary goal is to play unmodified mkv files then you may want to consider new goals. Using NEON, it is possible to do, all on the CPU.

If you insist though, I have provided a switch to disable audio and increase thread count to take advantage of both CPU cores.  If you do have any level of success with playing hd videos, please let me know.

Also if you are an expert in the FFmpeg ecosystem and know of some parameters that might give a boost, please pass them along.

Source for the modified FFmpeg is here:
https://github.com/error454/FFmpeg

Source for TouchPlayer is here:
https://github.com/error454/TouchPlayer

Precentral Forum on TouchPlayer:
http://forums.precentral.net/webos-homebrew-apps/293654-touchplayer.html

Direct link:
http://t.co/gnKEkkt

About these ads

55 Responses to “Play mkv, avi, flv and wmv files on webOS Touchpad”

  1. wubo said

    As a hearing impaired person, subtitles are a must have. I’ve been using Handbrake to reencode and burn in subs and touchplayer plays them smoothly. Thanks for your work!

  2. Josh said

    Hey dude, great job on this! I was able to download and install onto touchpad. I added a few avi files to see what would happen and it does recognize them in the internal media section, however it doesn’t actually play anything. I can select the file but that is it. Same for the wallpaper folder. I can select the jpeg but it doesn’t actually open it. Am I doing something wrong? Sorry for the lame questions I am not the best at this stuff, I just read stuff by smart people like you and try to follow directions.

    • error454 said

      As I responded via email, this is due to not having the homebrew javascript framework installed or not doing a luna restart after installing.

  3. kyle said

    hi error454,
    Could you share some knowledge of how to compile ffmpeg and touchplayer for x86 emulator and touchpad?
    I am in processing to learn webos programming.

    Thanks,

  4. Aweb said

    First, I’d like to thank you a lot for this player which sounds awesome. I’ll be sure to try it as soon as my Touchpad is delivered !

    As a French, I like to watch US movies in english with english subtitles, will you application support them ?

    Thank you and best regards !

  5. Ollo said

    Have you enabled NEON support during the build of ffmepg? This may speed up things a lot.

  6. Wes said

    I was wondering what flags you used with ffmpeg to compile it? I know from android development that there’s a few that will help to optimize things like –enable-neon

    http://androidcore.com/android-programming-tutorials/641-how-to-compile-ffmpeg-on-android.html

    I know these guys make an ffmpeg based player for android and modified the source ffmpeg source some to make it work better on mobile platforms. Perhaps it will be useful for the touchpad as well.

    • error454 said

      See my reply to the last comment regarding compile flags. Thanks for the links, I’ll see if they contain any more performance items to apply to the Touchpad version!

  7. Wes said

    Missed the second link somehow. Here it is: http://www.anplayer.com/tech_en.html

  8. UncleSteven said

    A wrapper for “MPlayer” and the KalemSofr Media Player exist for webOS 2.x, but I like having different options. Can your app be made compatible with Pre 2 devices? (I admit having already installed and attempted using it, but it wouldn’t start.)

    • error454 said

      The UI is written in Enyo, so it isn’t going to run on the Pre2. The underlying service would run on the Pre2, someone just needs to write a UI. You could open up a terminal, browse to the touchplayer service folder and run ffplay /media/internal/yourmedia to play whatever you want.

  9. James said

    Hi Error 454,

    Just wondering if you are thinking about adding play/pause features (or any other on screen controls) to your app?!
    Good job so far, its the only app that will let me to stream my avi videos (after mounting shares).

    Thanks, keep up the good work.

    James

  10. Tony said

    This is excellent work and I thank you for making my touchpad usable for video!!!

    I wondered if mplayer would allow GPU acceleration if we compiled it for touchpad?
    I thought most hd videos are in an h264 variant so would the option to use the touchpad’s GFX be possible with a different player behind the interface?

    Thank you again for this work, My touchpad is no longer crying out for Android!

    • error454 said

      Thanks Tony. To be honest, I am pretty new to the world of video hacking. After spending several weeks on this, here is what I *think* is correct – I am happy to be proven wrong because it would mean hardware acceleration on the TP:
      To do GPU acceleration on the Touchpad, we would need hardware accelerated codecs to be written for the Qualcomm Adreno 220. Palm has written one for h.264 that their native app uses but it is closed source.

      Acceleration in mplayer works because mplayer supports APIs like VDPAU and vA API – these APIs depend on you having an Nvidia or Intel graphics card respectively. The video library that TouchPlayer uses is the same that mplayer uses, those hardware acceleration options are there they just don’t do us any good :(

  11. danny said

    I want to thank you for getting this project started. Good work!

  12. jin said

    great job man, btw touchplayer still has the limitaiton movies greater than 1gb files, is it webos limitation? also waiting for the newer version of touchplayer with the control bar

  13. bengarang said

    I’m having trouble getting movies to play, they all show up with a weird rainbow effect… I took a screenshot: http://tinypic.com/r/118o9qc/7
    I tried a variety of formats, lengths and bitrates, all of which have the same effect. Audio seems to work fine. Reinstalled several times with no luck. :( Any suggestions?

    Also wanted to say thank you for making your software available for free, that is awesome and greatly appreciated.

  14. CookieMonster said

    I might be mistaken but I thought all the video is decoded by the Neon chip which is what hardware decode is. For software decode we use the CPU. Hardware acceleration is using the GPU.

    to summarize:

    Hardware decode=Neon
    Software decode=CPU
    Hardware acceleration =GPU

    So while hardware decode is ideal as it offers the highest performance ratio and battery, it does not rule out hardware acceleration. Then again it may be a lot of work..

    Alteratively, I heard samsung plans to release the Samsung Hercules with the 1.2ghz Qualcomm processor and Samsung is usually good at providing large number of codec support so maybe it can be taken from there….

    Also last thing, I don’t even think that the snapdragon has a Neon, I think it uses its own SIMD + VFP which recognizes Neon instructions

    • error454 said

      NEON is a SIMD extension for ARM. It definitely helps decode video but not for free. The compiler still doesn’t generate very good NEON instructions by itself, to take advantage of the instructions you need to code your loops by hand so you can take advantage of NEON. Whether or not they do this in the matroska codec, I don’t know.

      The cpuinfo of the touchpad does claim NEON support and I have compiled TouchPlayer to use it:
      Features : swp half thumb fastmult vfp edsp neon vfpv3

      • CookieMonster said

        The Snapdragon isn’t even an ARM processor, it just accepts ARM instructions and they build around it. Otherwise unlike other Cortex based CPUs Snapdragons are created from scratch. And yes it does support Neon instructions.

        And yes it isn’t free, on my SGS when I do software decode it uses up full 1ghz to run, on hardware decode it stays at 400mhz for 720p video at high bitrate.

        Also, if I am not mistaken matroska is a container, not a codec.

        I also have a Tegra 2 tablet running honeycomb port (no drivers) and at 1.5ghz overclocked and using software decode it can play 720p ok..so theoretically I don’t see why a tablet that can overclock to 1.9ghz can’t handle it via software decode too..unless we are being bottle-necked by the slow ram..(Snapdragon is single channel 233mhz while tegra 2 is 600mhz single channel)

      • error454 said

        Yes, thank you, matroska is most definitely a container and *not* a codec.

  15. Grobux said

    Hi Error454,

    First of all, thank you so much for your work, TouchPlayer is a must-have on Touchpad!

    I’m looking to use it to read RTSP streams, but my tests aren’t successful…
    I developed an application to try to play streams with the TouchPlayer service.

    FFMPEG supports RTSP streams, so I’m looking forward a solution.
    I managed to do the following:
    - view a local video file from my app,
    - view a remote file via UPnP (custom patch of an UPnP client available on the App Catalog).

    I tried the same thing as Kyle (comment #2), to see if I could have more informations in the debug’s logs.
    But as you said, TouchPlayer didn’t start on WebOS emulator.
    On my Touchpad, nothing happens, and I didn’t managed to get debugging on it.

    Have you tried to read streams (RTSP or other) with TouchPlayer?
    Do you think it’s possible?

    • Grobux said

      Hi,

      I managed to get it work from a stream generated on my computer.
      It’s not very fluent, and sometimes the picture freezes. I will try some switches (I already use -fast), and other video sources (but my test video runs very well with TouchPlayer).

      Now I’m looking to get a remote stream (outside my LAN).
      I think my problem come from the stream’s URL, wich contains parameters (something like rtsp://exemple.com/stream?channel=1).
      According to the docs on your Github, URL parameters are used to set some options for FFplay.

      I keep looking. If you think about a solution, let me know. ;-)

  16. Any way to make this discover upnp media servers so that we can easily access our media residing on servers (i.e. windows home server)?

    • error454 said

      About the best I can do is allow you to type in url’s that point to upnp shared media. I would encourage the upnp app authors to use the service calls that I’m exposing in the next release.

      • Hi,

        Nice work with Touchplayer.

        I’m the dev who makes upnp av player and am interested in your service calls.
        Have you got any details.

        Thanks
        Richard

      • error454 said

        When I post the next release, I will publish full details on the available service calls that I’ve recently implemented.

      • Grobux said

        Hi everyone,

        Richard, with the current Touchplayer release, you can try the following code.

        Add the Touchplayer service:

        {name: "runTouchplayer", kind: "PalmService", service: "palm://com.wordpress.mobilecoder.touchplayer.service", method: "play"}

        To run Touchplayer:

        this.$.runTouchplayer.call({source: this.convertUrl(VIDEO_URL), switches: "-fast"});

        Replace VIDEO_URL by the good URL (“item.res” for example).

        Hope this will help making those two great applications more essentials.
        Looking forward to seeing the new version of Touchplayer.

  17. Ed en Vadrouille said

    Thanks for the putting this up! This is the one thing i was still using my android phone for (but 4 inches screens are not really fun).
    I’d love having controls on the screen and subtitle support! But it’s already quite cool the way it is!

  18. Just VIsitting said

    The kalemsoft media player also uses the same FFMPEG base, but with shared libraries from somewhere.
    libavcodec.so.53 / libavformat.so.53, etc.
    Could touchplayer use these libraries (as per the FFMPEG license) and would that result in better performance than the static compilation?

    • error454 said

      Touchplayer currently uses the same library. I believe the performance differential is due to how things are being drawn to the screen. Touchplayer (ffplay) uses SDL where Kalemsoft uses openGL. I am looking at switching out ffplay for mplayer to get openGL output, subtitle support and hopefully down the line enable their OSD/GUI.

  19. Olive said

    Hi,

    Mplayer for the Touchpad will be a dream come true !
    Thank you so much for undertaking this project as there is currently no solution for watching movies with subtitles.
    If you put a ‘Donate’ button somewhere, I will gladly make a small donation to encourage you.

    By the way have you thought about contacting the author from http://code.google.com/p/mplayer-webos/ to get some help ?

    • error454 said

      Thanks, I have contacted the original author of the patch. I’m not quite ready to handle a donate button, it would just make me feel guilty for not working on things as often as I want to ;)

  20. boltronics said

    This project looks sweet – thanks Error454 for giving it a crack! Kalemsoft doesn’t support subtitles, and I watch a lot of fansubbed anime and need them. I’d prefer a free software product anyway, so may setup a scratchbox environment over the weekend to take a proper look.

  21. Chris R. said

    Okay, stupid question. I’m trying to play an .avi file, but when I click on it, nothing happens. The file is highlighted, but it doesn’t play. What am I missing? How do I play this video?

  22. NEWEXPLORER said

    Just Start yesterday the set up of my new touchpad.. First install Preware and overclock
    to 1.5 Ghz with kernel for touchpad and Govnah, then try to install Touchpad player new version and it request install also 2 more packages wich aparently install good, but the download of touchpad aparently good then when begin installation of touchpad nothing happened it continued and continued 20 minutes or more and nothing only freeze installation, no lunarstart, nothing… I have to close the windows and restart the device but then, only appear two more apps of preware but the third and what I need Touchpad nothing… Can not install … I update to 3.0.2 and every thing is working fine… Have I missed something or need fo install another packages from Preware for beging installation? Do you have a Guide step by step…
    THANK YOU IN ADVANCED!

  23. NEWEXPLORER said

    THANK YOU SO MUCH! WONDERFULL APP…. WORKING AMAZING! PROBLEM FIXED! Just read more in your page and find fhe Solution… Add in Manage Feed: URL: mobilecoder.touchpadhp.info/mcfeed and dowload and install quickly… CONTINUED WITH THE GOOD WORK… I am an Apple fan…Have 3 Ipads,3 iphone, 1 ipod and a Mac Book Air… Newbie for Webos… But find this OS fascinating… Another Good Way In The Road !!!

  24. Thanks for such a great app and the hard work. Just one question, and I’m not sure if this has been answered somewhere else. I’m just a casual user, but can I import my itunes purchases and watch? When I try, it just highlights and doesn’t start, however it works on all of my other videos.

    Thanks again!

    • error454 said

      I have never tried, are they .mov format? it is ppssible that there isnt codec support there.

      • I can’t tell you about the codec support. I’m not that tech savy, just know how to use my equipment. As far as I can tell itunes movies are .mk4. And I’m sure it’s all down to the DRM that Apple puts on everything.

  25. Diego said

    Hi! First of all, great app! Every new touchpad owner should download this app as soon as possible, heck, this app should come bundled with the original OS!

    So, yeah, I think this application is great, but, I’m having some issues with spanish subtitles, as foreign characters (non english) seem to not be supported.. do you know any way I could fix this?

    Thanks.

    • Diego said

      ok, I downloaded the font pack for 8859-1 and overwrote the 8859-7 folder. It worked fine!

    • error454 said

      You would need to install a font pack that has the correct character set that you desire, another commenter here was successful in doing so. I’m not really interested in elaborating too much more here because then folks will ask more questions ;) The font situation should fix itself once I get TTF font support working.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 183 other followers

%d bloggers like this: