mirror of
https://github.com/jlengrand/Ivolution.git
synced 2026-03-10 08:21:18 +00:00
Corrects the video codec bug.
Thanks to SO (once again), it appears that to be correct, the video has to have this relation : (channels * width) i a multiple of 4 The method has to be integrated into Facemovie_lib
This commit is contained in:
@@ -2,12 +2,41 @@
|
||||
import os
|
||||
import cv
|
||||
|
||||
|
||||
|
||||
def resizes_for_video_codec(frameSize):
|
||||
"""
|
||||
Searches for the closest couple of frameSize so that width*height is a multiple of 4 to avoid weird image encoding.
|
||||
"""
|
||||
try:
|
||||
x,y = frameSize
|
||||
except ValueError:
|
||||
print "ERROR: unknown format for frameSize "
|
||||
return (0, 0)
|
||||
|
||||
if not(isinstance(x, int)) or not(isinstance(x, int)):
|
||||
print "ERROR: method expects two integers"
|
||||
return (0, 0)
|
||||
|
||||
while ((x * 3) % 4) != 0:
|
||||
x += 1
|
||||
|
||||
print frameSize
|
||||
print x, y
|
||||
|
||||
return (x, y)
|
||||
|
||||
in_dir = "../data/inputs/sample-test"
|
||||
out = "output.avi"
|
||||
|
||||
|
||||
# loading images, create Guys and store it into guys
|
||||
frameSize = (652, 498)
|
||||
frameSize = (1257, 499)
|
||||
|
||||
|
||||
frameSize = resizes_for_video_codec(frameSize)
|
||||
|
||||
|
||||
#frameSize = (453, 325)
|
||||
fourcc = cv.CV_FOURCC('F', 'M', 'P', '4')
|
||||
my_video = cv.CreateVideoWriter(out,
|
||||
|
||||
Reference in New Issue
Block a user