tanktoo
tanktoo

Reputation: 301

Video created with opencv, not playable in android

I am creating a simple video from .png files with a python script. The created video is playing fine on my computer but I want to sent it to some android devices (e.g. with Whatsapp) and play it there. But I cannot manage to find any codec that is working. Of course I can install VLC on android but I like to have it playing without additional apps.

Please have a look at my source code.

frame = cv2.imread(path.join(directory, images[0]))
height, width, layers = frame.shape
video = cv2.VideoWriter(directory + "/test.avi", cv2.VideoWriter.fourcc('M', 'J', 'P', 'G'), 5, (width,height))

for image in images:
    video.write(cv2.imread(path.join(directory, image)))

I tried so far .avi and .mp4 endings, MJPG, DIVX and some I cannot remember. I am working on a Windows System using pycharm with a python3 venv where I installed cv2 with pycharm. I also tried it with H264 but there is a dll file missing. I downloaded it but it is not working when I copy the file into my project or into the cv2 folder in the venv folder.

Maybe someone has a simple solution to solve this. Thanks!

Upvotes: 1

Views: 887

Answers (1)

tanktoo
tanktoo

Reputation: 301

I solved it. Thanks to @Morrison Chang for the list. H264 is the right codec. The provided .dll file has to be at the same place where the executed "python.exe" is.

Upvotes: 1

Related Questions