Skip to content

spencerjibz/video_compression

Repository files navigation

Video transcoding nodejs

Simple tutorial of video transcoding with fluent-ffmpeg.

Requirments

  • Nodejs versions with worker_threads & esmodule support
  • ffmpeg ;
  • Optional: Hardware acceleration requirements (Nvidia GPU with nvenc support Or Apple Silicon devices)

Features

  • h264 compression with a crf of 28,
  • Both single thread(singlethreaded.js) and multi-thread workloads(index.js&)
  • Resizing to any resolution (when provided an array of resolutions)
  • Conversion to mp4
  • Hardware accelerated video compression with cuda support(using h264_nevc) && videotool box for Mac

usage

Note:

  • Before testing, create a folder named compressed in the root directory.
  • For GPU acceleration, follow the instructions here to add hardware acceleration support to ffmpeg. (Nividia only).

  1. single threaded
 node singlethreaded.js [InputFilenamewithExt]
  1. Multithreaded workload.
 node  index.js [InputFilenamewithExt]
  1. Clean up the example out files
  ./cleanup.sh 
  1. Compare video file sizes of original and compressed;
 ./checkVideoSize.sh

The End

thanks