Media Transfer Protocol


The Media Transfer Protocol is an extension to the Picture Transfer Protocol communications protocol that allows media files to be transferred automatically to and from portable devices. Whereas PTP was designed for downloading photographs from digital cameras, Media Transfer Protocol allows the transfer of music files on digital audio players and media files on portable media players, as well as personal information on personal digital assistants. MTP is a key part of WMDRM10-PD, a digital rights management service for the Windows Media platform. In 2011, it became the standard method to transfer files from/to Android.
MTP is part of the "Windows Media" framework and thus closely related to Windows Media Player. Versions of the Microsoft Windows operating system from Windows XP SP2 support MTP. Windows XP requires Windows Media Player 10 or higher; later Windows versions have built-in support. Microsoft has also made available an MTP Porting Kit for older versions of Windows back to Windows 98.
The USB Implementers Forum device working group standardised MTP as a full-fledged Universal Serial Bus device class in May 2008. Since then MTP is an official extension to PTP and shares the same class code.

Overview

The main purpose of this protocol is to allow only the transfer of media files and associated metadata to and from portable devices, one transfer function, in or out, at a time. It does not support operations such as open, edit and modify. A workaround is to copy to the hosting system for these operations and then copy back.
The protocol was originally implemented for use across USB but extended for use across TCP/IP and Bluetooth. Windows Vista supports MTP over TCP/IP. Windows 7 and Windows Vista with the Platform Update for Windows Vista also support MTP over Bluetooth. The host connecting to an MTP device is called an MTP Initiator whereas the device itself is an MTP Responder.
A main reason for using MTP rather than, for example, the USB mass-storage device class is that the latter operates at the granularity of a mass storage device block, rather than at the logical file level. In other words, the USB mass storage class is designed to give a host computer undifferentiated access to bulk mass storage, such as compact flash, rather than to a file system, which might be safely shared with the target device. In practice, therefore, when a USB host computer has mounted an MSC partition, it assumes absolute control of the storage, which then may not be safely modified by the device without risk of data corruption until the host computer has severed the connection. Furthermore, because the host computer has full control over the connected storage device, there is a risk that the host computer may corrupt the file system, reformat it to a file system not supported by the USB device, or otherwise modify it in such a way that the USB device cannot completely understand it.
MTP and PTP specifically overcome this issue by making the unit of managed storage a local file rather than an entire unit of mass storage at the block level. In this way, MTP works like a transactional file system - either the entire file is written/read or nothing. The storage media is not affected by failed transfers.
Where the device maintains a database/index of the content of the disk, MTP saves the cost of re-scanning the entire disk every time the content is modified.
Additionally, the MTP allows MTP Initiators to identify the specific capabilities of device with respect to file formats and functionality. In particular, MTP Initiators may have to provide passwords and other information to unlock files, or otherwise enable digital rights management. Nothing specific of this nature is in the core standard but the features are available via vendor extensions. MTPZ, the Zune Extension to MTP specifically denies access to files until authentication has been processed, which is only possible using Windows Media Player 10 or higher.

Comparison with USB Mass Storage

MTP's advantages are marked with "" while disadvantages are marked with "".

File oriented instead of block oriented protocol

By not exposing the filesystem and metadata index, the integrity of these is in full control of the device.
Windows does not assign drive letters or UNC paths to MTP devices because it does not natively expose them as virtual file systems. Without drive letters or UNC paths, MTP-unaware software cannot access directories or files on these devices. The user has to switch to an MTP-aware application, or else work around by using an MTP-aware application such as Windows Explorer to copy or move the file to a file system that the application can access.
One specific concern is that antivirus software on the host computer may not be aware of MTP devices, making them potentially less secure than mass storage devices. Antivirus scanning might also be impractical due to blocking regular use of the device.

Drivers know a fixed set of supported devices

Despite identifiability by the PTP/MTP USB device class, libmtp documentation indicates that the vendor and product ID combination plays a functional role in identifying an MTP device, also by Windows drivers. Libmtp includes vast listings of vendor and product ID numbers of devices that it supports, along with workarounds for bugs. This non-generic methodology hinders MTP drivers' forward compatibility with new devices.

The spec knows a fixed set of defined file formats

The MTP specification includes an enumeration of file formats, called object format. The use of this enumeration is in communicating supported file formats, and formats of transferred files.
Apart from some uncategorized formats in the beginning, the list of formats is grouped in categories of image, audio, video and document formats, with each category having one "Undefined" format followed by specific formats. There is also a super-generic "Undefined object" format.
Jolla cited lack of WebM support in MTP as one reason not to support the video format in their mobile operating system Sailfish OS. It is unclear if the limitation is in the tools or the spec, other than that WebM is not defined by the MTP 1.1 spec.

Direct modification and partial transfer features

These features can be used as more efficient alternatives to whole-file transfers and re-uploads:
From the MTP 1.1 spec:
OpcodeOperation NameExplanation
0x9805GetObjectPropListMetadata transfer
0x9806SetObjectPropListMetadata transfer
0x1019MoveObjectRename a file or directory
0x101BGetPartialObjectRequest a byte range of a file

Android extensions

According to go-mtpfs:
OpcodeOperation NameExplanation
0x95C1GetPartialObject64Same as GetPartialObject, but with 64 bit offset
0x95C2SendPartialObjectSame as GetPartialObject64, but copying host to device
0x95C3TruncateObjectTruncates file to 64 bit length
0x95C4BeginEditObjectMust be called before using SendPartialObject and TruncateObject
0x95C5EndEditObjectCalled to commit changes made by SendPartialObject and TruncateObject

MTP support

Windows

MTP is supported in Windows XP if Windows Media Player 10 or later versions are installed. Windows Vista and later have MTP support built in. For older versions of Windows, specifically, Windows 2000, Windows 98 and Windows Me, Microsoft has released the MTP Porting Kit. which contains a MTP device driver. Some manufacturers, such as Creative Technology, also provide legacy MTP drivers for some of their players; these usually consist of MTP Porting Kit files with a customized INF file describing their specific players.
Windows does not assign drive letters or UNC pathnames to devices connected via MTP; instead, they only appear as named devices in MTP-aware applications such as Windows Explorer. Compared to devices that implement USB mass storage, such devices cannot be accessed programmatically by scripts or normal Windows programs that depend on drive letters or UNC paths. Instead, files must be manipulated using Windows Explorer or applications with specially written MTP support.
Under Windows, MTP-compatible devices support a feature called Auto Sync, which lets users configure Windows Media Player to automatically transfer all copied or newly acquired content to devices whenever they are connected - provided that content is compatible with Windows Media player. Auto Sync is customizable so that the player will transfer only content that meets certain criteria. Changes made to file properties on a device can be propagated back to the computer when the device is reconnected.
Copies of files accessed over MTP may remain on the host computer even after reboot, where they will be accessible to the user account which accessed them, as well as any other user accounts able to read that user account's files, including any administrative users. Windows 7's sensor platform supports sensors built into MTP-compatible devices.

Unix-like systems

A free and open-source implementation of the Media Transfer Protocol is available as libmtp. This library incorporates product and device IDs from many sources, and is commonly used in other software for MTP support.

Graphical

applications like GNOME Files and Archive Manager use GIO-based GVfs to access files on MTP devices. Proper MTP support was added to GVfs in version 1.15.2 by Philip Langdale. Early patches for GVfs to enable Google's direct I/O extensions are available.
The KDE Project develops the MTP KIO Slave with a similar level of integration as GVfs.
Not related to GNOME or KDE is the *NIX graphical MTP-capable media player, .

Virtual file system

Several tools provide a FUSE based file system for mounting MTP devices within the Unix filesystem hierarchy, making it accessible to any program that operates on files and directories. Examples include mtpfs, , and .

macOS

has built-in support for MTP but no drivers to mount MTP devices as drives. Also several third-party file transfer applications are available for Mac OS X v10.5 and later:
Later versions of several operating systems, including AmigaOS, Android, AROS, MorphOS, and Symbian OS support MTP, sometimes with additional drivers or software.
A disadvantage of MTP devices on Android as compared to USB mass storage is that although file timestamps are preserved when copying files from the Android device to one's computer, when copying in the other direction, the file modification timestamps are replaced with the time the copy was done.

Other manufacturers

Companies, including Creative Technology, Intel, iriver, and Samsung Electronics, that manufacture devices based on Microsoft's "Portable Media Center specification", have widely adopted MTP. Supporting devices were introduced at the 2004 Consumer Electronics Show.
After an initial period of uncertain reactions, several large media player producers such as Creative Technology and iriver adopted the MTP protocol in place of their own protocols.
Many devices and audio software applications support MTP.

Alternatives