0

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 @Gyan, 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!

1 Answer 1

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"
2
  • 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
    Commented Jul 15, 2023 at 15:38
  • Edited answer...
    – Gyan
    Commented Jul 15, 2023 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.