0

I am trying to increase video size from 256x256 to 512x512 or higher efficiently.

I used OpenCV and srgan.

srgan is taking 13 minutes to increase size of a 16 second video 30 fps. OpenCV image resize is taking around 40 sec to achieve it. But problem is when i convert extracted frames back to video using both methods, I see no difference in size of final output video. OpenCV code is

x = img.resize(size=(img.size[0]*2, img.size[1]*2), resample=Image.BICUBIC)

Original size: (480, 854, 3)
After using OpenCV code: (960, 1708, 3)

How can I efficiently modify the resolution?

Red
  • 26,798
  • 7
  • 36
  • 58
Rahul Chauhan
  • 125
  • 1
  • 7

1 Answers1

1

You can try:

import cv2

cap = cv2.VideoCapture("video.mp4")

fourcc = cv2.VideoWriter_fourcc(*"XVID")
fps = cap.get(cv2.CAP_PROP_FPS)
w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) * 2
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) * 2

writer = cv2.VideoWriter("out.mp4", fourcc, fps, (w, h))

success, img = cap.read()
while success:
    writer.write(cv2.resize(img, (w, h)))
    success, img = cap.read()

cap.release()
writer.release()
Red
  • 26,798
  • 7
  • 36
  • 58