Very small black video at the beginning after using ffmpeg to crop video?

198 Views Asked by At

So I have a video that I am trying to crop with ffmpeg and does crop successfully, but the cropped video has about 1 second of black video at the start. blackFrame video

I assume it is my lack of knowledge of how to set the right codec or I am splitting a frame somehow.

This is the block of code on how I am cropping my video.

import subprocess
import time


def crop_video(original_vid_name, cropped_vid_name, start_time, end_time):
    start_time_timeformat = time.strftime('%H:%M:%S', time.gmtime(start_time))
    end_time_timeformat = time.strftime('%H:%M:%S', time.gmtime(end_time))
    ffmpeg_timecrop_cmd = "-ss {} -to {}".format(start_time_timeformat, end_time_timeformat)
    ffmpeg_quality_codec_cmd = '-q:v 10 -crf 18 -c:v copy -c:a copy -avoid_negative_ts make_zero'
    ffmpeg_cmd = 'ffmpeg {} -i {} {} {}'.format(
        ffmpeg_timecrop_cmd, original_vid_name, ffmpeg_quality_codec_cmd, cropped_vid_name
    )

    subprocess.call(ffmpeg_cmd, shell=True)

Please let me know what I am doing wrong?

0

There are 0 best solutions below