Overlay images to frames in video

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Overlay images to frames in video

Rainer M Krug
Hi

First poster, o apologies for any forgotten info.


I have a video with the following metadata:

```
$ ffprobe ./1.pre-processed.data/bemovi/20210208_00097.avi
ffprobe version 4.3.2 Copyright (c) 2007-2021 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.29)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.2_4 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, avi, from './1.pre-processed.data/bemovi/20210208_00097.avi':
  Metadata:
    encoder         : Lavf58.45.100
  Duration: 00:00:12.50, start: 0.000000, bitrate: 91831 kb/s
    Stream #0:0: Video: png (PNG  / 0x20474E50), pal8(pc), 2048x2048, 92565 kb/s, 10 fps, 10 tbr, 10 tbn, 10 tbc
    Metadata:
      title           : FileAVI write  
```

In addition, I have 125 images (jpg, but I can as easily create them as png) which contain some labelling of the individual frames. The particles are moving, the images are different.

Now I want to overlay the images over the corresponding frames.

What is the easiest to do this? I could convert them to a move, then overlay these two, but I have the feeling I could do this in one step?

Any suggestions?

Thanks,

Rainer



--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office: +41 (0)44 635 47 64
Cell:       +41 (0)78 630 66 57
email:      [hidden email]
                [hidden email]
Skype:     RMkrug

PGP: 0x0F52F982




_______________________________________________
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".

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Overlay images to frames in video

pdr0
Rainer M. Krug-2 wrote

> Hi
>
> First poster, o apologies for any forgotten info.
>
>
> I have a video with the following metadata:
>
> ```
> $ ffprobe ./1.pre-processed.data/bemovi/20210208_00097.avi
> ffprobe version 4.3.2 Copyright (c) 2007-2021 the FFmpeg developers
>   built with Apple clang version 12.0.0 (clang-1200.0.32.29)
>   configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.2_4 --enable-shared
> --enable-pthreads --enable-version3 --enable-avresample --cc=clang
> --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls
> --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d
> --enable-libmp3lame --enable-libopus --enable-librav1e
> --enable-librubberband --enable-libsnappy --enable-libsrt
> --enable-libtesseract --enable-libtheora --enable-libvidstab
> --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264
> --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma
> --enable-libfontconfig --enable-libfreetype --enable-frei0r
> --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb
> --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq
> --enable-libzimg --disable-libjack --disable-indev=jack
> --enable-videotoolbox
>   libavutil      56. 51.100 / 56. 51.100
>   libavcodec     58. 91.100 / 58. 91.100
>   libavformat    58. 45.100 / 58. 45.100
>   libavdevice    58. 10.100 / 58. 10.100
>   libavfilter     7. 85.100 /  7. 85.100
>   libavresample   4.  0.  0 /  4.  0.  0
>   libswscale      5.  7.100 /  5.  7.100
>   libswresample   3.  7.100 /  3.  7.100
>   libpostproc    55.  7.100 / 55.  7.100
> Input #0, avi, from './1.pre-processed.data/bemovi/20210208_00097.avi':
>   Metadata:
>     encoder         : Lavf58.45.100
>   Duration: 00:00:12.50, start: 0.000000, bitrate: 91831 kb/s
>     Stream #0:0: Video: png (PNG  / 0x20474E50), pal8(pc), 2048x2048,
> 92565 kb/s, 10 fps, 10 tbr, 10 tbn, 10 tbc
>     Metadata:
>       title           : FileAVI write  
> ```
>
> In addition, I have 125 images (jpg, but I can as easily create them as
> png) which contain some labelling of the individual frames. The particles
> are moving, the images are different.
>
> Now I want to overlay the images over the corresponding frames.
>
> What is the easiest to do this? I could convert them to a move, then
> overlay these two, but I have the feeling I could do this in one step?
>
> Any suggestions?
>
> Thanks,
>
> Rainer


Overlay them where? What x,y position? What is the dimension of your jpg
sequence?

jpg does not specify an alpha channel (transparency information). If you
overlay the jpg sequence over the base video layer , and assuming they are
the same dimensions, you will "cover up" the video layer entirely . You will
not see the video, only the jpg sequence

When you say you can "create them as PNG", does the original source have an
alpha channel?






--
Sent from: http://ffmpeg-users.933282.n4.nabble.com/
_______________________________________________
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: Overlay images to frames in video

Rainer M Krug
Thanks for your reply

Comments inline

> On 7 Apr 2021, at 21:28, pdr0 <[hidden email]> wrote:
>
> Rainer M. Krug-2 wrote
>> Hi
>>
>> First poster, o apologies for any forgotten info.
>>
>>
>> I have a video with the following metadata:
>>
>> ```
>> $ ffprobe ./1.pre-processed.data/bemovi/20210208_00097.avi
>> ffprobe version 4.3.2 Copyright (c) 2007-2021 the FFmpeg developers
>>  built with Apple clang version 12.0.0 (clang-1200.0.32.29)
>>  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.2_4 --enable-shared
>> --enable-pthreads --enable-version3 --enable-avresample --cc=clang
>> --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls
>> --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d
>> --enable-libmp3lame --enable-libopus --enable-librav1e
>> --enable-librubberband --enable-libsnappy --enable-libsrt
>> --enable-libtesseract --enable-libtheora --enable-libvidstab
>> --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264
>> --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma
>> --enable-libfontconfig --enable-libfreetype --enable-frei0r
>> --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb
>> --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq
>> --enable-libzimg --disable-libjack --disable-indev=jack
>> --enable-videotoolbox
>>  libavutil      56. 51.100 / 56. 51.100
>>  libavcodec     58. 91.100 / 58. 91.100
>>  libavformat    58. 45.100 / 58. 45.100
>>  libavdevice    58. 10.100 / 58. 10.100
>>  libavfilter     7. 85.100 /  7. 85.100
>>  libavresample   4.  0.  0 /  4.  0.  0
>>  libswscale      5.  7.100 /  5.  7.100
>>  libswresample   3.  7.100 /  3.  7.100
>>  libpostproc    55.  7.100 / 55.  7.100
>> Input #0, avi, from './1.pre-processed.data/bemovi/20210208_00097.avi':
>>  Metadata:
>>    encoder         : Lavf58.45.100
>>  Duration: 00:00:12.50, start: 0.000000, bitrate: 91831 kb/s
>>    Stream #0:0: Video: png (PNG  / 0x20474E50), pal8(pc), 2048x2048,
>> 92565 kb/s, 10 fps, 10 tbr, 10 tbn, 10 tbc
>>    Metadata:
>>      title           : FileAVI write  
>> ```
>>
>> In addition, I have 125 images (jpg, but I can as easily create them as
>> png) which contain some labelling of the individual frames. The particles
>> are moving, the images are different.
>>
>> Now I want to overlay the images over the corresponding frames.
>>
>> What is the easiest to do this? I could convert them to a move, then
>> overlay these two, but I have the feeling I could do this in one step?
>>
>> Any suggestions?
>>
>> Thanks,
>>
>> Rainer
>
>


> Overlay them where? What x,y position?

1:1 overlay - i.e. covering everything.

> What is the dimension of your jpg sequence?

They are the same dimensions as the video.

>
> jpg does not specify an alpha channel (transparency information). If you
> overlay the jpg sequence over the base video layer , and assuming they are
> the same dimensions, you will "cover up" the video layer entirely . You will
> not see the video, only the jpg sequence
>
> When you say you can "create them as PNG", does the original source have an
> alpha channel?

The images are created in a different script. I changed it to png and they have ab alpha channel.

I am using now the following:

ffmpeg -start_number 1 -framerate 10 -i 'frame_%d.png’ -vcodec png ‘overlay.avi'

To create the move from the png files (same frame rate and codec as the second movie), and

ffmpeg -i ‘background_movie.avi' -i 'overlay.avi' -filter_complex 'overlay=0x0’ ‘final_movie.avi’

To do the actual overlay.

This is working. If I am missing something here, please let me know.


Thanks,

Rainer



>
>
>
>
>
>
> --
> Sent from: http://ffmpeg-users.933282.n4.nabble.com/ <http://ffmpeg-users.933282.n4.nabble.com/>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email] <mailto:[hidden email]>
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user <https://ffmpeg.org/mailman/listinfo/ffmpeg-user>
>
> To unsubscribe, visit link above, or email
> [hidden email] <mailto:[hidden email]> with subject "unsubscribe".
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office: +41 (0)44 635 47 64
Cell:       +41 (0)78 630 66 57
email:      [hidden email]
                [hidden email]
Skype:     RMkrug

PGP: 0x0F52F982




_______________________________________________
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".

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Overlay images to frames in video

Michael Koch
Am 08.04.2021 um 09:27 schrieb Rainer M Krug:
> ffmpeg -i ‘background_movie.avi' -i 'overlay.avi' -filter_complex
> 'overlay=0x0’ ‘final_movie.avi’

I think overlay=0x0 is not doing what you expect. It does set the x
option to hexadecimal 0, and it doesn't specify the y option. In your
case that doesn't matter because the default values are 0. You could
write 'overlay=x=0:y=0' or you could simplify it to just 'overlay'
without any options.

Michael

_______________________________________________
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: Overlay images to frames in video

Rainer M Krug
Thanks a lot - these are the things I was afraid of missing.

 I will change it and use 'overlay=x=0:y=0’ for clarity.

Rainer

> On 8 Apr 2021, at 09:45, Michael Koch <[hidden email]> wrote:
>
> Am 08.04.2021 um 09:27 schrieb Rainer M Krug:
>> ffmpeg -i ‘background_movie.avi' -i 'overlay.avi' -filter_complex 'overlay=0x0’ ‘final_movie.avi’
>
> I think overlay=0x0 is not doing what you expect. It does set the x option to hexadecimal 0, and it doesn't specify the y option. In your case that doesn't matter because the default values are 0. You could write 'overlay=x=0:y=0' or you could simplify it to just 'overlay' without any options.
>
> Michael
>
> _______________________________________________
> 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".
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office: +41 (0)44 635 47 64
Cell:       +41 (0)78 630 66 57
email:      [hidden email]
                [hidden email]
Skype:     RMkrug

PGP: 0x0F52F982




_______________________________________________
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".

smime.p7s (5K) Download Attachment