T
T
trintrintrava2020-11-23 17:07:39
Python
trintrintrava, 2020-11-23 17:07:39

How to log the ffmpeg-python library process?

I work with the ffmpeg-python library, I need to log the process, errors, etc., etc., preferably being able to specify the folder and file where everything will be written

now, the code is like this:

(ffmpeg
    .input(input_path + str(f))
    .output(output_path + str(id) + '.mp4', acodec='aac', vcodec='libx264')
    .run()
    # .run(capture_stderr=True)
    # .run(quiet=True)
    )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2020-11-23
@trintrintrava

Use standard logger

import os
import pathlib
import logging

LOG_DIR = os.path.join(pathlib.Path(__file__).parent.absolute(), 'logs')

if not os.path.exists(LOG_DIR):
    os.makedirs(LOG_DIR)

logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    datefmt='%m-%d %H:%M',
    filename=os.path.join(LOG_DIR, 'mylog.log'),
    filemode='w'
)
logging.info(f'Input file: {input_pat}/{str(f)}')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question