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
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.