0

I made this code to open the pi camera and to close it. When i run the code it makes .h264 videos but i can't play these on windows. Heres the code

import picamera
from time import *
from subprocess  import call 

with picamera.PiCamera() as camera:
    camera.start_recording("beepvid.h264")
    sleep(5)
    camera.stop_recording()
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
  • Then just use a random online converter – Mia Aug 29 '18 at 08:36
  • Also a good videoplayer should be able to play it. And a duplicate to https://stackoverflow.com/questions/45040261/python-3-auto-conversion-from-h264-to-mp4 – Bernhard Aug 29 '18 at 08:38
  • Possible duplicate of [(python 3) Auto-Conversion from .h264 to .mp4](https://stackoverflow.com/questions/45040261/python-3-auto-conversion-from-h264-to-mp4) – Bernhard Aug 29 '18 at 08:38

2 Answers2

1

Another simpler way is to simply make it record to beepvid.mp4

0

This is really a question for the rasberry pi stack but its ok!

If you type in cd (where ever the file is stored) and type ‘omxplayer (yourvid).h264, it will show you the video. The best thing for you to do is to use a command called ‘MP4Box’.

You can do this with the CMD but ill tell you how to do it in Python. Below your current code add the following.

command = "MP4Box -add beepvid.h264 beepvid.mp4"
call([command], shell=True)
print("vid conv")

This will convert the ‘beepvid.h264’ to mp4 and you can install VLC player if you want to play it. The way to install VLC player is the following: sudo apt-get install vlc. I suggest you type in ‘ sudo apt-get update’ and ‘sudo apt-get upgrade’ before hand

I hope this has answered your question.

Neamus
  • 198
  • 1
  • 3
  • 16
  • 1
    Worth mentioning that VLC will play .h264 files, too. At least mine plays some h264 baseline. I guess that means it could also do the conversion. – Pam Aug 29 '18 at 09:08