How to use FFmpeg to create test input

A useful tool in many situations is FFmpeg. Documentation on using FFmpeg is available at the FFmpeg wiki.

Create an MPEG-TS feed on a port

The following is a recipe for creating an MPEG Transport Stream (TS) feed on a port, where <mp4 video file> is the file to be used as a video source:

$ ffmpeg -nostdin -re -stream_loop -1 -i ~/encoder/data/<mp4 video file> \ -c copy -f mpegts 'udp://127.0.0.1:1234' > logile.txt 2>&1 &

The above command can be executed in foreground or background.

FFmpeg opens sockets for STDIN, STDOUT, and STDERR by default. If the STDIN isn’t disabled with -nostdin a background FFmpeg process will stall on socket reads from STDIN and the video will not display.

Encoder File Input

Looping a file, where the file is named demo.mp4:

ffmpeg -re -stream_loop -1 -i demo.mp4 -c copy -f mpegts udp://0.0.0.0:5501

Encoder input:

sourceUri: 'udp://192.168.1.101:5501'

Where sourceUri: 'udp://192.168.1.101 is the local IP address of the Encoder and 5501 matches the port from the looping command.

Static image with a timecode (counter, not clock)

The following is a recipe for creating a static image video with a timecode counting up from 00:00:00:00 (HH:MM:SS:FF), where r is the framerate and <rtmp URL> is the destination URL of the video stream.

The “image.png” input in the above argument must be appropriately sized for the video being fed. That is, the dimensions must equal the video resolution.

Larger font sizes may be desired for higher resolutions.

For example, using an image file that is 480 x 720, the result will appear similar to the following at one hour, 10 minutes, 37 seconds, and 9 frames:

Color bar video with audio file

Create a tone and click track in a tool such as Audacity. That tool allows you to generate all kinds of annyoing tones, clicks, etc. Be sure to set the project sample rate to 48kHz instead of 44.1kHz, which is the default.

Use ffmpeg to add the audio track to an ffmpeg-generated color bar pattern with a counter.

Trim it to length if necessary. For example, the toneAndClick file is only 10 minutes, so this command trims the file to only 10 minutes.

 

©2020-2021 Phenix Real Time Solutions, Inc.