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

Notes:

Here are some details to keep in mind if you choose to DIY transcode:

Turning off automatic transcoding is optional

Flow Production Tracking will monitor the sg_uploaded_movie field and automatically transcode supported files. However, if you are doing your own transcoding, the uploaded .mp4 media file will be transcoded to the sg_uploaded_movie_mp4 field instead of the sg_uploaded_movie field. In this case, automatic transcoding will not be triggered.

When a thumbnail is uploaded, automatic transcoding will generate a smaller version of that thumbnail.

Exposing hidden fields

The sg_uploaded_movie_mp4 and sg_uploaded_movie_frame_rate fields are not visible by default. These fields can be made visible in the browser by entering the following command into your browser's javascript console:

SG.schema.entity_fields.Version.sg_uploaded_movie_mp4.grid_column = true;
SG.schema.entity_fields.Version.sg_uploaded_movie_frame_rate.grid_column = true;

If you want these two transcoding fields to always be visible in the UI while you're setting up your transcoding scripts, contact support.

Name movies with extensions for their file type

Best practice is to name the movies you create with the proper extensions (.mp4). 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. The variable substitution is ruby-style.

vcodec = "-vcodec libx264 -pix_fmt yuv420p -vf 'scale=trunc((a*oh)/2)*2:%{height}' -g 30 -vprofile high -bf 0 -crf 23"
acodec = "-strict experimental -acodec aac -ab 160k -ac 2"
ffmpeg -i #{src_file} #{acodec} #{vcodec} -f mp4 #{dest_file_mp4}

The height variable above is the minimum between 1080 and the source resolution (so we don’t upscale).

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

ffmpeg -r 24 -i #{src_file} #{acodec} #{vcodec} -f mp4 #{dest_file_mp4}

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.

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

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

Flow Production Tracking'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 -threads #{self.threads_to_use} -i #{src_file} -vf select=\"not(mod((n-#{offset})\\,#{frame_increment}))\",setpts=\"N/(#{fps_f}*TB)\",scale=#{frame_width}:-1 -sws_flags lanczos -qscale:v 2 -pix_fmt yuvj420p -f image2 #{thumb_files}-%02d.jpeg"

Additional requirement for enabling DIY Transcoding on your site

When you're ready to activate DIY transcoding and turn off Automatic Flow Production Tracking transcoding, reach out to support so that they can configure your site appropriately.

Automatic transcoding

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