Is there a way to tell ffmpeg “encode file A with format settings of file B?”
I know I could use ffprobe and then parse the text file to get the codec info of file B, but is there a simpler way?
Goal: I want to append a few seconds of silence to hundreds of audio files (who have different bitrates and encodings) without reencoding, because I would like to have a few seconds of silence between tracks when playing a playlist. Since there is no audio player on Android that offers this functionality (to my knowledge), I'm considering incorporating the silence within the files themselves.
audio ffmpeg batch concatenation lossless
add a comment |
I know I could use ffprobe and then parse the text file to get the codec info of file B, but is there a simpler way?
Goal: I want to append a few seconds of silence to hundreds of audio files (who have different bitrates and encodings) without reencoding, because I would like to have a few seconds of silence between tracks when playing a playlist. Since there is no audio player on Android that offers this functionality (to my knowledge), I'm considering incorporating the silence within the files themselves.
audio ffmpeg batch concatenation lossless
3
Your question unfortunately exhibits the XY problem. Your actual problem is finding an Android player that offers gaps between tracks, or how to play music on Android with gaps in between. Doing what you think is the solution with ffmpeg is not really possible. I would recommend to ask on Android Enthusiasts about the Android issue.
– slhck
Dec 23 '18 at 17:24
1
It definitely IS possible to use ffprobe to read out the codec and bitrate of an audio file, pipe it into a text file, parse it and then encode my 11-sec audio file of silence with the same codec and bitrate. Then just join them.
– Mia Lon
Dec 23 '18 at 20:34
I was merely wondering if there was an easier way. I'm pretty sure that there is no Android player with that functionality, and even if there was, it would only work there. Chances are I would not want to use it for lack of other functions. The only nice player so far is the integrated player of TotalCommander. All other fail in very basic functionality like ignoring MP3 tags, quickly creating playlists or editing them. It's either very cumbersome or flat out impossible.
– Mia Lon
Dec 23 '18 at 20:51
If you encoded silence with the same format, how exactly did you combine that with the original track? But yes, that's the only possible way to achieve that, as ffmpeg does not have a functionality like the one you've asked for.
– slhck
Dec 23 '18 at 22:55
Sure it does: (trac.ffmpeg.org/wiki/Concatenate)
– Mia Lon
Dec 29 '18 at 20:14
add a comment |
I know I could use ffprobe and then parse the text file to get the codec info of file B, but is there a simpler way?
Goal: I want to append a few seconds of silence to hundreds of audio files (who have different bitrates and encodings) without reencoding, because I would like to have a few seconds of silence between tracks when playing a playlist. Since there is no audio player on Android that offers this functionality (to my knowledge), I'm considering incorporating the silence within the files themselves.
audio ffmpeg batch concatenation lossless
I know I could use ffprobe and then parse the text file to get the codec info of file B, but is there a simpler way?
Goal: I want to append a few seconds of silence to hundreds of audio files (who have different bitrates and encodings) without reencoding, because I would like to have a few seconds of silence between tracks when playing a playlist. Since there is no audio player on Android that offers this functionality (to my knowledge), I'm considering incorporating the silence within the files themselves.
audio ffmpeg batch concatenation lossless
audio ffmpeg batch concatenation lossless
asked Dec 23 '18 at 16:37
Mia LonMia Lon
1
1
3
Your question unfortunately exhibits the XY problem. Your actual problem is finding an Android player that offers gaps between tracks, or how to play music on Android with gaps in between. Doing what you think is the solution with ffmpeg is not really possible. I would recommend to ask on Android Enthusiasts about the Android issue.
– slhck
Dec 23 '18 at 17:24
1
It definitely IS possible to use ffprobe to read out the codec and bitrate of an audio file, pipe it into a text file, parse it and then encode my 11-sec audio file of silence with the same codec and bitrate. Then just join them.
– Mia Lon
Dec 23 '18 at 20:34
I was merely wondering if there was an easier way. I'm pretty sure that there is no Android player with that functionality, and even if there was, it would only work there. Chances are I would not want to use it for lack of other functions. The only nice player so far is the integrated player of TotalCommander. All other fail in very basic functionality like ignoring MP3 tags, quickly creating playlists or editing them. It's either very cumbersome or flat out impossible.
– Mia Lon
Dec 23 '18 at 20:51
If you encoded silence with the same format, how exactly did you combine that with the original track? But yes, that's the only possible way to achieve that, as ffmpeg does not have a functionality like the one you've asked for.
– slhck
Dec 23 '18 at 22:55
Sure it does: (trac.ffmpeg.org/wiki/Concatenate)
– Mia Lon
Dec 29 '18 at 20:14
add a comment |
3
Your question unfortunately exhibits the XY problem. Your actual problem is finding an Android player that offers gaps between tracks, or how to play music on Android with gaps in between. Doing what you think is the solution with ffmpeg is not really possible. I would recommend to ask on Android Enthusiasts about the Android issue.
– slhck
Dec 23 '18 at 17:24
1
It definitely IS possible to use ffprobe to read out the codec and bitrate of an audio file, pipe it into a text file, parse it and then encode my 11-sec audio file of silence with the same codec and bitrate. Then just join them.
– Mia Lon
Dec 23 '18 at 20:34
I was merely wondering if there was an easier way. I'm pretty sure that there is no Android player with that functionality, and even if there was, it would only work there. Chances are I would not want to use it for lack of other functions. The only nice player so far is the integrated player of TotalCommander. All other fail in very basic functionality like ignoring MP3 tags, quickly creating playlists or editing them. It's either very cumbersome or flat out impossible.
– Mia Lon
Dec 23 '18 at 20:51
If you encoded silence with the same format, how exactly did you combine that with the original track? But yes, that's the only possible way to achieve that, as ffmpeg does not have a functionality like the one you've asked for.
– slhck
Dec 23 '18 at 22:55
Sure it does: (trac.ffmpeg.org/wiki/Concatenate)
– Mia Lon
Dec 29 '18 at 20:14
3
3
Your question unfortunately exhibits the XY problem. Your actual problem is finding an Android player that offers gaps between tracks, or how to play music on Android with gaps in between. Doing what you think is the solution with ffmpeg is not really possible. I would recommend to ask on Android Enthusiasts about the Android issue.
– slhck
Dec 23 '18 at 17:24
Your question unfortunately exhibits the XY problem. Your actual problem is finding an Android player that offers gaps between tracks, or how to play music on Android with gaps in between. Doing what you think is the solution with ffmpeg is not really possible. I would recommend to ask on Android Enthusiasts about the Android issue.
– slhck
Dec 23 '18 at 17:24
1
1
It definitely IS possible to use ffprobe to read out the codec and bitrate of an audio file, pipe it into a text file, parse it and then encode my 11-sec audio file of silence with the same codec and bitrate. Then just join them.
– Mia Lon
Dec 23 '18 at 20:34
It definitely IS possible to use ffprobe to read out the codec and bitrate of an audio file, pipe it into a text file, parse it and then encode my 11-sec audio file of silence with the same codec and bitrate. Then just join them.
– Mia Lon
Dec 23 '18 at 20:34
I was merely wondering if there was an easier way. I'm pretty sure that there is no Android player with that functionality, and even if there was, it would only work there. Chances are I would not want to use it for lack of other functions. The only nice player so far is the integrated player of TotalCommander. All other fail in very basic functionality like ignoring MP3 tags, quickly creating playlists or editing them. It's either very cumbersome or flat out impossible.
– Mia Lon
Dec 23 '18 at 20:51
I was merely wondering if there was an easier way. I'm pretty sure that there is no Android player with that functionality, and even if there was, it would only work there. Chances are I would not want to use it for lack of other functions. The only nice player so far is the integrated player of TotalCommander. All other fail in very basic functionality like ignoring MP3 tags, quickly creating playlists or editing them. It's either very cumbersome or flat out impossible.
– Mia Lon
Dec 23 '18 at 20:51
If you encoded silence with the same format, how exactly did you combine that with the original track? But yes, that's the only possible way to achieve that, as ffmpeg does not have a functionality like the one you've asked for.
– slhck
Dec 23 '18 at 22:55
If you encoded silence with the same format, how exactly did you combine that with the original track? But yes, that's the only possible way to achieve that, as ffmpeg does not have a functionality like the one you've asked for.
– slhck
Dec 23 '18 at 22:55
Sure it does: (trac.ffmpeg.org/wiki/Concatenate)
– Mia Lon
Dec 29 '18 at 20:14
Sure it does: (trac.ffmpeg.org/wiki/Concatenate)
– Mia Lon
Dec 29 '18 at 20:14
add a comment |
1 Answer
1
active
oldest
votes
To answer your literal question, no, ffmpeg cannot determine the input codec and bitrate and apply the same settings to the output file.
There are several reasons why it wouldn't be easy to implement:
- You'd have to determine the output encoder based on the input codec. You can't always know which encoder was used for the original file, so selecting the exact same encoder will not be possible in all cases.
- Choosing the same input bitrate might lead to generation loss, so the user should select an appropriate bitrate or quality level for the output themselves.
- Keeping sample rate and number of audio channels (or pixel formats, frame rate for video) is usually supported, but there are edge cases where, for example, an input may have a 5.1 audio stream, but the only audio encoder that ffmpeg can choose only supports stereo audio encoding.
- There are lots of combinations of input/output codecs with file formats, where you can't guarantee that a given input combination can be written to an output file.
That said, for a limited use case such as yours, a simple script that parses file information (e.g., with mediainfo or ffprobe) and translates that into ffmpeg settings would work.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1387155%2fis-there-a-way-to-tell-ffmpeg-encode-file-a-with-format-settings-of-file-b%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To answer your literal question, no, ffmpeg cannot determine the input codec and bitrate and apply the same settings to the output file.
There are several reasons why it wouldn't be easy to implement:
- You'd have to determine the output encoder based on the input codec. You can't always know which encoder was used for the original file, so selecting the exact same encoder will not be possible in all cases.
- Choosing the same input bitrate might lead to generation loss, so the user should select an appropriate bitrate or quality level for the output themselves.
- Keeping sample rate and number of audio channels (or pixel formats, frame rate for video) is usually supported, but there are edge cases where, for example, an input may have a 5.1 audio stream, but the only audio encoder that ffmpeg can choose only supports stereo audio encoding.
- There are lots of combinations of input/output codecs with file formats, where you can't guarantee that a given input combination can be written to an output file.
That said, for a limited use case such as yours, a simple script that parses file information (e.g., with mediainfo or ffprobe) and translates that into ffmpeg settings would work.
add a comment |
To answer your literal question, no, ffmpeg cannot determine the input codec and bitrate and apply the same settings to the output file.
There are several reasons why it wouldn't be easy to implement:
- You'd have to determine the output encoder based on the input codec. You can't always know which encoder was used for the original file, so selecting the exact same encoder will not be possible in all cases.
- Choosing the same input bitrate might lead to generation loss, so the user should select an appropriate bitrate or quality level for the output themselves.
- Keeping sample rate and number of audio channels (or pixel formats, frame rate for video) is usually supported, but there are edge cases where, for example, an input may have a 5.1 audio stream, but the only audio encoder that ffmpeg can choose only supports stereo audio encoding.
- There are lots of combinations of input/output codecs with file formats, where you can't guarantee that a given input combination can be written to an output file.
That said, for a limited use case such as yours, a simple script that parses file information (e.g., with mediainfo or ffprobe) and translates that into ffmpeg settings would work.
add a comment |
To answer your literal question, no, ffmpeg cannot determine the input codec and bitrate and apply the same settings to the output file.
There are several reasons why it wouldn't be easy to implement:
- You'd have to determine the output encoder based on the input codec. You can't always know which encoder was used for the original file, so selecting the exact same encoder will not be possible in all cases.
- Choosing the same input bitrate might lead to generation loss, so the user should select an appropriate bitrate or quality level for the output themselves.
- Keeping sample rate and number of audio channels (or pixel formats, frame rate for video) is usually supported, but there are edge cases where, for example, an input may have a 5.1 audio stream, but the only audio encoder that ffmpeg can choose only supports stereo audio encoding.
- There are lots of combinations of input/output codecs with file formats, where you can't guarantee that a given input combination can be written to an output file.
That said, for a limited use case such as yours, a simple script that parses file information (e.g., with mediainfo or ffprobe) and translates that into ffmpeg settings would work.
To answer your literal question, no, ffmpeg cannot determine the input codec and bitrate and apply the same settings to the output file.
There are several reasons why it wouldn't be easy to implement:
- You'd have to determine the output encoder based on the input codec. You can't always know which encoder was used for the original file, so selecting the exact same encoder will not be possible in all cases.
- Choosing the same input bitrate might lead to generation loss, so the user should select an appropriate bitrate or quality level for the output themselves.
- Keeping sample rate and number of audio channels (or pixel formats, frame rate for video) is usually supported, but there are edge cases where, for example, an input may have a 5.1 audio stream, but the only audio encoder that ffmpeg can choose only supports stereo audio encoding.
- There are lots of combinations of input/output codecs with file formats, where you can't guarantee that a given input combination can be written to an output file.
That said, for a limited use case such as yours, a simple script that parses file information (e.g., with mediainfo or ffprobe) and translates that into ffmpeg settings would work.
answered Dec 30 '18 at 11:26
slhckslhck
160k47444466
160k47444466
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1387155%2fis-there-a-way-to-tell-ffmpeg-encode-file-a-with-format-settings-of-file-b%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
3
Your question unfortunately exhibits the XY problem. Your actual problem is finding an Android player that offers gaps between tracks, or how to play music on Android with gaps in between. Doing what you think is the solution with ffmpeg is not really possible. I would recommend to ask on Android Enthusiasts about the Android issue.
– slhck
Dec 23 '18 at 17:24
1
It definitely IS possible to use ffprobe to read out the codec and bitrate of an audio file, pipe it into a text file, parse it and then encode my 11-sec audio file of silence with the same codec and bitrate. Then just join them.
– Mia Lon
Dec 23 '18 at 20:34
I was merely wondering if there was an easier way. I'm pretty sure that there is no Android player with that functionality, and even if there was, it would only work there. Chances are I would not want to use it for lack of other functions. The only nice player so far is the integrated player of TotalCommander. All other fail in very basic functionality like ignoring MP3 tags, quickly creating playlists or editing them. It's either very cumbersome or flat out impossible.
– Mia Lon
Dec 23 '18 at 20:51
If you encoded silence with the same format, how exactly did you combine that with the original track? But yes, that's the only possible way to achieve that, as ffmpeg does not have a functionality like the one you've asked for.
– slhck
Dec 23 '18 at 22:55
Sure it does: (trac.ffmpeg.org/wiki/Concatenate)
– Mia Lon
Dec 29 '18 at 20:14