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):
    return sp.Popen(['ffmpeg',
                     '-nostats',
                     '-loglevel', '0',
                     '-y',
                     '-vstats_file', vstats_path,
                     '-i', infile,
                      outfile]).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()


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

start() is the main function to use. If on_message is not passed, a default function is used. The on_done argument is optional. The initial_wait_time keyword argument can be used to specify a time to wait before processing the log.

The ffmpeg callback must return a PID (int). It is recommended to pass -nostats -loglevel 0 to your ffmpeg process. The ffmpeg callback also must pass -vstats_file given the path from the callback argument.

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.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file ffmpeg_progress-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: ffmpeg_progress-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.9

File hashes

Hashes for ffmpeg_progress-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8891c5b6febede96ff86e802d49ec43b9f92b17843b560544a7fde5d047809d2
MD5 959c08b5623698127cdae3af123a9d4a
BLAKE2b-256 6035843ae593551fb2d1ecb36f32318bf21d43631d51d416ec28260356a5b6ed

See more details on using hashes here.

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