TransWikia.com

ffmpeg: Replace part of a video by a jpg file for 5 seconds

Unix & Linux Asked by vyasa on January 3, 2022

Sometimes I have a video in which I like to discard the video sequence for five seconds between second 11 and second 16 (as an example) and instead incorporate an image from a jpg file that is displayed during that time and leaving the audio sequence intact.

Would be great if someone told me an apt command line for this.

Thanks in advance 🙂

UPDATE 20200906: The solution should not re-encode the entire video in order to rapidly process large video files with a short image-overlay.

2 Answers

Just an idea, but how about: splitting the video in three parts (pre, needed-part, post)

then applying the idea posted to the "needed-part".

Afterwards concatenate the three files together again ?

PS: Using the command above kinda destroys my videos picture quality... no idea why...

Answered by Rye on January 3, 2022

Use

ffmpeg -i video -i image -filter_complex "[1][0]scale2ref[img][vid];[vid][img]overlay=enable='between(t,11,16)'" -c:a copy out.mp4

Scale2ref resizes the image to the resolution of the video. The overlay places the image on top of the video from the 12th to the end of the 16th second.

Answered by Gyan on January 3, 2022

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP