Do it yourself (DIY) transcoding

You have the option to do your own transcoding, which might be desirable if you already have render processes in place that produce images or movies in a web-streamable format.

DIY transcoding tips

Here are some details you'll want to keep in mind should you decide to go this route:

Automatic transcoding must be disabled

Make sure we disable automatic transcoding for uploaded images and movies if you are doing your own transcoding, otherwise uploaded media files will continue to be automatically transcoded, and may overwrite your own transcoded movies on the server. Just send us a support ticket and we'll deactivate transcoding for your site.

Shotgun’s transcoder generates MP4 and WebM

(We can make it so these fields show up in the UI for you while you're setting up your transcoding scripts; just send us a support ticket to request this.)

Name movies with extensions for their file type

Best practice is to name the movies you create with the proper extensions for each respective file type (.mp4 and .webm). Some browsers may not properly detect the movie format without these specific extensions, which may lead to playback errors.

The frames per second (FPS) defaults to 24

The field sg_uploaded_movie_frame_rate defaults to 24, so for media that is not 24 FPS you will need to set the correct sg_uploaded_movie_frame_rate.

DIY transcoding code

This is the FFmpeg code we run to generate the streamable movie files (one for H.264 and one for WebM). The variable substitution is ruby-style.

  • vcodec = "-vcodec libx264 -pix_fmt yuv420p -vf 'scale=trunc((a*oh)/2)*2:720' -g 30 -b:v 2000k -vprofile high -bf 0"
    acodec = "-strict experimental -acodec aac -ab 160k -ac 2"
    ffmpeg -i #{src_file} #{acodec} #{vcodec} -f mp4 #{dest_file_mp4}
    vcodec = " -pix_fmt yuv420p -vcodec libvpx -vf 'scale=trunc((a*oh)/2)*2:720' -g 30 -b:v 2000k -vpre 720p -quality realtime -cpu-used 0 -qmin 10 -qmax 42"
    acodec = "-acodec libvorbis -aq 60 -ac 2"
    ffmpeg -i #{src_file} #{acodec} #{vcodec} -f webm #{dest_file_webm}

If you need to force the frame rate, you can add the -r flag to the transcoding calls. So to force 24 FPS on the WebM, you'd have something like this:

  • ffmpeg -r 24 -i #{src_file} #{acodec} #{vcodec} -f webm #{dest_file_webm}

Note that it is important for this flag to remain the first in the list, otherwise we have seen FFmpeg drop some frames in the encoding.

  • For image files, Shotgun's Transcoder generates a single high resolution (maximum 2k) image file (PNG if the original contains transparency, JPG otherwise) that is used by all supported browsers. The high resolution image file is stored in a hidden field in the UI, but you can update them via the API. The field name is sg_uploaded_movie_image. (We can make it so these fields show up in the UI for you while you're setting up your transcoding scripts, just drop us an email at to request this.)

This is the ImageMagick code we run to generate the still image files.

  • convert #{src_file} -resize #{2048}x{2048}\\> #{dest_file}

Shotgun's built-in transcoder creates thumbnails in addition to generating the streamable movie formats. If you choose to do your own transcoding, you'll probably want to build in API calls that replicate this functionality. Check the API docs for upload_thumbnail() and upload_filmstrip_thumbnail() for more information.

If you want to create your own Filmstrip Thumbnails using FFmpeg, here is the code we use to generate the image from a set of individual thumbnail images:

ffmpeg -r #{frame_count/seconds} -i #{src_file} -f image2 #{thumb_files}-%02d.jpeg
montage #{thumb_files}-* -geometry #{frame_width}x+0+0 -tile x1 -format jpeg -quality #{quality} #{filmstrip_path}

Automatic transcoding

For more information on how Shotgun automatically transcodes movies and images, see the article "Transcoding."