FFmpeg - the core command app of open source transcoder

  • free and available as command line software for windows, mac, linux
  • input video format: 3GP, AVI, FLV, Matroska, MP4, MPEG-PS, Ogg, QuickTime, SVCD, TS, TOD, VCD, WMV
  • output video format: 3GP, AVI, Blu-ray, DVD, FLV, MKV, MP4, MPEG-PS, Ogg, mov, super VCD, TS, VCD, Webm, WMV

Common Convertion

  • MTS 50i interlaced video to progress video 50p (ref: link)
    ffmpeg -i in.MTS -vf yadif=1 -acodec ac3 -ab 192k -vcodec mpeg4 -f mp4 -y -qscale 0 out.mp4
  • image sequence to mp4 in cmd (25fps, FHD size, pic.0001.png naming, H264, quality 15-25)
    ffmpeg -r 25 -f image2 -s 1920x1080 -i pic.%04d.png -vcodec libx264 -crf 25  -pix_fmt yuv420p test.mp4
  • image sequence to MOV with start frame detection (e.g h264 mov, prores 422)
    • h264 mov
      import os,glob,shlex,subprocess
      imgSeqPath = 'D:/ExamplePathRoot/ExampleName/ExampleVersion/example.%04d.exr' # 0001 format image names
      movPath = 'D:/OutputMov/ExampleName/example.mov'
       
      file_list = glob.glob( os.path.join(os.path.dirname(imgSeqPath), re.sub('\.?%0\d+d$', '*', base) + ext ))
      if len(file_list) == 0:
          return
      prefix, ext = os.path.splitext(os.path.basename(file_list[0]))
      start_number = re.findall('\d+$', prefix)[0]
      enc = 'D:/toolPath/ffmpeg.exe -y -r 24 -start_number {0} -i "{1}" -an -vcodec libx264 -preset slow -crf 22 -threads 0 "{2}"'.format(start_number, imgSeqPath, movPath)
      subprocess.Popen(shlex.split(enc), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    • proRes422
      # profile: 0 proxy, 1 LT, 2 SQ, 3 HQ
      # pix format: yuv422p10le , for 444, use yuva444p10le
      # -qscale:v 11: best 0-32 worst
      # ref: https://trac.ffmpeg.org/wiki/Encode/VFX
      enc = 'D:/toolPath/ffmpeg.exe -y -r 24 -start_number %s -i "%s" -an -c:v prores_ks -profile:v 2 -pix_fmt yuv422p10le -vendor ap10 "%s"' % (start_number, imgSeqPath, movPath)