Skip to main content

Automatically Demux tracks from media-files

Project description

Automatic Demuxer

Package to demux media-files into single file formats to be used elsewhere.

Video tracks are only supported currently

Developed by Jessie Wilson (2022)

Install

pip install AutomaticDemuxer

If using Linux you must also install MediaInfo

sudo apt install mediainfo

Uninstall

pip uninstall AutomaticDemuxer

Examples of How To Use

Video: Example with callback

from automatic_demuxer import AutoDemuxer


def callback_func(x):
    """
    AutoDemuxer will return a dictionary with keys 'output' and 'percent'
    "output" will always display the ffmpeg command line output
    "percent" will return None if there is no track duration OR when the job hasn't fully started/is finished
    "job_pid" will return a pathlike/string of the full path of the output filename
    """
    print(x["output"])
    print(x["percent"])
    print(x["job_pid"])

    # check if x["percent"] is not none before using output
    if x["percent"]:
        print(f"do something with {str(x['percent'])}")


demux = AutoDemuxer()
demux.video_demux(file_input=r"fileinput.mkv", callback=callback_func)


Video: Example without callback

When not using callback the FFMPEG output is automatically printed to console in the format of a string. This does not include percentage.

from automatic_demuxer import AutoDemuxer

demux = AutoDemuxer()
demux.video_demux(file_input=r"fileinput.mkv")


Video: Return status

from automatic_demuxer import AutoDemuxer

demux = AutoDemuxer()
demux.video_demux(file_input=r"fileinput.mkv")

# To print the return code
print(demux.status["return_code"])

# To print the output file name
print(demux.status["output_filename"])

# To print a completed status (completed internally by checking the output path name and getting a return code of 0)
# This will return "Ok" or "Error"
print(demux.status["status"])

Video Parameters

file_input String or Pathlike path to input file.

ffmpeg_path String or Pathlike path to ffmpeg.
Optional: Will raise an error if not found on path or defined

track_number Track number based off of ffmpeg stream selection or mediainfo's 'Stream identifier'.
Optional: Defaults to 0

suffix String to define the output ending suffix.
Optional: Defaults to "_out_"

insert_delay Bool to insert delay string into filename output if delay is detected.
Optional: Defaults to True

video_output_extension The output extension in the form of a string. e.g. "mkv" or ".mkv"
Optional: Defaults to "mkv"

callback Log callback progress to a variable instead of printing to console
Optional: Defaults to None

fallback_ext Extension in the form of a string. e.g. "mkv" or "mp4". Default is "mkv", if changed the program will fall back to what ever extension is selected
Optional: Defaults to "mkv"

Project details


Download files

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

Source Distribution

AutomaticDemuxer-1.34.tar.gz (7.4 kB view details)

Uploaded Source

File details

Details for the file AutomaticDemuxer-1.34.tar.gz.

File metadata

  • Download URL: AutomaticDemuxer-1.34.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.8

File hashes

Hashes for AutomaticDemuxer-1.34.tar.gz
Algorithm Hash digest
SHA256 1c10a58f4baed14b8ab341af1b11acf2f956f85843f4f96ea1d5d143a16446d9
MD5 cac35ac117c6d978a4d5159574e87e63
BLAKE2b-256 0ffa417b8a161e636fde32b2de28b787071cf83252a2d56d8da8937dcd6aba27

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