create a looped audio of a certain part of audio using ffmpeg
How can we create a looped audio with ffmpeg from an audio file
the command used for a looped audio is
ffmpeg -lavfi "amovie=audio.wav:loop=3" out.wav
but this creates a looped file of the whole audio, not a part of it
how ever I want is
If the audio file is of a duration of 4 mins 30 sec, I want to get part from 2 min 25 sec to 3 min 55 sec, of the audio and loop it
how can we do this
audio ffmpeg
add a comment |
How can we create a looped audio with ffmpeg from an audio file
the command used for a looped audio is
ffmpeg -lavfi "amovie=audio.wav:loop=3" out.wav
but this creates a looped file of the whole audio, not a part of it
how ever I want is
If the audio file is of a duration of 4 mins 30 sec, I want to get part from 2 min 25 sec to 3 min 55 sec, of the audio and loop it
how can we do this
audio ffmpeg
@Mawg I left a pointer to the solution, but I cannot test an answer, because it would include audio, and in my current context I cannot listen to the output to verify that it's correct. Hence, no answer, just a comment. Any comment I may leave regarding moderation and policy is completely independent of the technical question.
– slhck
Jan 8 at 13:57
The OP (and future readers) got help. That's what we are here for.
– Mawg
Jan 8 at 14:38
add a comment |
How can we create a looped audio with ffmpeg from an audio file
the command used for a looped audio is
ffmpeg -lavfi "amovie=audio.wav:loop=3" out.wav
but this creates a looped file of the whole audio, not a part of it
how ever I want is
If the audio file is of a duration of 4 mins 30 sec, I want to get part from 2 min 25 sec to 3 min 55 sec, of the audio and loop it
how can we do this
audio ffmpeg
How can we create a looped audio with ffmpeg from an audio file
the command used for a looped audio is
ffmpeg -lavfi "amovie=audio.wav:loop=3" out.wav
but this creates a looped file of the whole audio, not a part of it
how ever I want is
If the audio file is of a duration of 4 mins 30 sec, I want to get part from 2 min 25 sec to 3 min 55 sec, of the audio and loop it
how can we do this
audio ffmpeg
audio ffmpeg
asked Jan 8 at 6:38
12345671234567
1204
1204
@Mawg I left a pointer to the solution, but I cannot test an answer, because it would include audio, and in my current context I cannot listen to the output to verify that it's correct. Hence, no answer, just a comment. Any comment I may leave regarding moderation and policy is completely independent of the technical question.
– slhck
Jan 8 at 13:57
The OP (and future readers) got help. That's what we are here for.
– Mawg
Jan 8 at 14:38
add a comment |
@Mawg I left a pointer to the solution, but I cannot test an answer, because it would include audio, and in my current context I cannot listen to the output to verify that it's correct. Hence, no answer, just a comment. Any comment I may leave regarding moderation and policy is completely independent of the technical question.
– slhck
Jan 8 at 13:57
The OP (and future readers) got help. That's what we are here for.
– Mawg
Jan 8 at 14:38
@Mawg I left a pointer to the solution, but I cannot test an answer, because it would include audio, and in my current context I cannot listen to the output to verify that it's correct. Hence, no answer, just a comment. Any comment I may leave regarding moderation and policy is completely independent of the technical question.
– slhck
Jan 8 at 13:57
@Mawg I left a pointer to the solution, but I cannot test an answer, because it would include audio, and in my current context I cannot listen to the output to verify that it's correct. Hence, no answer, just a comment. Any comment I may leave regarding moderation and policy is completely independent of the technical question.
– slhck
Jan 8 at 13:57
The OP (and future readers) got help. That's what we are here for.
– Mawg
Jan 8 at 14:38
The OP (and future readers) got help. That's what we are here for.
– Mawg
Jan 8 at 14:38
add a comment |
1 Answer
1
active
oldest
votes
Option 1 — Trimming and looping
You can use the atrim
filter to first trim your input to the required part, then use the aloop
filter to loop that section.
ffmpeg -i input.m4a
-filter_complex "
[0:a]
atrim=0:3,asetpts=PTS-STARTPTS,
asetrate=48000,aloop=2:size=3*48000
[outa]"
-map "[outa]"
-c:a aac
out.m4a
In the above example, note the following settings:
- the input is cut from 0 to 3 seconds with
atrim
- the audio is looped 3⨉ (
aloop=2
) - the size of the loop is set with
size=3*48000
- the audio codec is AAC with the default quality options (
-c:a aac
)
If you want a different duration, e.g. from 5 to 10 seconds, change atrim=5:10
, and change size=5*48000
.
Unfortunately, the aloop
filter requires setting the size of the looped portion in samples—in our case, that's 3 seconds ⨉ 48,000 samples. Since you don't know the input sample rate, you have to set it to 48,000 Hz first with the asetrate
filter.
If there's an easier way, I'd be glad to know about it, but unfortunately the amovie
input source does not allow trimming on the fly.
Option 2 — Looping, then stopping
An alternative might be:
ffmpeg -ss 0 -i input.m4a
-filter_complex "
[0:a]asetrate=48000,aloop=1:size=3*48000[outa]"
-map "[outa]"
-t 6
-c:a aac
out.m4a
Here, the input is not trimmed; it's just the loop size that determines the length of the loop. But then you have to specify the total output duration (i.e, 6 seconds) with -t
. If you want a different offset, use ffmpeg -ss <timestamp> -i input.m4a
, where <timestamp>
is the seek point.
thanks for the reply can you look at another of my question which is based on loop and trim concept of ffmpeg superuser.com/questions/1391908/…
– 1234567
Jan 8 at 14:46
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%2f1391777%2fcreate-a-looped-audio-of-a-certain-part-of-audio-using-ffmpeg%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
Option 1 — Trimming and looping
You can use the atrim
filter to first trim your input to the required part, then use the aloop
filter to loop that section.
ffmpeg -i input.m4a
-filter_complex "
[0:a]
atrim=0:3,asetpts=PTS-STARTPTS,
asetrate=48000,aloop=2:size=3*48000
[outa]"
-map "[outa]"
-c:a aac
out.m4a
In the above example, note the following settings:
- the input is cut from 0 to 3 seconds with
atrim
- the audio is looped 3⨉ (
aloop=2
) - the size of the loop is set with
size=3*48000
- the audio codec is AAC with the default quality options (
-c:a aac
)
If you want a different duration, e.g. from 5 to 10 seconds, change atrim=5:10
, and change size=5*48000
.
Unfortunately, the aloop
filter requires setting the size of the looped portion in samples—in our case, that's 3 seconds ⨉ 48,000 samples. Since you don't know the input sample rate, you have to set it to 48,000 Hz first with the asetrate
filter.
If there's an easier way, I'd be glad to know about it, but unfortunately the amovie
input source does not allow trimming on the fly.
Option 2 — Looping, then stopping
An alternative might be:
ffmpeg -ss 0 -i input.m4a
-filter_complex "
[0:a]asetrate=48000,aloop=1:size=3*48000[outa]"
-map "[outa]"
-t 6
-c:a aac
out.m4a
Here, the input is not trimmed; it's just the loop size that determines the length of the loop. But then you have to specify the total output duration (i.e, 6 seconds) with -t
. If you want a different offset, use ffmpeg -ss <timestamp> -i input.m4a
, where <timestamp>
is the seek point.
thanks for the reply can you look at another of my question which is based on loop and trim concept of ffmpeg superuser.com/questions/1391908/…
– 1234567
Jan 8 at 14:46
add a comment |
Option 1 — Trimming and looping
You can use the atrim
filter to first trim your input to the required part, then use the aloop
filter to loop that section.
ffmpeg -i input.m4a
-filter_complex "
[0:a]
atrim=0:3,asetpts=PTS-STARTPTS,
asetrate=48000,aloop=2:size=3*48000
[outa]"
-map "[outa]"
-c:a aac
out.m4a
In the above example, note the following settings:
- the input is cut from 0 to 3 seconds with
atrim
- the audio is looped 3⨉ (
aloop=2
) - the size of the loop is set with
size=3*48000
- the audio codec is AAC with the default quality options (
-c:a aac
)
If you want a different duration, e.g. from 5 to 10 seconds, change atrim=5:10
, and change size=5*48000
.
Unfortunately, the aloop
filter requires setting the size of the looped portion in samples—in our case, that's 3 seconds ⨉ 48,000 samples. Since you don't know the input sample rate, you have to set it to 48,000 Hz first with the asetrate
filter.
If there's an easier way, I'd be glad to know about it, but unfortunately the amovie
input source does not allow trimming on the fly.
Option 2 — Looping, then stopping
An alternative might be:
ffmpeg -ss 0 -i input.m4a
-filter_complex "
[0:a]asetrate=48000,aloop=1:size=3*48000[outa]"
-map "[outa]"
-t 6
-c:a aac
out.m4a
Here, the input is not trimmed; it's just the loop size that determines the length of the loop. But then you have to specify the total output duration (i.e, 6 seconds) with -t
. If you want a different offset, use ffmpeg -ss <timestamp> -i input.m4a
, where <timestamp>
is the seek point.
thanks for the reply can you look at another of my question which is based on loop and trim concept of ffmpeg superuser.com/questions/1391908/…
– 1234567
Jan 8 at 14:46
add a comment |
Option 1 — Trimming and looping
You can use the atrim
filter to first trim your input to the required part, then use the aloop
filter to loop that section.
ffmpeg -i input.m4a
-filter_complex "
[0:a]
atrim=0:3,asetpts=PTS-STARTPTS,
asetrate=48000,aloop=2:size=3*48000
[outa]"
-map "[outa]"
-c:a aac
out.m4a
In the above example, note the following settings:
- the input is cut from 0 to 3 seconds with
atrim
- the audio is looped 3⨉ (
aloop=2
) - the size of the loop is set with
size=3*48000
- the audio codec is AAC with the default quality options (
-c:a aac
)
If you want a different duration, e.g. from 5 to 10 seconds, change atrim=5:10
, and change size=5*48000
.
Unfortunately, the aloop
filter requires setting the size of the looped portion in samples—in our case, that's 3 seconds ⨉ 48,000 samples. Since you don't know the input sample rate, you have to set it to 48,000 Hz first with the asetrate
filter.
If there's an easier way, I'd be glad to know about it, but unfortunately the amovie
input source does not allow trimming on the fly.
Option 2 — Looping, then stopping
An alternative might be:
ffmpeg -ss 0 -i input.m4a
-filter_complex "
[0:a]asetrate=48000,aloop=1:size=3*48000[outa]"
-map "[outa]"
-t 6
-c:a aac
out.m4a
Here, the input is not trimmed; it's just the loop size that determines the length of the loop. But then you have to specify the total output duration (i.e, 6 seconds) with -t
. If you want a different offset, use ffmpeg -ss <timestamp> -i input.m4a
, where <timestamp>
is the seek point.
Option 1 — Trimming and looping
You can use the atrim
filter to first trim your input to the required part, then use the aloop
filter to loop that section.
ffmpeg -i input.m4a
-filter_complex "
[0:a]
atrim=0:3,asetpts=PTS-STARTPTS,
asetrate=48000,aloop=2:size=3*48000
[outa]"
-map "[outa]"
-c:a aac
out.m4a
In the above example, note the following settings:
- the input is cut from 0 to 3 seconds with
atrim
- the audio is looped 3⨉ (
aloop=2
) - the size of the loop is set with
size=3*48000
- the audio codec is AAC with the default quality options (
-c:a aac
)
If you want a different duration, e.g. from 5 to 10 seconds, change atrim=5:10
, and change size=5*48000
.
Unfortunately, the aloop
filter requires setting the size of the looped portion in samples—in our case, that's 3 seconds ⨉ 48,000 samples. Since you don't know the input sample rate, you have to set it to 48,000 Hz first with the asetrate
filter.
If there's an easier way, I'd be glad to know about it, but unfortunately the amovie
input source does not allow trimming on the fly.
Option 2 — Looping, then stopping
An alternative might be:
ffmpeg -ss 0 -i input.m4a
-filter_complex "
[0:a]asetrate=48000,aloop=1:size=3*48000[outa]"
-map "[outa]"
-t 6
-c:a aac
out.m4a
Here, the input is not trimmed; it's just the loop size that determines the length of the loop. But then you have to specify the total output duration (i.e, 6 seconds) with -t
. If you want a different offset, use ffmpeg -ss <timestamp> -i input.m4a
, where <timestamp>
is the seek point.
edited Jan 8 at 14:29
answered Jan 8 at 14:24
slhckslhck
160k47444466
160k47444466
thanks for the reply can you look at another of my question which is based on loop and trim concept of ffmpeg superuser.com/questions/1391908/…
– 1234567
Jan 8 at 14:46
add a comment |
thanks for the reply can you look at another of my question which is based on loop and trim concept of ffmpeg superuser.com/questions/1391908/…
– 1234567
Jan 8 at 14:46
thanks for the reply can you look at another of my question which is based on loop and trim concept of ffmpeg superuser.com/questions/1391908/…
– 1234567
Jan 8 at 14:46
thanks for the reply can you look at another of my question which is based on loop and trim concept of ffmpeg superuser.com/questions/1391908/…
– 1234567
Jan 8 at 14:46
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%2f1391777%2fcreate-a-looped-audio-of-a-certain-part-of-audio-using-ffmpeg%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
@Mawg I left a pointer to the solution, but I cannot test an answer, because it would include audio, and in my current context I cannot listen to the output to verify that it's correct. Hence, no answer, just a comment. Any comment I may leave regarding moderation and policy is completely independent of the technical question.
– slhck
Jan 8 at 13:57
The OP (and future readers) got help. That's what we are here for.
– Mawg
Jan 8 at 14:38