Skip to main content

Get progress information for an ffmpeg process.

Project description

ffmpeg-progress

This script is based on the work of Rupert Plumridge.

Basic use

import subprocess as sp
import sys

from ffmpeg_progress import start


def ffmpeg_callback(infile: str, outfile: str, vstats_path: str):
    p = sp.Popen(['ffmpeg',
                  '-y',
                  '-vstats_file', vstats_path,
                  '-i', infile,
                  outfile], stdout=sp.PIPE, stderr=sp.PIPE)
    return p.pid


def on_message_handler(percent: float,
                       fr_cnt: int,
                       total_frames: int,
                       elapsed: float):
    sys.stdout.write('\r{:.2f}%'.format(percent))
    sys.stdout.flush()


def on_done_handler():
    print('')


start('my input file.mov',
      'some output file.mp4',
      ffmpeg_callback,
      on_message=on_message_handler,
      on_done=on_done_handler,
      wait_time=1)  # seconds

start() is the main function to use. If on_message is not passed, a default function is used.

ffprobe

An ffprobe front-end function is included. Usage:

from ffmpeg_progress import ffprobe


ffprobe('my file.mp4')  # returns a dict()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ffmpeg_progress-0.0.3-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page