Audio/Video drop when merging 3 FFmpeg commands which includes scale, pad, filter complex
I am trying to scale 2 videos to h=240 resolution keeping the same aspect ration. Then I am merging the audio and video of these 2 videos to form a single mp4 file. I have 3 commands in total and the final result is good.
However, I want to combine these 3 commands and get the same result in one single command. Can someone please help me in combing these commands? Thanks in advance.
First Command:
ffmpeg -i 01_v.mp4 -vf "[0]scale=-1:240[scaled_240]; [scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black" -preset ultrafast -y -r pal "1_v.mp4"
Second Command:
ffmpeg -i 02_v.mp4 -vf "[0]scale=-1:240[scaled_240]; [scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black" -preset ultrafast -y -r pal "2_v.mp4"
Third Command:
ffmpeg -i 1_a.opus -i 2_a.opus -itsoffset 0.024181 -i 1_v.mp4 -itsoffset 0.113192 -i 2_v.mp4 -filter_complex "[1:a]adelay=15726.168|15726.168[a1]; [0:a][a1]amix; [3:v]trim=0:15.726168,geq=0:128:128[silence]; [3:v]fifo[3v]; [silence][3v]concat[3_v_silence]; [2:v]fifo[2v]; [2v][3_v_silence]hstack[out_v]; [out_v]pad=width=640:height=480:x=(640-in_w)/2:y=(480-in_h)/2:color=black" -crf 40 -preset ultrafast -y -r pal "out.mp4"
I have tried to combine the above 3 commands and formed a single command. However, the result is not good with muted audio for few seconds in the middle of playback, also the 2nd video gets over few seconds earlier. Hence ending up in messing up the audio/video sync.
This is my single command which doesn't produce the desired result:
ffmpeg -i 1_a.opus -i 2_a.opus -itsoffset 0.024181 -i 01_v.webm -itsoffset 0.113192 -i 02_v.webm -filter_complex "[1:a]adelay=15726.168|15726.168[a1]; [0:a][a1]amix; [3:v]trim=0:15.726168,geq=0:128:128[silence]; [3:v]fifo[3v]; [silence][3v]concat[3_v_silence]; [2:v]scale=-1:240[2v_scaled_240]; [2v_scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black[2v_padded]; [3_v_silence]scale=-1:240[3v_scaled_240]; [3v_scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black[3v_padded]; [2v_padded]fifo[2v]; [2v][3v_padded]hstack[out_v]; [out_v]pad=width=640:height=480:x=(640-in_w)/2:y=(480-in_h)/2:color=black" -crf 40 -preset ultrafast -y -r pal out.mp4
audio video ffmpeg video-processing
add a comment |
I am trying to scale 2 videos to h=240 resolution keeping the same aspect ration. Then I am merging the audio and video of these 2 videos to form a single mp4 file. I have 3 commands in total and the final result is good.
However, I want to combine these 3 commands and get the same result in one single command. Can someone please help me in combing these commands? Thanks in advance.
First Command:
ffmpeg -i 01_v.mp4 -vf "[0]scale=-1:240[scaled_240]; [scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black" -preset ultrafast -y -r pal "1_v.mp4"
Second Command:
ffmpeg -i 02_v.mp4 -vf "[0]scale=-1:240[scaled_240]; [scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black" -preset ultrafast -y -r pal "2_v.mp4"
Third Command:
ffmpeg -i 1_a.opus -i 2_a.opus -itsoffset 0.024181 -i 1_v.mp4 -itsoffset 0.113192 -i 2_v.mp4 -filter_complex "[1:a]adelay=15726.168|15726.168[a1]; [0:a][a1]amix; [3:v]trim=0:15.726168,geq=0:128:128[silence]; [3:v]fifo[3v]; [silence][3v]concat[3_v_silence]; [2:v]fifo[2v]; [2v][3_v_silence]hstack[out_v]; [out_v]pad=width=640:height=480:x=(640-in_w)/2:y=(480-in_h)/2:color=black" -crf 40 -preset ultrafast -y -r pal "out.mp4"
I have tried to combine the above 3 commands and formed a single command. However, the result is not good with muted audio for few seconds in the middle of playback, also the 2nd video gets over few seconds earlier. Hence ending up in messing up the audio/video sync.
This is my single command which doesn't produce the desired result:
ffmpeg -i 1_a.opus -i 2_a.opus -itsoffset 0.024181 -i 01_v.webm -itsoffset 0.113192 -i 02_v.webm -filter_complex "[1:a]adelay=15726.168|15726.168[a1]; [0:a][a1]amix; [3:v]trim=0:15.726168,geq=0:128:128[silence]; [3:v]fifo[3v]; [silence][3v]concat[3_v_silence]; [2:v]scale=-1:240[2v_scaled_240]; [2v_scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black[2v_padded]; [3_v_silence]scale=-1:240[3v_scaled_240]; [3v_scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black[3v_padded]; [2v_padded]fifo[2v]; [2v][3v_padded]hstack[out_v]; [out_v]pad=width=640:height=480:x=(640-in_w)/2:y=(480-in_h)/2:color=black" -crf 40 -preset ultrafast -y -r pal out.mp4
audio video ffmpeg video-processing
add a comment |
I am trying to scale 2 videos to h=240 resolution keeping the same aspect ration. Then I am merging the audio and video of these 2 videos to form a single mp4 file. I have 3 commands in total and the final result is good.
However, I want to combine these 3 commands and get the same result in one single command. Can someone please help me in combing these commands? Thanks in advance.
First Command:
ffmpeg -i 01_v.mp4 -vf "[0]scale=-1:240[scaled_240]; [scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black" -preset ultrafast -y -r pal "1_v.mp4"
Second Command:
ffmpeg -i 02_v.mp4 -vf "[0]scale=-1:240[scaled_240]; [scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black" -preset ultrafast -y -r pal "2_v.mp4"
Third Command:
ffmpeg -i 1_a.opus -i 2_a.opus -itsoffset 0.024181 -i 1_v.mp4 -itsoffset 0.113192 -i 2_v.mp4 -filter_complex "[1:a]adelay=15726.168|15726.168[a1]; [0:a][a1]amix; [3:v]trim=0:15.726168,geq=0:128:128[silence]; [3:v]fifo[3v]; [silence][3v]concat[3_v_silence]; [2:v]fifo[2v]; [2v][3_v_silence]hstack[out_v]; [out_v]pad=width=640:height=480:x=(640-in_w)/2:y=(480-in_h)/2:color=black" -crf 40 -preset ultrafast -y -r pal "out.mp4"
I have tried to combine the above 3 commands and formed a single command. However, the result is not good with muted audio for few seconds in the middle of playback, also the 2nd video gets over few seconds earlier. Hence ending up in messing up the audio/video sync.
This is my single command which doesn't produce the desired result:
ffmpeg -i 1_a.opus -i 2_a.opus -itsoffset 0.024181 -i 01_v.webm -itsoffset 0.113192 -i 02_v.webm -filter_complex "[1:a]adelay=15726.168|15726.168[a1]; [0:a][a1]amix; [3:v]trim=0:15.726168,geq=0:128:128[silence]; [3:v]fifo[3v]; [silence][3v]concat[3_v_silence]; [2:v]scale=-1:240[2v_scaled_240]; [2v_scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black[2v_padded]; [3_v_silence]scale=-1:240[3v_scaled_240]; [3v_scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black[3v_padded]; [2v_padded]fifo[2v]; [2v][3v_padded]hstack[out_v]; [out_v]pad=width=640:height=480:x=(640-in_w)/2:y=(480-in_h)/2:color=black" -crf 40 -preset ultrafast -y -r pal out.mp4
audio video ffmpeg video-processing
I am trying to scale 2 videos to h=240 resolution keeping the same aspect ration. Then I am merging the audio and video of these 2 videos to form a single mp4 file. I have 3 commands in total and the final result is good.
However, I want to combine these 3 commands and get the same result in one single command. Can someone please help me in combing these commands? Thanks in advance.
First Command:
ffmpeg -i 01_v.mp4 -vf "[0]scale=-1:240[scaled_240]; [scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black" -preset ultrafast -y -r pal "1_v.mp4"
Second Command:
ffmpeg -i 02_v.mp4 -vf "[0]scale=-1:240[scaled_240]; [scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black" -preset ultrafast -y -r pal "2_v.mp4"
Third Command:
ffmpeg -i 1_a.opus -i 2_a.opus -itsoffset 0.024181 -i 1_v.mp4 -itsoffset 0.113192 -i 2_v.mp4 -filter_complex "[1:a]adelay=15726.168|15726.168[a1]; [0:a][a1]amix; [3:v]trim=0:15.726168,geq=0:128:128[silence]; [3:v]fifo[3v]; [silence][3v]concat[3_v_silence]; [2:v]fifo[2v]; [2v][3_v_silence]hstack[out_v]; [out_v]pad=width=640:height=480:x=(640-in_w)/2:y=(480-in_h)/2:color=black" -crf 40 -preset ultrafast -y -r pal "out.mp4"
I have tried to combine the above 3 commands and formed a single command. However, the result is not good with muted audio for few seconds in the middle of playback, also the 2nd video gets over few seconds earlier. Hence ending up in messing up the audio/video sync.
This is my single command which doesn't produce the desired result:
ffmpeg -i 1_a.opus -i 2_a.opus -itsoffset 0.024181 -i 01_v.webm -itsoffset 0.113192 -i 02_v.webm -filter_complex "[1:a]adelay=15726.168|15726.168[a1]; [0:a][a1]amix; [3:v]trim=0:15.726168,geq=0:128:128[silence]; [3:v]fifo[3v]; [silence][3v]concat[3_v_silence]; [2:v]scale=-1:240[2v_scaled_240]; [2v_scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black[2v_padded]; [3_v_silence]scale=-1:240[3v_scaled_240]; [3v_scaled_240]pad=width=320:height=240:x=(320-in_w)/2:y=(240-in_h)/2:color=black[3v_padded]; [2v_padded]fifo[2v]; [2v][3v_padded]hstack[out_v]; [out_v]pad=width=640:height=480:x=(640-in_w)/2:y=(480-in_h)/2:color=black" -crf 40 -preset ultrafast -y -r pal out.mp4
audio video ffmpeg video-processing
audio video ffmpeg video-processing
asked Nov 21 '18 at 21:51
MayankMayank
113
113
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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%2fstackoverflow.com%2fquestions%2f53420963%2faudio-video-drop-when-merging-3-ffmpeg-commands-which-includes-scale-pad-filte%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f53420963%2faudio-video-drop-when-merging-3-ffmpeg-commands-which-includes-scale-pad-filte%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