How to use ffmpeg to join MP3s and copy the metadata at the same time?











up vote
0
down vote

favorite












Various pages on the Internet talk about how to use ffmpeg to join MP3s and copy the tags, but I cannot seem to get it to work properly. Ideally, what would happen is that it would join all the MP3s together, then take the first MP3's metadata, such as album, track, author, etc. and copy it to the final file.



I've put together the following script. While it joins the files, it does not copy the metadata. I thought the -map_metadata 0 -id3v2_version 3 -write_id3v1 1 parameters to ffmpeg would do it, but it doesn't. What am I missing?



#!/usr/bin/env bash

set -e
if [[ $# -eq 0 ]] ; then
echo "Usage: $0 <output_file> <mp3_file> <mp3_file> ..."
exit 1
fi
output_file="$1"
shift

queue_file=$(mktemp "${PWD}/queue.XXXXXX")
for m in "$@" ; do
echo "file '$m'" >> "${queue_file}"
done

cat "${queue_file}"
ffmpeg -f concat -safe 0 -i "${queue_file}" -c copy -map_metadata 0 -id3v2_version 3 -write_id3v1 1 "${output_file}"
rm "${queue_file}"









share|improve this question






















  • Ingest the first file only as a 2nd input i.e. -i "${queue_file}" -i "first_file" and and use -map_metadata 1.
    – Gyan
    Nov 29 at 6:17










  • @Gyan Would this end up getting the first file to be copied to the output file twice?
    – Roxy
    Nov 29 at 15:36










  • No, there are no stream maps, so ffmpeg will pick one of the inputs, and since the stream properties are the same, it'll pick the first one.
    – Gyan
    Nov 29 at 15:59















up vote
0
down vote

favorite












Various pages on the Internet talk about how to use ffmpeg to join MP3s and copy the tags, but I cannot seem to get it to work properly. Ideally, what would happen is that it would join all the MP3s together, then take the first MP3's metadata, such as album, track, author, etc. and copy it to the final file.



I've put together the following script. While it joins the files, it does not copy the metadata. I thought the -map_metadata 0 -id3v2_version 3 -write_id3v1 1 parameters to ffmpeg would do it, but it doesn't. What am I missing?



#!/usr/bin/env bash

set -e
if [[ $# -eq 0 ]] ; then
echo "Usage: $0 <output_file> <mp3_file> <mp3_file> ..."
exit 1
fi
output_file="$1"
shift

queue_file=$(mktemp "${PWD}/queue.XXXXXX")
for m in "$@" ; do
echo "file '$m'" >> "${queue_file}"
done

cat "${queue_file}"
ffmpeg -f concat -safe 0 -i "${queue_file}" -c copy -map_metadata 0 -id3v2_version 3 -write_id3v1 1 "${output_file}"
rm "${queue_file}"









share|improve this question






















  • Ingest the first file only as a 2nd input i.e. -i "${queue_file}" -i "first_file" and and use -map_metadata 1.
    – Gyan
    Nov 29 at 6:17










  • @Gyan Would this end up getting the first file to be copied to the output file twice?
    – Roxy
    Nov 29 at 15:36










  • No, there are no stream maps, so ffmpeg will pick one of the inputs, and since the stream properties are the same, it'll pick the first one.
    – Gyan
    Nov 29 at 15:59













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Various pages on the Internet talk about how to use ffmpeg to join MP3s and copy the tags, but I cannot seem to get it to work properly. Ideally, what would happen is that it would join all the MP3s together, then take the first MP3's metadata, such as album, track, author, etc. and copy it to the final file.



I've put together the following script. While it joins the files, it does not copy the metadata. I thought the -map_metadata 0 -id3v2_version 3 -write_id3v1 1 parameters to ffmpeg would do it, but it doesn't. What am I missing?



#!/usr/bin/env bash

set -e
if [[ $# -eq 0 ]] ; then
echo "Usage: $0 <output_file> <mp3_file> <mp3_file> ..."
exit 1
fi
output_file="$1"
shift

queue_file=$(mktemp "${PWD}/queue.XXXXXX")
for m in "$@" ; do
echo "file '$m'" >> "${queue_file}"
done

cat "${queue_file}"
ffmpeg -f concat -safe 0 -i "${queue_file}" -c copy -map_metadata 0 -id3v2_version 3 -write_id3v1 1 "${output_file}"
rm "${queue_file}"









share|improve this question













Various pages on the Internet talk about how to use ffmpeg to join MP3s and copy the tags, but I cannot seem to get it to work properly. Ideally, what would happen is that it would join all the MP3s together, then take the first MP3's metadata, such as album, track, author, etc. and copy it to the final file.



I've put together the following script. While it joins the files, it does not copy the metadata. I thought the -map_metadata 0 -id3v2_version 3 -write_id3v1 1 parameters to ffmpeg would do it, but it doesn't. What am I missing?



#!/usr/bin/env bash

set -e
if [[ $# -eq 0 ]] ; then
echo "Usage: $0 <output_file> <mp3_file> <mp3_file> ..."
exit 1
fi
output_file="$1"
shift

queue_file=$(mktemp "${PWD}/queue.XXXXXX")
for m in "$@" ; do
echo "file '$m'" >> "${queue_file}"
done

cat "${queue_file}"
ffmpeg -f concat -safe 0 -i "${queue_file}" -c copy -map_metadata 0 -id3v2_version 3 -write_id3v1 1 "${output_file}"
rm "${queue_file}"






ffmpeg mp3 metadata






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 29 at 1:59









Roxy

1517




1517












  • Ingest the first file only as a 2nd input i.e. -i "${queue_file}" -i "first_file" and and use -map_metadata 1.
    – Gyan
    Nov 29 at 6:17










  • @Gyan Would this end up getting the first file to be copied to the output file twice?
    – Roxy
    Nov 29 at 15:36










  • No, there are no stream maps, so ffmpeg will pick one of the inputs, and since the stream properties are the same, it'll pick the first one.
    – Gyan
    Nov 29 at 15:59


















  • Ingest the first file only as a 2nd input i.e. -i "${queue_file}" -i "first_file" and and use -map_metadata 1.
    – Gyan
    Nov 29 at 6:17










  • @Gyan Would this end up getting the first file to be copied to the output file twice?
    – Roxy
    Nov 29 at 15:36










  • No, there are no stream maps, so ffmpeg will pick one of the inputs, and since the stream properties are the same, it'll pick the first one.
    – Gyan
    Nov 29 at 15:59
















Ingest the first file only as a 2nd input i.e. -i "${queue_file}" -i "first_file" and and use -map_metadata 1.
– Gyan
Nov 29 at 6:17




Ingest the first file only as a 2nd input i.e. -i "${queue_file}" -i "first_file" and and use -map_metadata 1.
– Gyan
Nov 29 at 6:17












@Gyan Would this end up getting the first file to be copied to the output file twice?
– Roxy
Nov 29 at 15:36




@Gyan Would this end up getting the first file to be copied to the output file twice?
– Roxy
Nov 29 at 15:36












No, there are no stream maps, so ffmpeg will pick one of the inputs, and since the stream properties are the same, it'll pick the first one.
– Gyan
Nov 29 at 15:59




No, there are no stream maps, so ffmpeg will pick one of the inputs, and since the stream properties are the same, it'll pick the first one.
– Gyan
Nov 29 at 15:59















active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379259%2fhow-to-use-ffmpeg-to-join-mp3s-and-copy-the-metadata-at-the-same-time%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379259%2fhow-to-use-ffmpeg-to-join-mp3s-and-copy-the-metadata-at-the-same-time%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Сан-Квентин

8-я гвардейская общевойсковая армия

Алькесар