Cannot display ffprobe information from youtube properly - python

I am trying to grab information from youtube streams using ffprobe and python. I could display offline video information properly on python, cannot do the same from youtube live streams.
os.system("ffprobe -hide_banner -stats -v quiet -pretty -show_entries format=size,duration:stream=filename,index,codec_type,codec_name,profile,bit_rate,width,height -of compact -i https://www.youtube.com/watch?v=QzsfLSP6hkI")
showing an error
Argument 'https://www.youtube.com/watch?v=QzsfLSP6hkI' provided as input filename, but 'quiet' was already specified.

Related

Combine many videos in list using FFMPEG

I have a bunch of videos that are MP4s with different FPS, resolution, aspect ratio, basically everything. I'm trying to see if its possible to use FFMPEG to combine them into a single 1080/720 video using a single command, or at least make them all similar format so that combining is easy. Speed and less CPU power would be preferred but I'm in no rush and
I found this command on another stack overflow question:
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -filter_complex \
"[0:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1,setsar=1,fps=30,format=yuv420p[v0];
[1:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1,setsar=1,fps=30,format=yuv420p[v1];
[2:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1,setsar=1,fps=30,format=yuv420p[v2];
[v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" -c:v libx264 -c:a aac -movflags +faststart output.mp4
The problem is that I have more that 3 videos to combine and I don't know how to work this command with more, I have an entire list of videos in a list.txt file structured as such:
file './videos/video1.mp4'
file './videos/video2.mp4'
file './videos/video3.mp4'
The code that somewhat worked for me was this
ffmpeg -safe 0 -f concat -i list.txt -c copy output.mp4
It combines the video well and fairly fast but I get weird glitches with the audio and the resolution is weird (I'm hoping for 1920x1080). I suspect this is due to the varying attributes of each video but I'm not sure. I'm familiar with Python but I have found no Python script that can do what I ask. If there any way to combine my list into one video (using FFMPEG or not) reliably?

Got incorrect audio duration from ffmpeg

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.

How to use ffmpeg to extract frames from video and read as a list of images in python in memory without writing files

At my application server, I have a stream of Webm chunks coming from browsers that users record live videos. I want to analyze each frame simultaneously. So I used python to create a generator yielding the Webm file binaries to feed into ffmpeg. I use the command python convert.py | ffmpeg -i pipe: -r 1 output%3d.jpg to create a set of frames files. (The convert.py is just the generator to yield binary webm data for ffmpeg).
My question is that how can I make the ffmpeg output to a new pipe that in python I can read as a list of images directly?
Try:
python convert.py | ffmpeg -i pipe: -r 1 -c:v mjpeg -f image2pipe pipe: | python example.py

Unknown format from Picamera recording

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.

Pygame Error: Mpeg video will not play

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.

Categories