I have been using my RaspberryPi 3 model B with the Picamera to record videos.
I saw in the RaspberryPi website that the default video format that you get from capturing video is h264, however when I use the camera, the file created appears as fyle type unknown.
To capture I tried both the basic command line
raspivid -o video -t 10 #for a 10s video
or a small programm using the PiCamera.start_recording (wich i believe lets you choose the format of the output file) but I still get these not known format files.
If it helps (doubtful) I try to read the recorded files with omxplayer and the footage is displayed at roughly twice the speed it should.
You're not specifiying the h264 extension - without that omxplayer doesn't know what type of video format it is - unless you can suggest what to try via command line
Try:
raspivid -o video.h264 -t 10 #for a 10s video
There's plenty of online help and examples for raspivid
Also - you may have to wrap your h264 file in mp4 "box" to play it
Here's one suggestion on how to do this wrapping using MP4Box
sudo apt-get update
sudo apt-get install -y gpac
Once installed use the following command to wrap your H264 video in an MP4 container file. This allows most media players to play the video.
MP4Box -fps 30 -add video.h264 video.mp4
This will give you a nice video at 30 frames per second that should play in most modern media players.
Related
I used an ffmpeg command to export parts of an audio clip:
ffmpeg -i {path} -acodec copy -ss {start_time} -to {end_time} {output_path}
Unfortunately, this has the side effect of not changing the time duration in the file's details section, making many programs I use think the time of the cut audio files is much more than it really is.
Is there a way to either make ffmpeg change the duration, or find a command in python that can change an audio file's "length" stat so I can do it manually? I couldn't find any way online.
Thanks.
The idea was to use my RBP as a baby monitor that would stream over the network so that I could watch from any computer/TV at home.
1.To begin with, I was trying to stream a video from my raspberry pi to be access from another PC using VLC Network Stream.
It worked using this command line :
raspivid -o - -t 0 -hf -w 800 -h 400 -fps 24 |cvlc -vvv stream:///dev/stdin --sout'#standard{access=http,mux=ts,dst=:8160}' :demux=h264
After that i wanted it to start from a python program.
Done using that simple program:
from subprocess import call
call(["raspivid -o - -t 0 -hf -w 800 -h 400 -fps 24 |cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8160}' :demux=h264"])
Now it needed to launch the python program at startup. So I created a .desktop file in autostart:
mkdir /home/pi/.config/autostart
nano /home/pi/.config/autostart/autostartCamStream.desktop
autostartCamStream.desktop :
[Desktop Entry]
Type=Application
Name=AutostartCam
Exec=/usr/bin/python3 /home/pi/startCamStream.py
Everything is doing exactly what it is supposed to do! On reboot, the startCamStream.py start streaming and I can access it over my VLC player on my PC on port 8160.
But the problem is that on the Raspberry pi, the stream is full screen and I cant close it or do anything else... Ive try CRTL+Q, ATL+F4 etc. Nothing is working (I cant even see a terminal, the recording seems to be in front of every other programs) Before the autostart, I was closing the stream using CTRL-C since it was running in a terminal.
As I only have basic knowledge in linux environment, I was wondering if anyone has a pretty obvious solution I wouldn't know about... Thank you !
just adding -n to the raspivid command solved the problem.
-n stops the video being previewed.
I'm working on a Voice Assistant based on the Raspberry Pi (2 B+), and one of the functions I was looking to integrate was to play my playlist whenever I want it to.
I tried out using youtube-dl and mplayer within os.system like so, inspired by this answer
youtube-dl --playlist-random -o - "https://www.youtube.com/playlist?list=PLFepKcct_CJG0mu-nb-HvQ52FRKTEO6hT" | mplayer -
I understand that youtube-dl will download the video and send the stream piped to mplayer which will play the music.
What is happening is that the code is playing the first video flawlessly, but as soon as the video ends, mplayer just stops at whatever was the last frame. It's not continuing to the next video even though I can see youtube-dl is to downloading videos in the playlist.
Is there any way I can play multiple songs in a playlist using youtube-dl seamlessly?
You can try omxplayer instead...
try this small sh script with named pipe
first mkfifo /home/midia/omxfifo
then save this script below script.sh and chmod +x:
#!/bin/bash
FileToPlay="$1"
for LINK in $(cat $FileToPlay)
do
echo "Playing : $LINK"
omxplayer -o hdmi --vol -2 $(youtube-dl -g -f mp4 $LINK)</home/midia/omxfifo>/dev/null 2>&1 & echo -n '' >/home/midia/omxfifo
echo "$LINK" >> watched.log
done
call the script like this:
./script.sh file_with_yt_url.txt
I can show videos all day with omxplayer, no problem. Showing a simple jpeg, apparently is rocket science. I've spent days with fbi library and it doesn't work very well. I'm running buster raspbian (and same issues on stretch raspbian) and programming in Python.
Simple: I want to display picture for an arbitrary amount of time then either show another or return the display to normal. No such luck.
sudo fbi -T 2 -a --noverbose -1 -t 30 foo.png
I do this with:
subprocess.Popen().
I use:
"-T 2"
because it is HDMI. If I don't do -1 and run fbi again, bad news. It appears to cache each image and will display each again like I'm building a playlist. But if I do "-1" it will not block but will insist on showing the image for the full -t time (30 secs above). There seems to be no way to "send" it a keyboard key to quit before the -t time. I can use the physical keyboard. Since it doesn't block, you'd think I could always do a
"sudo killall -9 fbi"
but doing so while an image is still on the screen freezes the image there.
So any other python library or shell command for display an image? Anyway to get this fbi to actually work?? Thanks much!!
Try using "feh",
something like:
feh --hide-pointer -x -q -B black -g 1280x800 "image.jpg"
with subprocess.Popen or os.system
Or if you want to use only fbi, with python,
Use:
import os
and then use os.system in front of the code you are using, works with python code.
Something like this has worked for me:
os.system('sudo fbi -a /dev/fb0 --noverbose -T 2 image.png')
picture block before sequence header block is the error I get when i try to play my mpeg video file in pygame.
i have no idea how to fix this:
global movie
movie = pygame.movie.Movie("movie.mpeg")
if movie.has_video():
screen = pygame.display.set_mode(movie.get_size())
movie_length = movie.get_length()
movie.set_volume(0.99)
movie.set_display(screen)
movie.play()
This is all I have to play the movie. I believe this should play. Though the
"picture block before sequence header block" error pops up.
What is wrong?
Convert the video using ffmpeg.
To install ffmpeg follow this youtube video and link mentioned in it.
**https://www.youtube.com/watch?v=3lSb-jLEJ**JM
After installation convert the video using this command:-
ffmpeg -i input.mp4 -target ntsc-vcd -vcodec mpeg1video -an output.mpg
I had this error myself, and I fixed it using ffmpeg and converting my .mpg video with this command:*
ffmpeg -i input.mp4 -target ntsc-vcd -vcodec mpeg1video -an output.mpg
* This answer was found on the Linux Distro Community forum.