Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: March 2, 2025
FFmpeg is a free, open-source software suite primarily used for converting, streaming, and editing multimedia files. It supports almost all known video and audio formats and offers numerous functionalities, including metadata editing. Whether we want to modify the title of a video, adjust the artist’s name in an audio track, or remove unwanted metadata, FFmpeg provides us with the right commands to do so.
In this tutorial, we’ll explore how to modify media metadata using FFmpeg, from basic metadata changes to more advanced editing techniques. We’ll also discuss the potential uses for metadata editing, including how it can enhance file organization, improve compatibility with media players, or make files more searchable.
Metadata plays a crucial role in organizing, managing, and sharing digital content effectively. When manipulating, editing, or removing such metadata, FFmpeg stands out as a powerful and versatile tool that can handle various types of media files, including audio, video, and even image formats.
Metadata is information about data. It refers to the additional information embedded within a media file that describes aspects of the content itself, such as the title, artist, album, genre, resolution, codec details, and much more.
For example, if we take a typical MP3 file, the metadata might include the song title, artist name, album name, genre, track number, and year. For a video file like MP4, the metadata could include the video resolution, audio codec (such as AAC), and the duration of the video:
$ ffmpeg -i Onedropreggae.mp3 -hide_banner
Input #0, mp3, from 'Onedropreggae.mp3':
Metadata:
encoder : Lavf60.3.100
title : ONE DROP REGGAE RIDDIMS MIX DJ FRANCOL,TARRUS RILEY,J BOOG,CHRIS MARTIN,BUSY SIGNAL,ALAINE Etc
artist : DJ FRANCOL
TLEN : 3644000
album : DJ FRANCOL
Duration: 01:00:44.11, start: 0.011021, bitrate: 160 kb/s
Stream #0:0: Audio: mp3 (mp3float), 48000 Hz, stereo, fltp, 160 kb/s
Metadata:
encoder : Lavc60.3.
Stream #0:1: Video: png, rgb24(pc, gbr/bt709/iec61966-2-1), 640x720, 90k tbr, 90k tbn (attached pic)
Metadata:
title : attached picture
comment : Cover (front)
FFmpeg is equipped with the ability to view, edit, and delete metadata from audio, video, and other media files. By default, FFmpeg provides tools to either read or write metadata tags to files without needing to extract the media content itself. This means we can perform metadata operations very efficiently without re-encoding the media content, saving time and preserving the quality of the media.
FFmpeg interacts with metadata in several ways, allowing us to:
Also, it has various options and libraries that we can either enable or disable when we’re compiling an input. Let’s view these options by running ffmpeg without the -hide_banner option:
The simplest way to modify metadata using FFmpeg is by specifying the -metadata option followed by the key-value pair of the metadata we wish to change. For example, let’s change the title and artist of an audio file:
$ ffmpeg -i Onedropreggae.mp3 -metadata title="One_Drop_reggae_1" -metadata artist="Test user 1" -codec copy Onedropreggae_new.mp3 -hide_banner
In this command:
Let’s look at the metadata of our newly created file, with some information changed from the original:
$ ffmpeg -i Onedropreggae_new.mp3 -hide_banner
Input #0, mp3, from 'Onedropreggae_new.mp3':
Metadata:
artist : Test user 1
album : DJ FRANCOL
title : One_Drop_reggae_1
TLEN : 3644000
encoder : Lavf61.7.100
Duration: 01:00:44.11, start: 0.011021, bitrate: 160 kb/s
Stream #0:0: Audio: mp3 (mp3float), 48000 Hz, stereo, fltp, 160 kb/s
Metadata:
encoder : Lavc60.3.
This is the basic usage, but as we’ll see, FFmpeg allows for more intricate and advanced modifications.
Once we grasp the basics of modifying metadata, we can move on to more advanced features of FFmpeg, which allow us to work with metadata in greater detail and tailor our operations to specific needs.
Sometimes, we need to delete all metadata tags. This is particularly useful when we want to reduce file size or ensure privacy by removing sensitive information. To remove all tags, we use the following command:
$ ffmpeg -i test.jpg -map_metadata -1 -codec copy output_test.jpg
Here:
If we check the file we’ve produced, all the metadata has been erased:
$ ffmpeg -i output_test.jpg -hide_banner
Input #0, image2, from 'output_test.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 708938 kb/s
Stream #0:0: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 4564x5705 [SAR 72:72 DAR 4:5], 25 fps, 25 tbr, 25 tbn
If we only want to remove specific tags, we can do so by targeting them individually. For instance, let’s see how to remove only the title tag from the metadata:
$ ffmpeg -i input.mp4 -metadata title="" -codec copy output.mp4
This command leaves the rest of the metadata intact while removing the title tag.
FFmpeg also allows us to add multiple metadata tags simultaneously. When we’re working with both video and audio files and we need to add detailed information for both streams, this feature comes in handy.
For example, apart from adding only the title and artist, we can also add other tags like the genre or description:
$ ffmpeg -i input.mp4 -metadata title="Test Video" -metadata artist="Artist RVT" -metadata genre="Comedy" -metadata description="A hilarious skit" -codec copy output.mp4
This will add four metadata tags to the output.mp4 file.
To edit the metadata of a file before making changes, we can use the ffmpeg -i command followed by the file name. FFmpeg will display a summary of both technical and metadata information. Let’s look at an example:
$ ffmpeg -i input.mp3 -map_metadata 0 -id3v2_version 3 -metadata title="New Title" -metadata artist="New Artist" -codec copy input.mp3
By inspecting the metadata in this way, we can decide which tags need to be modified or removed.
Further, we can edit metadata without having to create new files. To achieve this, we use the -update option. This allows us to overwrite the input file:
$ ffmpeg -i test.jpg -metadata title="Single SHot 1" -metadata artist="Test user 1" -codec copy test.jpg -hide_banner -update 1
Trailing option(s) found in the command: may be ignored.
Input #0, image2, from 'test.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 708938 kb/s
Stream #0:0: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 4564x5705 [SAR 72:72 DAR 4:5], 25 fps, 25 tbr, 25 tbn
File 'test.jpg' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Output #0, image2, to 'test.jpg':
Metadata:
title : Single SHot 1
artist : Test user 1
encoder : Lavf61.7.100
Stream #0:0: Video: mjpeg (Progressive), yuvj420p(pc, bt470bg/unknown/unknown), 4564x5705 [SAR 72:72 DAR 4:5], q=2-31, 25 fps, 25 tbr, 25 tbn
In some cases, we may want to transfer the metadata from one media file to another, especially when converting formats. FFmpeg allows us to copy metadata from the input file to the output file without altering it. Here’s an example where we convert an MP3 to an MP4 file while keeping the metadata:
$ ffmpeg -i input.mp3 -i input_video.mp4 -map 0 -map_metadata 0 -codec copy output.mp4
Let’s break down the command options and arguments from the above example:
The output.mp4 file will contain the video from input_video.mp4 and the metadata from input.mp3. This is useful for creating multimedia files that preserve all the original metadata from various sources.
Metadata often includes more detailed information about video files, such as frame rate, resolution, and codec. While end users don’t typically modify these technical details, they can still be adjusted if needed.
For instance, if we want to change the title and resolution metadata of a video, we can run:
$ ffmpeg -i input.mp4 -metadata title="New Title" -metadata resolution="1920x1080" -codec copy output.mp4
Aside from the title tag, we’ve added a resolution tag. The resolution tag will not change the actual video resolution but will serve as additional metadata describing the video.
Metadata plays a crucial role in organizing, managing, and sharing digital content effectively. When manipulating, editing, or removing metadata, we can enhance the overall functionality and usability of our files.
When we’re editing metadata, we can improve file organization by adding descriptive tags, categories, or custom fields, making it easier to locate specific content across various systems. This becomes important when handling large collections of digital media, as well-organized metadata allows for quicker sorting and retrieval.
Additionally, editing metadata can significantly enhance compatibility with media players and software applications. For example, adjusting the metadata for audio or video files ensures that media players can correctly display relevant information like artist names, track titles, album art, and resolution details, which improves the user experience.
Moreover, editing metadata can increase the discoverability of files through improved search functionality. Files with rich, accurate metadata are more easily indexed by search engines or file management systems, leading to faster and more precise searches.
Whether for a digital archive, personal collection, or shared content, these enhancements make files more accessible and manageable, streamlining workflows and increasing productivity across multiple platforms.
In this tutorial, we’ve looked at how FFmpeg is a versatile and powerful tool for working with multimedia files, with its ability to modify media metadata being one of its many strengths. Whether we’re simply editing basic tags like title and artist in an audio file or managing more complex video-specific metadata, FFmpeg offers the flexibility to meet our needs.
Further, we’ve covered the basics of modifying metadata with FFmpeg, including advanced techniques such as removing or copying metadata while working with both audio and video files. The ability to manipulate metadata allows us to keep our media organized, share files with the correct information, and optimize content for various platforms.
By mastering FFmpeg’s metadata editing commands, we open up a wide range of possibilities for managing and customizing our media library, whether it’s for personal use, professional projects, or content distribution. Lastly, Linux offers us other alternatives like the exiftool for editing metadata.