Skip to content
Permalink
Browse files

Fix crop-video scale argument

  • Loading branch information
KMielnik committed May 23, 2020
1 parent ebb4b93 commit 264139d07a4e167217da0e77463abe6c7af24c14
Showing with 6 additions and 3 deletions.
  1. +6 −3 crop-video.py
@@ -46,7 +46,7 @@ def join(tube_bbox, bbox):
return (xA, yA, xB, yB)


def compute_bbox(start, end, fps, tube_bbox, frame_shape, inp, increase_area=0.1):
def compute_bbox(start, end, fps, tube_bbox, frame_shape, inp, image_shape, increase_area=0.1):
left, top, right, bot = tube_bbox
width = right - left
height = bot - top
@@ -67,14 +67,16 @@ def compute_bbox(start, end, fps, tube_bbox, frame_shape, inp, increase_area=0.1
end = end / fps
time = end - start

return f'ffmpeg -i {inp} -ss {start} -t {time} -filter:v "crop={w}:{h}:{left}:{top}, scale=256:256" crop.mp4'
scale = f'{image_shape[0]}:{image_shape[1]}'

return f'ffmpeg -i {inp} -ss {start} -t {time} -filter:v "crop={w}:{h}:{left}:{top}, scale={scale}" crop.mp4'


def compute_bbox_trajectories(trajectories, fps, frame_shape, args):
commands = []
for i, (bbox, tube_bbox, start, end) in enumerate(trajectories):
if (end - start) > args.min_frames:
command = compute_bbox(start, end, fps, tube_bbox, frame_shape, inp=args.inp, increase_area=args.increase)
command = compute_bbox(start, end, fps, tube_bbox, frame_shape, inp=args.inp, image_shape=args.image_shape, increase_area=args.increase)
commands.append(command)
return commands

@@ -153,3 +155,4 @@ def process_video(args):
for command in commands:
print (command)


0 comments on commit 264139d

Please sign in to comment.
You can’t perform that action at this time.