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
-
OSJH and LPI Release 2024 Open Source Pros Job Survey Results
See what open source professionals look for in a new role.
-
Proton 9.0-1 Released to Improve Gaming with Steam
The latest release of Proton 9 adds several improvements and fixes an issue that has been problematic for Linux users.
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
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.