Elimde dikey videolar var bunların arkasına siyah resim ekleyip dikey videoyu siyah resmin ortasına ekleyip yatay video oluşturmam lazım.
Nasıl Yapabilirim.
Python Dikey Videoyu Nasıl Yataya Çeviririm Ffmpeg ile vs
2
●82
- 26-02-2024, 20:07:04Benzer bir işlem için chatgptye sormuştum. Hallediyor.
import cv2 import numpy as np def convert_to_16_9_vertical_to_horizontal(input_video_path, output_video_path): # Giriş videosunu yükle cap = cv2.VideoCapture(input_video_path) if not cap.isOpened(): print("Giriş videosu yüklenemedi!") return # Giriş videosunun özelliklerini al frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) fps = cap.get(cv2.CAP_PROP_FPS) # Yatay format için yeni boyutları hesapla (16:9) target_width = int(frame_height * (16 / 9)) target_height = frame_height # Yeni video dosyası oluştur fourcc = cv2.VideoWriter_fourcc(*'mp4v') out = cv2.VideoWriter(output_video_path, fourcc, fps, (target_width, target_height)) # Siyah arka plan oluştur black_bg = np.zeros((target_height, target_width, 3), dtype=np.uint8) while True: ret, frame = cap.read() if not ret: break # Dikey görüntüyü yatayda ortala start_x = (target_width - frame_width) // 2 end_x = start_x + frame_width black_bg[:, start_x:end_x] = frame # Yeni çerçeveyi yaz out.write(black_bg) # Kullanılan kaynakları serbest bırak cap.release() out.release() cv2.destroyAllWindows() print("Dönüşüm tamamlandı. Yeni video:", output_video_path) # Örnek kullanım input_video_path = "dikey_video.mp4" output_video_path = "yatay_video.mp4" convert_to_16_9_vertical_to_horizontal(input_video_path, output_video_path)