FFmpeg is a set of free, open source libraries and command line tools for recording, converting and streaming video and audio. FFmpeg is licensed under the LGPL version 2.1 or later with some parts licensed under the GPL version 2 or later.
2018-02-08
Some CCTV or surveillance camera systems record video in files with .264
extension. If you open a file like these with a text editor, you may see a video format tag, which could look like MDVR96NT_2_R
or similar. Usually, it is not straightforward to play such a file with a conventional video player application. You may have to convert the file into a more recognisable (video container) format, without further loss of quality. This can be accomplished with ffmpeg
command, specifying -c copy
option:
ffmpeg -vcodec h264 -i rawvid.264 -c copy playable.avi
The next example demonstrates how to copy 120 seconds of video, starting from offset 235 seconds of a long video file, into a new short video file.
ffmpeg -ss 235 -i long.avi -t 120 -c copy short.avi
In this particular context an 'image' means a still picture. The command below would break down a video file into individual frames and save them as JPEG files. The last parameter frame%04d.jpg
specifies the names of the output files to be frame0001.jpg, frame0002.jpg and so on.
ffmpeg -i video.avi -f image2 frame%04d.jpg
In order to compose video from images, you can use the same -f image2
option but with different order of the other parameters.
ffmpeg -f image2 -i frame%d.jpg -c:v copy video.avi
Breaking down and composing can be useful when making partially or fully synthetic video. Individual images can be processed more efficiently and to a greater extent with software like ImageMagick or GraphicsMagick, for example.
Copyright (C) 2021 embedeo.com Terms of use and legal disclaimer