User Tools

Site Tools


postproduction:ffmpegconversionworkflows

FFMpeg Conversion Workflows

This is a bunch of unsorted tinkerings with FFMpeg and some useful conversion Workflows that might help you in your postproduction work. Not necessarily BMPCC related but still useful.

Transcoding with LUT

if you need to create rushes of any Prores recorded in FILM Setting and want to apply a preliminary color preview (i.e. for editing): recent ffmpeg (>=2.0) versions can apply LUT's during conversion:

example for h264 conversion while applying Hooks LUT

ffmpeg -i input.mov \
-vf "lut3d=/home/x/Downloads/HooksLUT/Hook_BMDFilm2Vid_3DLC_BASIC_V1.cube" \
-c:v libx264 -preset fast -crf 22 output.mp4

trancoding to prores proxy while applying LUT:

ffmpeg -i input.mov \
-vf "lut3d=/home/till/Downloads/HooksLUT/Hook_BMDFilm2Vid_3DLC_BASIC_V1.cube" \
-vcodec prores -profile:v 0 -an output.mov

Transcoding with LUT and adding TC

example for h264 conversion while applying LUT and superimposing Timecode

#!/bin/bash
for file in *.mov; do
    ffmpeg -i "$file" -vf "lut3d=./path/to/3dLUT.cube, \
    drawtext=fontfile=/usr/share/fonts/liberation/LiberationSans-Regular.ttf : \
    timecode='00\:00\:00\:00': r=25: x=(w-tw)/2: y=h-(2*lh): \
    fontsize=30: fontcolor=white: box=1: boxcolor=0x00000000@1" \
    -c:v libx264 -preset ultrafast -crf 35 -c:a aac -b:a 128k \
    -strict -2 "$file".mp4
done;

Anamorphic desqueeze

The following gives you square pixels in the result. You might want to optimize with different scalers.

#!/bin/bash
for file in *.mov; do
    ffmpeg -i "$file" -vf scale=1920:720,setsar=1:1,setdar=2.66:0,unsharp \
    -c:v libx264 -preset ultrafast -crf 35 -c:a aac -b:a 128k \
    -strict -2 "$file".mp4  
done;

Crop and scale an anamorphic part of the image

Extract 1440 pixel in width and calculate the corresponding hight for 2.4:1 ratio with a 1.5x scope: -vf crop=1440:1440/2.4*1.5 get that up to 1080p in width:

#!/bin/bash
for file in *.mov; do
    ffmpeg -i "$file" -vf crop=1440:1440/2.4*1.5,scale=1920:1920/2.4,setsar=1:1,setdar=2.4:0,unsharp \
    -c:v libx264 -preset ultrafast -crf 35 -c:a aac -b:a 128k \
    -strict -2 "$file".mp4  
done;

Extract 2600 pixel in width and calculate the corresponding hight for 2.6:1 ratio with a 2x scope: -vf crop=2600:2600/2.6*2

Denoising

Does not work with RAW Source Material.

*Work in Progress*

Inspired by: http://www.personal-view.com/talks/discussion/10637/4k-downscaling-progress-topic

ffmpeg denoise script for BMPCC, tested for already graded ISO800 Footage

 ffmpeg -i "$1" \
  -filter:v hqdn3d=2.0:2.0:7.0:8.0
  -c:v prores_ks -profile:v 2 \
  -c:a copy \
  -c:s null \
  -c:d copy \
  -c:t copy \
  "$1_dn_ProRes.mov"

ffmpeg scale and denoise for GH4 UHD tested with ISO 800

 ffmpeg -i "$1" \
  -filter:v hqdn3d=3.0:3.0:5.0:5.0 \
  -vf scale=1920:1080 \
  -q 0 -quant_mat hq \
  -c:v prores_ks -profile:v 1 \
  -c:a copy \
  -c:s copy \
  -c:d copy \
  -c:t copy \
  "$1_hqdn3d_ProRes.mov"

ffmpeg scale UHD to HD 444 and denoise for GH4 UHD and defish 7,5mm Samyang tested with ISO 800

 ffmpeg -i "$1"  \
  -filter_complex 'extractplanes=y+u+v[y][u][v]; [u] scale=w=3840:h=2160:flags=print_info+neighbor+bitexact [us]; [v] scale=w=3840:h=2160:flags=print_info+neighbor+bitexact [vs]; [y][us][vs]mergeplanes=0x001020:yuv444p,format=pix_fmts=yuv444p10le,hqdn3d=3:3:5:5,frei0r=lenscorrection:0.5:0.5:0.16:0.6,scale=w=1920:h=1080:flags=print_info+bicubic+full_chroma_inp+full_chroma_int'  \
  -sws_dither none   \
  -q 0 -quant_mat hq  \
  -c:v prores_ks  \
  -profile:v 4  \
  -c:a copy   \
  -c:s copy  \
  -c:d copy   \
  -map 0  \
  "$2/$1"

Deinterlace & Upscaling

Deinterlace & Upscale any kind of found footage to ProRes at 1920×1080 resolution

ffmpeg -i InFile.avi -codec:v prores_ks -profile:v 2 -codec:a pcm_s16le \
-filter_complex asetnsamples=n=16384:p=0 -vf "yadif, scale=1920:1080" 
\ OutputProRes.mov
postproduction/ffmpegconversionworkflows.txt · Last modified: 2015/07/07 18:46 by 81.221.48.139