Skip to main content
Update for movie in lower right corner for all source movie size, not just assuming equal size of both movies
Source Link

You can use ffmpeg filters to overlay the video and create a Picture-in-Picture effect. To overlay the movie2.avi, we'll have to scale it down, and to play it back with a lower frame rate, we'll use another filter.

Your command looks something like this:

ffmpeg -i movie1.avi \
-filter:v "movie=movie2.avi, scale=iw/2:ih/2, setpts=2.0*PTS [small];\
[in][small] overlay=main_w*0.5overlay=main_w-overlay_w:main_h*0.5main_h-overlay_h [out]" output.avi

For readability, I've split the command where the \ are. To break it down:

  • -i movie1.avi is your big input movie.
  • -filter:v "movie=movie2.avi loads the small movie.
  • scale=iw/2:ih/2 scales down that movie to half of its width and height. iw and ih are parameters that take the input width and height, respectively. Look at the scale filter options if you want to tweak that.
  • setpts=2.0*PTS lets the video appear twice as slow as the original by "expanding" the individual presentation time stamps of the frames. You could speed it up with 0.5*PTS. See setpts.
  • This is assigned to the [small] link.
  • The [in] and [small] links are then combined with an overlay filter, positioning the top left corner of the smaller video at the middle of the frame. The main_w and main_h parameters take the width and height of the frame, so here, you're selecting the exact middle point.
  • This is rendered to [out].

It could look something like this:

Here are some tips:

  • Always use a recent version of ffmpeg, not the one provided by your Linux distribution. The FFmpeg download page has a list of static builds for each operating system.

  • The command, by default, will use some basic settings regarding video and audio codecs. This can result in the quality looking worse than the original. You can tweak the quality by setting a higher bit rate, or a variable quality flag with -qscale. Have a look at the XviD/MPEG-4 encoding guide for AVI video, or choose MP4 as output with the x264 encoder.

    In practice, this could look like the following:

      ffmpeg -i movie1.avi … -c:v libxvid -qscale 2 output.avi
      ffmpeg -i movie1.avi … -c:v libx264 -crf 21 output.mp4
    

You can use ffmpeg filters to overlay the video and create a Picture-in-Picture effect. To overlay the movie2.avi, we'll have to scale it down, and to play it back with a lower frame rate, we'll use another filter.

Your command looks something like this:

ffmpeg -i movie1.avi \
-filter:v "movie=movie2.avi, scale=iw/2:ih/2, setpts=2.0*PTS [small];\
[in][small] overlay=main_w*0.5:main_h*0.5 [out]" output.avi

For readability, I've split the command where the \ are. To break it down:

  • -i movie1.avi is your big input movie.
  • -filter:v "movie=movie2.avi loads the small movie.
  • scale=iw/2:ih/2 scales down that movie to half of its width and height. iw and ih are parameters that take the input width and height, respectively. Look at the scale filter options if you want to tweak that.
  • setpts=2.0*PTS lets the video appear twice as slow as the original by "expanding" the individual presentation time stamps of the frames. You could speed it up with 0.5*PTS. See setpts.
  • This is assigned to the [small] link.
  • The [in] and [small] links are then combined with an overlay filter, positioning the top left corner of the smaller video at the middle of the frame. The main_w and main_h parameters take the width and height of the frame, so here, you're selecting the exact middle point.
  • This is rendered to [out].

It could look something like this:

Here are some tips:

  • Always use a recent version of ffmpeg, not the one provided by your Linux distribution. The FFmpeg download page has a list of static builds for each operating system.

  • The command, by default, will use some basic settings regarding video and audio codecs. This can result in the quality looking worse than the original. You can tweak the quality by setting a higher bit rate, or a variable quality flag with -qscale. Have a look at the XviD/MPEG-4 encoding guide for AVI video, or choose MP4 as output with the x264 encoder.

    In practice, this could look like the following:

      ffmpeg -i movie1.avi … -c:v libxvid -qscale 2 output.avi
      ffmpeg -i movie1.avi … -c:v libx264 -crf 21 output.mp4
    

You can use ffmpeg filters to overlay the video and create a Picture-in-Picture effect. To overlay the movie2.avi, we'll have to scale it down, and to play it back with a lower frame rate, we'll use another filter.

Your command looks something like this:

ffmpeg -i movie1.avi \
-filter:v "movie=movie2.avi, scale=iw/2:ih/2, setpts=2.0*PTS [small];\
[in][small] overlay=main_w-overlay_w:main_h-overlay_h [out]" output.avi

For readability, I've split the command where the \ are. To break it down:

  • -i movie1.avi is your big input movie.
  • -filter:v "movie=movie2.avi loads the small movie.
  • scale=iw/2:ih/2 scales down that movie to half of its width and height. iw and ih are parameters that take the input width and height, respectively. Look at the scale filter options if you want to tweak that.
  • setpts=2.0*PTS lets the video appear twice as slow as the original by "expanding" the individual presentation time stamps of the frames. You could speed it up with 0.5*PTS. See setpts.
  • This is assigned to the [small] link.
  • The [in] and [small] links are then combined with an overlay filter, positioning the top left corner of the smaller video at the middle of the frame. The main_w and main_h parameters take the width and height of the frame, so here, you're selecting the exact middle point.
  • This is rendered to [out].

It could look something like this:

Here are some tips:

  • Always use a recent version of ffmpeg, not the one provided by your Linux distribution. The FFmpeg download page has a list of static builds for each operating system.

  • The command, by default, will use some basic settings regarding video and audio codecs. This can result in the quality looking worse than the original. You can tweak the quality by setting a higher bit rate, or a variable quality flag with -qscale. Have a look at the XviD/MPEG-4 encoding guide for AVI video, or choose MP4 as output with the x264 encoder.

    In practice, this could look like the following:

      ffmpeg -i movie1.avi … -c:v libxvid -qscale 2 output.avi
      ffmpeg -i movie1.avi … -c:v libx264 -crf 21 output.mp4
    
added 2 characters in body
Source Link
slhck
  • 232.6k
  • 72
  • 628
  • 604

You can use ffmpeg filters to overlay the video and create a Picture-in-Picture effect. To overlay the movie2.avi, we'll have to scale it down, and to play it back with a lower frame rate, we'll use another filter.

Your command looks something like this:

ffmpeg -i movie_1movie1.avi \
-filter:v "movie=movie_2"movie=movie2.avi, scale=iw/2:ih/2, setpts=2.0*PTS [small];\
[in][small] overlay=main_w*0.5:main_h*0.5 [out]" output.avi

For readability, I've split the command where the \ are. To break it down:

  • -i movie_1movie1.avi is your big input movie.
  • -filter:v "movie=movie_2"movie=movie2.avi loads the small movie.
  • scale=iw/2:ih/2 scales down that movie to half of its width and height. iw and ih are parameters that take the input width and height, respectively. Look at the scale filter options if you want to tweak that.
  • setpts=2.0*PTS lets the video appear twice as slow as the original by "expanding" the individual presentation time stamps of the frames. You could speed it up with 0.5*PTS. See setpts.
  • This is assigned to the [small] link.
  • The [in] and [small] links are then combined with an overlay filter, positioning the top left corner of the smaller video at the middle of the frame. The main_w and main_h parameters take the width and height of the frame, so here, you're selecting the exact middle point.
  • This is rendered to [out].

It could look something like this:

Here are some tips:

  • Always use a recent version of ffmpeg, not the one provided by your Linux distribution. The FFmpeg download page has a list of static builds for each operating system.

  • The command, by default, will use some basic settings regarding video and audio codecs. This can result in the quality looking worse than the original. You can tweak the quality by setting a higher bit rate, or a variable quality flag with -qscale. Have a look at the XviD/MPEG-4 encoding guide for AVI video, or choose MP4 as output with the x264 encoder.

    In practice, this could look like the following:

      ffmpeg -i movie_1movie1.avi … -c:v libxvid -qscale 2 output.avi
      ffmpeg -i movie_1movie1.avi … -c:v libx264 -crf 21 output.mp4
    

You can use ffmpeg filters to overlay the video and create a Picture-in-Picture effect. To overlay the movie2.avi, we'll have to scale it down, and to play it back with a lower frame rate, we'll use another filter.

Your command looks something like this:

ffmpeg -i movie_1.avi \
-filter:v "movie=movie_2.avi, scale=iw/2:ih/2, setpts=2.0*PTS [small];\
[in][small] overlay=main_w*0.5:main_h*0.5 [out]" output.avi

For readability, I've split the command where the \ are. To break it down:

  • -i movie_1.avi is your big input movie.
  • -filter:v "movie=movie_2.avi loads the small movie.
  • scale=iw/2:ih/2 scales down that movie to half of its width and height. Look at the scale filter options if you want to tweak that.
  • setpts=2.0*PTS lets the video appear twice as slow as the original by "expanding" the individual presentation time stamps of the frames. See setpts.
  • This is assigned to the [small] link.
  • The [in] and [small] links are then combined with an overlay filter, positioning the top left corner of the smaller video at the middle of the frame.
  • This is rendered to [out].

It could look something like this:

Here are some tips:

  • Always use a recent version of ffmpeg, not the one provided by your Linux distribution. The FFmpeg download page has a list of static builds for each operating system.

  • The command, by default, will use some basic settings regarding video and audio codecs. This can result in the quality looking worse than the original. You can tweak the quality by setting a higher bit rate, or a variable quality flag with -qscale. Have a look at the XviD/MPEG-4 encoding guide for AVI video, or choose MP4 as output with the x264 encoder.

    In practice, this could look like the following:

      ffmpeg -i movie_1.avi … -c:v libxvid -qscale 2 output.avi
      ffmpeg -i movie_1.avi … -c:v libx264 -crf 21 output.mp4
    

You can use ffmpeg filters to overlay the video and create a Picture-in-Picture effect. To overlay the movie2.avi, we'll have to scale it down, and to play it back with a lower frame rate, we'll use another filter.

Your command looks something like this:

ffmpeg -i movie1.avi \
-filter:v "movie=movie2.avi, scale=iw/2:ih/2, setpts=2.0*PTS [small];\
[in][small] overlay=main_w*0.5:main_h*0.5 [out]" output.avi

For readability, I've split the command where the \ are. To break it down:

  • -i movie1.avi is your big input movie.
  • -filter:v "movie=movie2.avi loads the small movie.
  • scale=iw/2:ih/2 scales down that movie to half of its width and height. iw and ih are parameters that take the input width and height, respectively. Look at the scale filter options if you want to tweak that.
  • setpts=2.0*PTS lets the video appear twice as slow as the original by "expanding" the individual presentation time stamps of the frames. You could speed it up with 0.5*PTS. See setpts.
  • This is assigned to the [small] link.
  • The [in] and [small] links are then combined with an overlay filter, positioning the top left corner of the smaller video at the middle of the frame. The main_w and main_h parameters take the width and height of the frame, so here, you're selecting the exact middle point.
  • This is rendered to [out].

It could look something like this:

Here are some tips:

  • Always use a recent version of ffmpeg, not the one provided by your Linux distribution. The FFmpeg download page has a list of static builds for each operating system.

  • The command, by default, will use some basic settings regarding video and audio codecs. This can result in the quality looking worse than the original. You can tweak the quality by setting a higher bit rate, or a variable quality flag with -qscale. Have a look at the XviD/MPEG-4 encoding guide for AVI video, or choose MP4 as output with the x264 encoder.

    In practice, this could look like the following:

      ffmpeg -i movie1.avi … -c:v libxvid -qscale 2 output.avi
      ffmpeg -i movie1.avi … -c:v libx264 -crf 21 output.mp4
    
Source Link
slhck
  • 232.6k
  • 72
  • 628
  • 604

You can use ffmpeg filters to overlay the video and create a Picture-in-Picture effect. To overlay the movie2.avi, we'll have to scale it down, and to play it back with a lower frame rate, we'll use another filter.

Your command looks something like this:

ffmpeg -i movie_1.avi \
-filter:v "movie=movie_2.avi, scale=iw/2:ih/2, setpts=2.0*PTS [small];\
[in][small] overlay=main_w*0.5:main_h*0.5 [out]" output.avi

For readability, I've split the command where the \ are. To break it down:

  • -i movie_1.avi is your big input movie.
  • -filter:v "movie=movie_2.avi loads the small movie.
  • scale=iw/2:ih/2 scales down that movie to half of its width and height. Look at the scale filter options if you want to tweak that.
  • setpts=2.0*PTS lets the video appear twice as slow as the original by "expanding" the individual presentation time stamps of the frames. See setpts.
  • This is assigned to the [small] link.
  • The [in] and [small] links are then combined with an overlay filter, positioning the top left corner of the smaller video at the middle of the frame.
  • This is rendered to [out].

It could look something like this:

Here are some tips:

  • Always use a recent version of ffmpeg, not the one provided by your Linux distribution. The FFmpeg download page has a list of static builds for each operating system.

  • The command, by default, will use some basic settings regarding video and audio codecs. This can result in the quality looking worse than the original. You can tweak the quality by setting a higher bit rate, or a variable quality flag with -qscale. Have a look at the XviD/MPEG-4 encoding guide for AVI video, or choose MP4 as output with the x264 encoder.

    In practice, this could look like the following:

      ffmpeg -i movie_1.avi … -c:v libxvid -qscale 2 output.avi
      ffmpeg -i movie_1.avi … -c:v libx264 -crf 21 output.mp4