0% found this document useful (0 votes)
49 views

Application Note Xinye

This document discusses customizing an FFMPEG command to create a mosaic view from multiple video streams. It provides an overview of the base script and describes how each option works. It then explains how to modify the complex filter to expand one video feed while cropping the others by changing the resolution and position of each input stream in the filter graph.

Uploaded by

Andi Sugandi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Application Note Xinye

This document discusses customizing an FFMPEG command to create a mosaic view from multiple video streams. It provides an overview of the base script and describes how each option works. It then explains how to modify the complex filter to expand one video feed while cropping the others by changing the resolution and position of each input stream in the filter graph.

Uploaded by

Andi Sugandi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Customizing FFMPEG Commands for Mosaic View

Xinye Ji
General Overview of a base script:

In order to change certain settings while recording a live stream with FFMPEG, this
base shell script must be changed. The description of each option is as follows:

Line 17: ffmpeg telling the terminal that ffmpeg is being used.
Lines 18-21: Defining the input feeds and the settings of each feed below.
Video4linux2 is an open source package that allows the machine to
have a live feed of the webcam.
-r 10 refers to the frame rate (in frames per second)
-vcodec refers to the video codec that the stream is encoded in
-i refers to the input source.
Lines 22-31: Complex Filters This allows the user to add either color filters or
overlays.
filter_complex: the call to implement filters, this is formatted and
constructed in the quoted text (highlighted yellow)
Line 23: This refers to the base resolution of the whole video.
[base] can be any name.
Lines 24-27: Instantiating the input feeds
o [n:v] : The numbering of the inputs, in this case 0-3
o setpts : sets the time point. In this case, PTS-STARTPTS
refers to 0, ensuring that all video streams are
synchronized.
o Scale = the individual resolution of the respective feed.
o The last part refers to the name of this input. It can be
labeled whatever is needed. In this case, it labels the four
corners.
Lines 28-31: Calls the base layer and immediately stacks the input
feeds in between temporary layers.
o Overlay=shortest=1 enables the video to end as soon as the
shortest video feed ends.
o The X and Y calls simply refer to the upper left corner of
each feed. If x = 320 and y = 240, that means that the upper
left corner of a video feed is located at 320 by 240.
Line 32: Settings for the output video
-q:v refers to the video quality. This number can range between
1-32; one (1) being the highest quality, thirty-two (32) being the
lowest quality.
o The higher the quality, the larger the file size.
-y This enables the script to overwrite a file.
-t Sets the time in seconds. Additionally, 00:00:00.00 can also be
inputted.
temp.mp4 The output file name, this can be named everything.

Modifying the complex filter


Being able to modify the filter is pivotal to custom tailoring the live feeds to your
needs. Currently the feed has a layout similar to this.
Problem: What if one camera feed needs more detail than the rest?

Solution: Expanding that view and cropping the others respectively.

One way to do this is:

While this isnt the most efficient method, it serves the purposes of the tutorial well.

Step 1: Setting the base resolution


The total resolution of the video can be changed here. In this situation, do not
modify the highlighted value.
Step 2: Resizing the individual feeds.

These values need to be changed accordingly:

Upper left: 480x120


Upper right: 160x120
Lower left: 480x360
Lower right: 160x360

Step 3: As this script stands, this output will not be positioned tightly, there will be
odd black space between the feeds, as such we need to change the x and y
coordinates of each feed.

Upper left: No changes needed, begins at (0, 0)


Upper right: (480, 0), x must be set to 480 instead of 320.
Lower left: (0, 160), y must be set to 160 instead of 240.
Lower right: (480, 360), x must be 480, and y must be 360.
INDEX
Settings table
Valid Input Function Examples
-f Live feeds Allows FFMPEG to video4linux2,
accept video feeds x11grab
from other audio
sources
-i file directory/ input file location /dev/video0,
names /Desktop/video.mov
-r 0 < x < inf Frame rate read in 1, 24, 29.975, 50
frames per second
-vcodec Codec libraries Determines the Libx264, mjpeg,
codec to encode mpeg, etc.
the video input or
output stream
-filter_complex Varies depending Allows See Modifying the
on string manipulation of Complex Filter
complex/multiple
input streams.
-q:v Number between Determines the 1, 4, 5, 30
1-32 video quality.
(Balance between
file size and quality
loss)
-y No input Allows script to N/A
overwrite existing
video file
-t Any integer (in Determines length 5, 00:00:05.03,
seconds) or of the video. 50:01:00.09
xx:xx:xx.yy where
xx is any number
from 0-59, and yy
is between 0-99

You might also like