Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How do I read a video's length/duration ?
31 janvier, par DnKHow can I batch generate .edl files for a folder of videos with different run times? I need to skip an exact amount of seconds from the start and another from the end. Videos have different runtimes. I can make .edl files for skipping the intro but need a way to read the video runtime to skip the last 60 or 90 seconds.
Edit decision list format:
0:00:00 0:01:20. 3
If the video is 40 minutes 30 seconds the edit decision list skipping 80 seconds from the start and 90 seconds from the end should be:
0:00:00 0:01:20. 3 0:39:00 0:40:30. 3
-
How to use the video datastreaming I get from nginx server ?
31 janvier, par Jennie TsaiI have three nodes in my network:
dataServer --- node1 --- node2
. My video data "friends.mp4" is saved on dataServer. I started both dataServer and node2 as rtmp-nginx servers. I use ffmpeg on node1 to pull datastreaming on dataServerand and push the converted datastreaming to the application "live" on node2. Here's my configuration of nginx.conf for node2.worker_processes 1; events { worker_connections 1024; } rtmp { server { listen 1935; chunk_size 4000; application play { play /usr/local/nginx/html/play; } application hls { live on; hls on; hls_path /usr/local/nginx/html/hls; hls_fragment 1s; hls_playlist_length 4s; } application live { live on; allow play all; } } }
I want to run this python code to recognize the faces in friends.mp4:
import cv2 vid_capture=cv2.VideoCapture("rtmp://127.0.0.1:1935/live") face_detect = cv2.CascadeClassifier('./haarcascade_frontalface_default.xml') if (vid_capture.isOpened() == False): print("Error opening the video file") else: fps = vid_capture.get(5) print("Frames per second : ", fps,'FPS') frame_count = vid_capture.get(7) print('Frame count : ', frame_count) while(vid_capture.isOpened()): ret, frame = vid_capture.read() if ret == True: gray = cv2.cvtColor(frame, code=cv2.COLOR_BGR2GRAY) face_zone = face_detect.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=3) for x, y, w, h in face_zone: cv2.rectangle(frame, pt1 = (x, y), pt2 = (x+w, y+h), color = [0,0,255], thickness=2) cv2.circle(frame, center = (x + w//2, y + h//2), radius = w//2, color = [0,255,0], thickness = 2) cv2.imshow('Frame', frame) key = cv2.waitKey(50) if key == ord('q'): break else: break vid_capture.release() cv2.destoryAllWindows()
But I can't do it because
cv2.VideoCapture
can not get the data streaming fromrtmp://127.0.0.1:1935/live
. Maybe it is because this path is not a file. How can I get the video streaming received by the nginx server and put it to my openCV model? Is there a way that I just access the dataStreaming received by the nginx server and make it a python object that openCV can use? -
How to convert multiple video files in a specific path outputvideo with the same video name
31 janvier, par Oussama GamerThe following code to converts a one video from mp4 to avi using ffmpeg
ffmpeg.exe -i "kingman.mp4" -c copy "kingman.avi"
I need to convert multiple videos in a specific path. "outputvideo" with the same video name
This is the my code that needs to be modified.
from pathlib import Path import subprocess from glob import glob all_files = glob('./video/*.mp4') for filename in all_files: videofile = Path(filename) outputfile = Path(r"./outputvideo/") codec = "copy" ffmpeg_path = (r"ffmpeg.exe") outputfile = outputfile / f"{videofile.stem}" outputfile.mkdir(parents=True, exist_ok=True) command = [ f"{ffmpeg_path}", "-i", f"{videofile}", "-c", f"{codec}", "{outputfile}",] process = subprocess.Popen( command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1, universal_newlines=True) process.communicate()
-
Cannot display ffprobe information from youtube properly
31 janvier, par KrishnaapI 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.
-
How do I chromakey an enclosed shape (or background) in ffmpeg ? [closed]
31 janvier, par JustAnotherCodemonkeyI have an animation with a fully contiguous 0xFFFFFF white background I want to remove. The issue is that the foreground contains the same exact color. These parts are all completely enclosed and contained within at least several pixels of a different shade at its weakest.
All I need is to be able to essentially, for each frame, make all pixels that are white and connected by white to 0,0, transparent. Chromakey and its siblings remove those bits from the foreground as well which is unacceptable and backgroundkey, well you can imagine how that goes.
I'm somewhat proficient with ffmpeg and can handle severe filter shenanigans, I've just thought about this for like 10 min and decided I seemingly don't have the creativity to piece together a clever solution. I just don't want to have to spend some time sitting down and manually writing out a program to do this frame-by-frame.