Overlaying part of a video by an image file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Overlaying part of a video by an image file

Marcello Mazzon

Hi;

for months I have been on a project where I am trying to overlay a few
seconds of a longer video by an image file, leaving the audio sequence
intact. For this, I posted an enquiry on stackexchange [*] to which I
received a reply by an official ffmpeg-consultant.

*
https://unix.stackexchange.com/questions/588667/ffmpeg-replace-part-of-a-video-by-a-jpg-file-for-5-seconds

Unfortunately, we were incapable of coming up with a solution to
integrate the image file into the video without re-encoding the whole
of the video file but only the part where the image is being overlayed,
leaving the exact codec and parameters of the video intact.

It would be great if someone knew of a solution either by replying via
email or by posting an answer into the respective thread on
stackexchange.

Thanks in advance.

Greetings from Germany;
Marcello
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Overlaying part of a video by an image file [quickly, without re-encoding the rest]

Jim DeLaHunt-2
On 2020-07-24 07:34, Marcello Mazzon wrote:

> Hi;
>
> for months I have been on a project where I am trying to overlay a few
> seconds of a longer video by an image file, leaving the audio sequence
> intact. For this, I posted an enquiry on stackexchange [*] to which I
> received a reply by an official ffmpeg-consultant.
>
> *
> https://unix.stackexchange.com/questions/588667/ffmpeg-replace-part-of-a-video-by-a-jpg-file-for-5-seconds
>
> Unfortunately, we were incapable of coming up with a solution to
> integrate the image file into the video without re-encoding the whole
> of the video file but only the part where the image is being overlayed,
> leaving the exact codec and parameters of the video intact.
> …
> Greetings from Germany;
> Marcello

Marcello:

Welcome to the ffmpeg-users email list.

I will make the comment here which I also put on the Stack-exchange
question: You apparently have additional requirements: that the
operation complete in just a few seconds, and that the operation does
not reencode the entire video sequence. You are more likely to get
relevant answers if you include those requirements in your question.
Note that these requirements may mean there is no easy way to satisfy
them using FFmpeg.

In my experience, Gyan Doshi, who answered your question on Stack
Exchange, knows a lot about FFmpeg and is very willing to help. If Gyan
says that avoiding re-encoding the video is "not trivial", then that
likely means the task is quite difficult. However, maybe someone will
point out a clever use of FFmpeg which meets your requirements.

Much is possible if you are willing to write an extension of some kind
to ffmpeg to operate on the video directly. However, it will be a lot of
work to learn enough about FFmpeg to be able to write this code, and
also substantial effort to write, test, and deploy the code. You will
have to decide if that effort (or hiring someone to make that effort) is
worth avoiding the video reencode.

Good luck, und schöne Grüße aus Kanada,
       —Jim DeLaHunt, software engineer, Vancouver, Canada


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Overlaying part of a video by an image file [quickly, without re-encoding the rest]

Gyan Doshi-2


On 25-07-2020 01:38 am, Jim DeLaHunt wrote:

> On 2020-07-24 07:34, Marcello Mazzon wrote:
>> Hi;
>>
>> for months I have been on a project where I am trying to overlay a few
>> seconds of a longer video by an image file, leaving the audio sequence
>> intact. For this, I posted an enquiry on stackexchange [*] to which I
>> received a reply by an official ffmpeg-consultant.
>>
>> *
>> https://unix.stackexchange.com/questions/588667/ffmpeg-replace-part-of-a-video-by-a-jpg-file-for-5-seconds 
>>
>>
>> Unfortunately, we were incapable of coming up with a solution to
>> integrate the image file into the video without re-encoding the whole
>> of the video file but only the part where the image is being overlayed,
>> leaving the exact codec and parameters of the video intact.
>> …
>> Greetings from Germany;
>> Marcello
>
> Marcello:
>
> Welcome to the ffmpeg-users email list.
>
> I will make the comment here which I also put on the Stack-exchange
> question: You apparently have additional requirements: that the
> operation complete in just a few seconds, and that the operation does
> not reencode the entire video sequence. You are more likely to get
> relevant answers if you include those requirements in your question.
> Note that these requirements may mean there is no easy way to satisfy
> them using FFmpeg.
>
> In my experience, Gyan Doshi, who answered your question on Stack
> Exchange, knows a lot about FFmpeg and is very willing to help. If
> Gyan says that avoiding re-encoding the video is "not trivial", then
> that likely means the task is quite difficult. However, maybe someone
> will point out a clever use of FFmpeg which meets your requirements.
>
> Much is possible if you are willing to write an extension of some kind
> to ffmpeg to operate on the video directly. However, it will be a lot
> of work to learn enough about FFmpeg to be able to write this code,
> and also substantial effort to write, test, and deploy the code. You
> will have to decide if that effort (or hiring someone to make that
> effort) is worth avoiding the video reencode.

As I mentioned in the comment at SE, this can be done via segmentation,
modifying and re-encoding affected segments, then stitching old and
re-encoded segments back together. The tricky part is satisfying a
decoder to play both old and new segments. Some like our own H264
decoder have no, or I should say, few issues doing this even if codec
parameter sets don't perfectly match. But I expect hardware players and
many old software players to be finicky. It can be done but it's not
easily automatable, which I presume, is what the OP wants.

Gyan
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".