Getting your MTP devices working on Linux
Fusing MTP
Remember I mentioned earlier that libmtp is just a C library for programmers to make their applications talk to your MTP device? One such application is MTPfs, which is a FUSE file system that will mount an MTP device and allow you to write files onto the device in a much more familiar fashion.
If you look in your distro's repository, you will not find MTPfs. The only way to obtain it is to grab the source tarball off the website [3] and install it:
$ tar xvf mtpfs-0.9.tar.gz -C /tmp $ cd /tmp/mtpfs-0.9 $ ./configure $ make $ su -c "make install" OR $ sudo make install
Once it is installed, create a mount point:
$ sudo mkdir /media/jogpod
Now you can plug in the device, wait for it to settle down, and the mount it with mtpfs:
$ mtpfs /media/jogpod
In the mounted directory, you'll see the folders for Images, Music, Videos, etc. as they exist on your device. With the cp command, you can copy files to the appropriate directory, and with the rm command, you can delete files. Alternatively, you could use your desktop's file manager, but Nautilus crashed on me several times when I tried to copy files.
In the mounted device, you'll also notice a Playlists directory that contains all the playlists. To make your own playlist, use your favorite text editor to create a file that lists the name of the tracks you want in it, one per line. Then save this file with a .m3u extension and copy it over to the Playlists directory. I would suggest creating the file outside the mount point and then copying it into the mounted player.
When you're done, unmount the device with fusermount -u /media/jogpod.
MTP Meets Zune
Thanks to a .NET-speaking buddy, I was able to get my hands on a first-generation Microsoft Zune player. You would assume that because Microsoft promotes MTP so actively, you'd have no trouble working with Zune on Linux, but you would be wrong.
To begin with, the Zune uses the MTPZ protocol, which is a ZUNE-specific extension to MTP. Before any copy operation, MPTZ sends an encrypted challenge to the computer, which must respond by decrypting the challenge message with a key and sending a proper reply. To add this functionality in libmtp, the developers need authentication and a signed certificate from Microsoft to authenticate, which they don't have.
So any attempts to copy files to the Zune player will throw ACCESS DENIED errors. In fact, all you can do is list the files on the Zune and delete them. And you thought that just because you paid for the device, you could use it anyway you wanted to!
Converting Videos for MTP Devices
Many media devices also play videos. But unlike music files, you can't just copy any video files onto your MTP player. To get them to play properly, the videos have to be transcoded into the proper format and resolution with the use of tools such as FFmpeg, Mencoder, or Handbrake.
To transcode videos for your device, refer to the vendor documentation and jot down the limitations you're working with in terms of video resolution, aspect ratio, video and audio bit rate, sampling rate, and number of channels, as well as the video container and codec supported by your device.
Some device vendors try to throw you off balance with their own custom format, such as Samsung and its Samsung Audio Video Interleaving (SVI) format, which is nothing but their own AVI container format. You can use the SVIcoder [7] tool to transcode videos for playback on Samsung devices.
MTP Support in Music Players
In addition to the command-line tools discussed in this article, a couple of popular music players on the Linux desktop support MTP devices: Amarok for KDE users and RhythmBox for Gnome. Both RhythmBox and Amarok include code from libmtp, so just make sure you grab the most recent version from your distro's repositories.
To get your MTP devices to work on RhythmBox, you will have to activate the MTP plugin. First go to Edit | Plugins, which will open the Configure Plugins dialog box (Figure 1). Next, scroll down the list of plugins to find and enable the Portable Player – MTP plugin. Now connect the device, and RhythmBox will pick it up.
Similarly, with Amarok, you need to activate support for MTP devices. To do so, head over to Settings | Configure Amarok | Media Device (Figure 2). You'll have to add your device manually with the Add Device option, which involves selecting the MTP plugin from a pull-down list and entering a name for the device. After adding the device, return to the main interface and click on the Devices tab. There, select MTP Media Device from the pull-down list and click on the Connect button.
Once your device is listed, you can drag and drop files into the player and play music from it.
A few other applications support MTP devices. For example, if you have one of the Creative Nomad players, you can transfer music onto it with Gnomad2 [4], which also is written by one of the libmtp developers. The Banshee and Audacious music players will talk with MTP devices as well.
If you are a developer and want to write your own app for communicating with MTP devices, you can use either the original libmtp library written in C, the Ruby wrapper [5], or the Python wrapper [6].
Conclusion
Although an MTP device might not behave like a simple mass storage device at first glance, thanks to the developers of libmtp, you will hardly notice any differences when you use MTP devices on Linux.
Infos
- libmtp Project: http://libmtp.sourceforge.net/
- Download libmtp: http://libmtp.sourceforge.net/download.php
- MTPfs FUSE filesystem for reading MTP devices: http://www.adebenham.com/mtpfs/
- Gnomad2 for several players from Creative and Dell: http://gnomad2.sourceforge.net/
- Ruby wrapper for libmtp: http://rubyforge.org/projects/libmtp/
- Python wrapper for libmtp: http://launchpad.net/pylibmtp
- SVIcoder: http://svicoder.sourceforge.net/
« Previous 1 2
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.