2

I want to concatenate 5 seconds of blank/black video to the end of different videos I download from net. The process I have for doing this is not working.

First I use ffprobe to the dimensions of the video (let's say it turns out to be 640x480). Then I create my blank video as so:

ffmpeg -f lavfi -i color=color=black -t 5 -s 640x480 blank.mp4

The resultant video, blank.mp4, plays back as a 5 second blank video as expected.

Then I concatenate the videos as so:

ffmpeg -i random.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts a.ts
ffmpeg -i blank.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts b.ts
ffmpeg -i concat:a.ts|b.ts -c copy -bsf:a aac_adtstoasc final.mp4

Now, it is worth noting: I have cribbed this together with snippets from all over the web / stackoverflow, and am pretty sure it is not right. In fact, I know it is not right because...

The resultant video, final.mp4, seems almost right. But during playback, once the playhead enters the end of the video into the 5 seconds of black, the video can then no longer seek to earlier in the video successfully. Instead the video remains black (although I can hear the audio).

Suggestions? I am looking for a general solution that will work with various mp4 files I find on the net. Thank you!


helpful, but requires creating a large blank video with a longer duration than the source video... https://stackoverflow.com/a/36786271/62255

1 Answer 1

2

Use

ffmpeg -i random.mp4 -f lavfi -i color=s=640x480:d=5 -filter_complex [0:v][1]concat -af [0]apad -shortest out.mp4
7
  • no matches found: [0:v][1]concat
    – jedierikb
    Commented Nov 28, 2016 at 5:33
  • Show the full console output.
    – Gyan
    Commented Nov 28, 2016 at 5:40
  • Alas, that is the full console output.
    – jedierikb
    Commented Nov 28, 2016 at 5:44
  • & if I've your attention and good grace, how would I add blank audio as well? (which I've since discovered is needed for concat with other videos to ensure synced audio and video)?
    – jedierikb
    Commented Nov 28, 2016 at 5:45
  • The full output has the banner and input and output details. Add -report to your command and run. A text file will be generated. Post that. Let's handle audio after that.
    – Gyan
    Commented Nov 28, 2016 at 5:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .