picamera2 icon indicating copy to clipboard operation
picamera2 copied to clipboard

[HOW-TO] How do i tell FfmpegOutput where to save my mp4 ?

Open 8JupiterMoll8 opened this issue 3 years ago • 2 comments

Hello there,

I'm trying to save audio and video in mp4 format using the following code:

output = FfmpegOutput('test.mp4', audio=True)

However, I want to specify a different location for the output file. I tried using the following code, hoping to save the file in the /static/videos directory:

output = FfmpegOutput('/static/videos/test.mp4', audio=True)

Unfortunately, it doesn't seem to be working. Do you have any idea what might be causing this issue?

import time
from picamera2 import Picamera2
from picamera2.encoders import H264Encoder
from picamera2.outputs import FfmpegOutput

picam2 = Picamera2()
video_config = picam2.create_video_configuration()
picam2.configure(video_config)

encoder = H264Encoder(5000000)
output = FfmpegOutput('test.mp4', audio=True)

picam2.start_recording(encoder, output)
time.sleep(10)
picam2.stop_recording()

8JupiterMoll8 avatar May 05 '23 16:05 8JupiterMoll8

I solve it: output = FfmpegOutput('/videos/test.mp4', audio=True)

My main.py was not in the root.... main.py *videos

8JupiterMoll8 avatar May 07 '23 10:05 8JupiterMoll8

Thx. For this great Picamera Library.

8JupiterMoll8 avatar May 07 '23 10:05 8JupiterMoll8