ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

how to specify output logs

Open ajeema opened this issue 5 years ago • 1 comments

I'm writing an app in Django and just deploy the local environment to Heroku. The one thing that stopped working was the printing of the ffprobe logs. I was getting them by adding '-report' to _probe.py. However, it is not printing them when in Heroku for some reason. My function is this:

def get_input_specs(filename):
    analyzed_file = ffmpeg.probe(filename)
    get_input_specs.video_info = next(s for s in analyzed_file['streams'] if s['codec_type'] == 'video')
    get_input_specs.width = int(get_input_specs.video_info['width'])
    get_input_specs.codec_name = str(get_input_specs.video_info['codec_name'])
    get_input_specs.codec_type = str(get_input_specs.video_info['codec_type'])
    get_input_specs.codec_time_base = str(get_input_specs.video_info['codec_time_base'])
    get_input_specs.codec_tag_string = str(get_input_specs.video_info['codec_tag_string'])
    get_input_specs.sample_aspect_ratio = str(get_input_specs.video_info['sample_aspect_ratio'])
    get_input_specs.display_aspect_ratio = str(get_input_specs.video_info['display_aspect_ratio'])
    get_input_specs.pix_fmt = str(get_input_specs.video_info['pix_fmt'])
    get_input_specs.level = int(get_input_specs.video_info['level'])
    get_input_specs.chroma_location = str(get_input_specs.video_info['chroma_location'])
    get_input_specs.r_frame_rate = str(get_input_specs.video_info['r_frame_rate'])
    get_input_specs.start_pts = int(get_input_specs.video_info['start_pts'])
    get_input_specs.duration_ts = int(get_input_specs.video_info['duration_ts'])
    get_input_specs.duration = float(get_input_specs.video_info['duration'])
    get_input_specs.bit_rate = int(get_input_specs.video_info['bit_rate'])
    get_input_specs.codec_long_name = str(get_input_specs.video_info['codec_long_name'])
    get_input_specs.video_profile = str(get_input_specs.video_info['profile'])
    get_input_specs.height = int(get_input_specs.video_info['height'])
    get_input_specs.num_frames = int(get_input_specs.video_info['nb_frames'])
    return get_input_specs.video_info,\
           get_input_specs.codec_name,\
           get_input_specs.codec_type,\
           get_input_specs.codec_time_base,\
           get_input_specs.codec_tag_string,\
           get_input_specs.sample_aspect_ratio,\
           get_input_specs.display_aspect_ratio,\
           get_input_specs.pix_fmt,\
           get_input_specs.level,\
           get_input_specs.chroma_location,\
           get_input_specs.r_frame_rate,\
           get_input_specs.start_pts,\
           get_input_specs.duration_ts,\
           get_input_specs.duration,\
           get_input_specs.bit_rate, \
           get_input_specs.codec_long_name, \
           get_input_specs.video_profile,\
           get_input_specs.width, \
           get_input_specs.height, \
           get_input_specs.num_frames

Is there a way to get the logs within this function or any other suggestion? I need them in order to debug why it is failing when handling files between Heroku and ffprobe. Thank you

ajeema avatar Jul 07 '20 03:07 ajeema

def probe(filename, cmd='ffprobe', **kwargs):
    """Run ffprobe on the specified file and return a JSON representation of the output.

    Raises:
        :class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code,
            an :class:`Error` is returned with a generic error message.
            The stderr output can be retrieved by accessing the
            ``stderr`` property of the exception.
    """
    args = [cmd, '-show_format', '-show_streams', '-of', 'json','-report']
    args += convert_kwargs_to_cmd_line_args(kwargs)
    args += [filename]

    p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = p.communicate()
    if p.returncode != 0:
        raise Error('ffprobe', out, err)
    return json.loads(out.decode('utf-8'))

You need to edit the source file(_probe.py) and add '-report' in args

HaochenJin0325 avatar Dec 23 '24 08:12 HaochenJin0325