<p>In one command:</p>
<pre><code>ffmpeg 
 -an -ss 00:00:00.45 -i &quot;input.mov&quot;
 -loop 1 -t 3 -i &quot;text-image.jpg&quot;
 -ss 00:05 -i 'song.wav'
 -filter_complex
 &quot;[0]setsar=1[v];[1]setsar=1[img];[v][img]concat=n=2:v=1:a=0;[2]apad&quot;
 -pix_fmt yuv420p
 -c:v libx264 -preset slow -b:v 3500k
 -c:a aac
 -shortest
 -movflags +faststart
 &quot;final-instagram.mp4&quot;
</code></pre>

CC BY-SA 4.0
2023-07-15T15:38:17.613Z
THANK YOU for your suggestion. I tried your suggested command but received an error: `Input link in1:v0 parameters (size 1370x970, SAR 1:1) do not match the corresponding output link in0:v0 parameters (1370x970, SAR 132987:133027)`
S. Imp
CC BY-SA 4.0
2023-07-15T19:49:59.770Z
Edited answer...
Gyan
CC BY-SA 4.0
2023-07-15T09:47:42.317Z
2023-07-15T19:49:51.743Z
2023-07-15T19:49:51.743Z
Gyan
<p>I've got a movie that I captured with my iphone. Let's call it <strong>input.mov</strong>. Having edited this video using my iphone, it appears to have dimensions of 1370x970, at least according to the iphone's information panel.  I also have some audio in a separate file, let's call it <strong>song.wav</strong>.</p>
<p>I want to:</p>
<p>STEP 1) extract the middle of input.mov, trimming off the first 14 frames or so (0.45 seconds) and the last few frames (not sure how many yet)</p>
<p>STEP 2) loop an image, <strong>text-image.jpg</strong> for 3 seconds and append the resulting video to the end of the trimmed output of STEP 1</p>
<p>STEP 3) extract the middle part of song.wav, let's say starting at <em>x</em> seconds and running just long enough to replace the audio of the video yielded by STEP 2. I.e., the song will be too long; I want just enough of the song to match the video's length.</p>
<p>STEP 4) output the whole resulting video in a format I can upload to instagram using a browser.</p>
<p>I've used some handy commands before, but I can't seem to combine them to get the results I want. This command works to trim off the beginning of <strong>input.mov</strong> and output an instagram-friendly result.</p>
<pre><code>ffmpeg -ss 00:00:00.45 -i &quot;input.mov&quot; -pix_fmt yuv420p -c:v libx264 -b:v 3500k -c:a aac -preset slow -movflags +faststart &quot;trimmed-instagram.mov&quot;
</code></pre>
<p>Working from that trimmed video, I try this command to loop <strong>text-image.jpg</strong> as suggested <a href="https://video.stackexchange.com/questions/17228/how-to-add-images-at-the-end-of-an-existing-movie">here</a>:</p>
<pre><code>ffmpeg -i &quot;trimmed-instagram.mov&quot; -loop 1 -t 3 -i &quot;text-image.jpg&quot; -f lavfi -t 3 -i anullsrc -filter_complex &quot;[0:v] [0:a] [1:v] [2:a] concat=n=2:v=1:a=1 [v] [a]&quot; -c:v libx264 -c:a aac -strict -2 -map &quot;[v]&quot; -map &quot;[a]&quot; with-text.mp4
</code></pre>
<p>That command always barfs with this error:</p>
<pre><code>[swscaler @ 0x564345f8a340] deprecated pixel format used, make sure you did set range correctly
[Parsed_concat_0 @ 0x56434572ee00] Input link in1:v0 parameters (size 1370x970, SAR 1:1) do not match the corresponding output link in0:v0 parameters (1370x970, SAR 9974:9977)
[Parsed_concat_0 @ 0x56434572ee00] Failed to configure output pad on Parsed_concat_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #2:0
Conversion failed!
</code></pre>
<p>NOTE that text-image.jpg is 1370x970, like input.mov.</p>
<p>I've also used this command to replace the audio for some video:</p>
<pre><code>ffmpeg -i trimmed-instagram.mov -i 'song.wav' -c:v copy -map 0:v:0 -map 1:a:0 -shortest with-audio.mov
</code></pre>
<p><em>However</em>, I need to trim off the beginning of the audio file, and when I provide an <code>-ss</code> parameter, this command trims the beginning of both the video input and the audio input:</p>
<pre><code>ffmpeg -i trimmed-instagram.mov -i 'song.wav' -ss 00:05 -c:v copy -map 0:v:0 -map 1:a:0 -shortest with-audio.mov
</code></pre>
<p>I need to specify different start/duration parameters at this point. I want <em>all</em> of trimmed-instagram.mov but want to start <em>x</em> seconds into <strong>song.wav</strong> and either go for some duration or use just enough of the song to match the video length.</p>
<p>EDIT: As suggested by @Gyan, I have tried this command:</p>
<pre><code>ffmpeg -an -ss 00:00:00.45 -i &quot;input.mov&quot; -loop 1 -t 3 -i &quot;text-image.jpg&quot; -ss 00:05 -i &quot;song.wav&quot; -filter_complex &quot;[1]setsar=1[img];[0][img]concat=n=2:v=1:a=0;[2]apad&quot; -pix_fmt yuv420p -c:v libx264 -preset slow -b:v 3500k -c:a aac -shortest -movflags +faststart &quot;final-instagram.mp4&quot;
</code></pre>
<p>However, this also results in an error:</p>
<pre><code>[swscaler @ 0x55573305b040] deprecated pixel format used, make sure you did set range correctly
[Parsed_concat_1 @ 0x55573303a880] Input link in1:v0 parameters (size 1370x970, SAR 1:1) do not match the corresponding output link in0:v0 parameters (1370x970, SAR 132987:133027)
[Parsed_concat_1 @ 0x55573303a880] Failed to configure output pad on Parsed_concat_1
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #2:0
Conversion failed!
</code></pre>

<ffmpeg><video><audio>
how to extract segment of input.mov, loop an image at the end, and then replace audio with segment of audio file?
S. Imp
# how to extract segment of input.mov, loop an image at the end, and then replace audio with segment of audio file?

(Asked by: username_0 on 2023-07-15)

I've got a movie that I captured with my iphone. Let's call it input.mov. Having edited this video using my iphone, it appears to have dimensions of 1370x970, at least according to the iphone's information panel.  I also have some audio in a separate file, let's call it song.wav.
I want to:
STEP 1) extract the middle of input.mov, trimming off the first 14 frames or so (0.45 seconds) and the last few frames (not sure how many yet)
STEP 2) loop an image, text-image.jpg for 3 seconds and append the resulting video to the end of the trimmed output of STEP 1
STEP 3) extract the middle part of song.wav, let's say starting at x seconds and running just long enough to replace the audio of the video yielded by STEP 2. I.e., the song will be too long; I want just enough of the song to match the video's length.
STEP 4) output the whole resulting video in a format I can upload to instagram using a browser.
I've used some handy commands before, but I can't seem to combine them to get the results I want. This command works to trim off the beginning of input.mov and output an instagram-friendly result.
ffmpeg -ss 00:00:00.45 -i "input.mov" -pix_fmt yuv420p -c:v libx264 -b:v 3500k -c:a aac -preset slow -movflags +faststart "trimmed-instagram.mov"

Working from that trimmed video, I try this command to loop text-image.jpg as suggested here:
ffmpeg -i "trimmed-instagram.mov" -loop 1 -t 3 -i "text-image.jpg" -f lavfi -t 3 -i anullsrc -filter_complex "[0:v] [0:a] [1:v] [2:a] concat=n=2:v=1:a=1 [v] [a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" with-text.mp4

That command always barfs with this error:
[swscaler @ 0x564345f8a340] deprecated pixel format used, make sure you did set range correctly
[Parsed_concat_0 @ 0x56434572ee00] Input link in1:v0 parameters (size 1370x970, SAR 1:1) do not match the corresponding output link in0:v0 parameters (1370x970, SAR 9974:9977)
[Parsed_concat_0 @ 0x56434572ee00] Failed to configure output pad on Parsed_concat_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #2:0
Conversion failed!

NOTE that text-image.jpg is 1370x970, like input.mov.
I've also used this command to replace the audio for some video:
ffmpeg -i trimmed-instagram.mov -i 'song.wav' -c:v copy -map 0:v:0 -map 1:a:0 -shortest with-audio.mov

However, I need to trim off the beginning of the audio file, and when I provide an -ss parameter, this command trims the beginning of both the video input and the audio input:
ffmpeg -i trimmed-instagram.mov -i 'song.wav' -ss 00:05 -c:v copy -map 0:v:0 -map 1:a:0 -shortest with-audio.mov

I need to specify different start/duration parameters at this point. I want all of trimmed-instagram.mov but want to start x seconds into song.wav and either go for some duration or use just enough of the song to match the video length.
EDIT: As suggested by @username_1, I have tried this command:
ffmpeg -an -ss 00:00:00.45 -i "input.mov" -loop 1 -t 3 -i "text-image.jpg" -ss 00:05 -i "song.wav" -filter_complex "[1]setsar=1[img];[0][img]concat=n=2:v=1:a=0;[2]apad" -pix_fmt yuv420p -c:v libx264 -preset slow -b:v 3500k -c:a aac -shortest -movflags +faststart "final-instagram.mp4"

However, this also results in an error:
[swscaler @ 0x55573305b040] deprecated pixel format used, make sure you did set range correctly
[Parsed_concat_1 @ 0x55573303a880] Input link in1:v0 parameters (size 1370x970, SAR 1:1) do not match the corresponding output link in0:v0 parameters (1370x970, SAR 132987:133027)
[Parsed_concat_1 @ 0x55573303a880] Failed to configure output pad on Parsed_concat_1
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #2:0
Conversion failed!

**Tags:** ffmpeg, video, audio


---

## 1 answers

### Answer by username_1 on 2023-07-15. Score: 1

In one command:
ffmpeg 
 -an -ss 00:00:00.45 -i "input.mov"
 -loop 1 -t 3 -i "text-image.jpg"
 -ss 00:05 -i 'song.wav'
 -filter_complex
 "[0]setsar=1[v];[1]setsar=1[img];[v][img]concat=n=2:v=1:a=0;[2]apad"
 -pix_fmt yuv420p
 -c:v libx264 -preset slow -b:v 3500k
 -c:a aac
 -shortest
 -movflags +faststart
 "final-instagram.mp4"

> **Comments:**
> **username_0**: THANK YOU for your suggestion. I tried your suggested command but received an error: `Input link in1:v0 parameters (size 1370x970, SAR 1:1) do not match the corresponding output link in0:v0 parameters (1370x970, SAR 132987:133027)`  
> **username_1**: Edited answer...  

---

