Three Video Editing Techniques with ffmpeg

Articles —> Three Video Editing Techniques with ffmpeg

ffmpeg is an open source audio/video tool for use in video recording, conversion, and streaming. It can be used for tasks such as creating a video slideshow from images, movie format conversion, and extracting a frame of a video as an image. ffmpeg is a command line tool, meaning it lacks a graphical user interface. While this gives it a steep learning curve for those unfamiliar with running tools from the 'command line' (on a mac, this is the 'terminal' application in the Application Utilities directory, on windows the 'Command Prompt' application in the Program Accessories directory), it readily facilitates batch processing of files and videos. Below I list three uses for ffmpeg I have found important in my video editing workflow.

  1. Movie Resizing: With today's technology one can readily capture movies with 1080p HD quality. A potential downside is the physical size of the movies created, which are often MB's if not GB's in size. This physical size can be cumbersome, causing difficulties in transferring over a network as well as making archive backups. However, if this particular size is not always necessary, one can resize the movies as needed, reducing file size tremendously. As an example, I often capture videos at the largest resolution - however backups of this volume require a large investment in backup devices. Thus, I typically retain the most important videos at a high resolution, while less important videos worth keeping are converted to a lower resolution. This is where ffmpeg works beautifully with a single command:

    ffmpeg -i -s 960x540 -vcodec copy -acodec copy

    The above command calls ffmpeg to reduce the input file to 960x540. This conversion, on average, results in a 10-fold reduction in physical size relative to 1080p. To facilitate batch conversion, my movie workflow utilizes a unix script (runnable on a mac or linux) to automate resizing: given a directory, the script reduces the size of all movies within - useful for directories containing more than a few movies:

    FILES=$(ls "$DIR" | grep -i mov)
    for FILE in $FILES
        echo "Processing $FILE..."                             
        ffmpeg -i "$DIR/$FILE" -s 960x540 -acodec copy "$DIR/m_$FILE"

    The above script accepts a command line parameter being the directory of movies, and reduces the size of each movie within this directory to 960x540. Here, each movie is anticipated to be a .mov format and converted to a given size, but different formats and sizes are acceptable.

  2. Movie From Images: Videos of a slideshow or animation can be accomplished by the generation of an image for one or more video frames, followed by the conversion of the sequence of images into a movie. A working example includes the construction of strange attractor videos, in which images representing the visual scene were saved as an image file (constructed using 3D graphics software) followed by the stitching of each frame into a movie. In some cases an audio track was added to the video. ffmpeg readily accomplishes these goals with a simple command that can stitch together the movie:

    ffmpeg -r 30 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4

    The above command lets ffmpeg know the names of the images to stitch (img%03d.png), the frame rate, and the video format; where the numbering - specified by the -i input parameter (%03d indicating 3 decimals) - is the sequential numbering of the images. Note any break in the sequence will terminate the movie. For more information on how to customize this useful technique, see the tutorial provided on the ffmpeg website. Addition of an audio track can be accomplished using mapping options:

    ffmpeg -i my_video.mp3 -i my_audio.mp3 -map 0 -map 1 -codec copy -shortest my_output_video.mp3
  3. Movie format conversion: Conversion of one video file format to another is sometimes a necessary task while editing or deploying videos. ffmpeg can recognize a large number of formats. Conversion of one file format to another is relatively simple, where the ouput file format is specified by the file extension (wmv, mov, mpeg, etc...):

    ffmpeg -i -vcodec copy -acodec copy out.wmv

    One can additionally modify the video in the process: for instance, change the video (-b) or audio (-ab) bitrate, the size (see above), etc...

ffmpeg not only makes video editing easy, given its capability of running from the command line gives it the power to be scripted - facilitating batch conversion of videos. In my opinion a very useful tool in one's video editing toolkit.


  • ffmpeg - a complete, cross-platform solution to record, convert and stream audio and video
  • ffmpeg: Create a video slideshow from images.
  • ffmpeg: embedding audio tracks into a video.

There are no comments on this article.

Back to Articles

© 2008-2017 Greg Cope