
Recherche avancée
Médias (91)
-
Valkaama DVD Cover Outside
4 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
Valkaama DVD Label
4 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Image
-
Valkaama DVD Cover Inside
4 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
1,000,000
27 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Demon Seed
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
The Four of Us are Dying
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (77)
-
Dépôt de média et thèmes par FTP
31 mai 2013, parL’outil MédiaSPIP traite aussi les média transférés par la voie FTP. Si vous préférez déposer par cette voie, récupérez les identifiants d’accès vers votre site MédiaSPIP et utilisez votre client FTP favori.
Vous trouverez dès le départ les dossiers suivants dans votre espace FTP : config/ : dossier de configuration du site IMG/ : dossier des média déjà traités et en ligne sur le site local/ : répertoire cache du site web themes/ : les thèmes ou les feuilles de style personnalisées tmp/ : dossier de travail (...) -
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
Gestion générale des documents
13 mai 2011, parMédiaSPIP ne modifie jamais le document original mis en ligne.
Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)
Sur d’autres sites (6109)
-
Broken pipe error when using FFmpeg stream camera video
14 septembre 2021, par Xiuyi YangI try to write frames captured from a my laptop camera and then stream these images with FFmpeg. This is my code :


import subprocess
import cv2
rstp_url = "rtsp://localhost:31415/stream"

# In my mac webcamera is 0, also you can set a video file name instead, for example "/home/user/demo.mp4"
path = 0
cap = cv2.VideoCapture(path)

# gather video info to ffmpeg
fps = int(cap.get(cv2.CAP_PROP_FPS))
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))

# command and params for ffmpeg
command = ['ffmpeg',
 '-y',
 '-f', 'rawvideo',
 '-vcodec', 'rawvideo',
 '-pix_fmt', 'bgr24',
 '-s', "{}x{}".format(width, height),
 '-r', str(fps),
 '-i', '-',
 '-c:v', 'libx264',
 '-pix_fmt', 'yuv420p',
 '-preset', 'ultrafast',
 '-f', 'flv',
 rstp_url]

# using subprocess and pipe to fetch frame data
p = subprocess.Popen(command, stdin=subprocess.PIPE)


while cap.isOpened():
 ret, frame = cap.read()
 if not ret:
 print("frame read failed")
 break

 # YOUR CODE FOR PROCESSING FRAME HERE

 # write to pipe
 p.stdin.write(frame.tobytes())



After run this code, the following error occurs :




Input #0, rawvideo, from 'pipe :' :
Duration : N/A, start : 0.000000, bitrate : 221184 kb/s
Stream #0:0 : Video : rawvideo (BGR[24] / 0x18524742), bgr24, 640x480, 221184 kb/s, 30 > tbr, 30 tbn, 30 tbc
rtsp ://localhost:31415/stream : Protocol not found
Traceback (most recent call last) :
File "rtsp.py", line 42, in 
p.stdin.write(frame.tobytes())
BrokenPipeError : [Errno 32] Broken pipe




Please help me fix this bug.



After reply by Rotem, I modidied code as below :


import subprocess
import cv2
import pdb 

rstp_url = "rtsp://localhost:31415/stream"

# In my mac webcamera is 0, also you can set a video file name instead, for example "/home/user/demo.mp4"
path = 0
cap = cv2.VideoCapture(path)

# gather video info to ffmpeg
fps = int(cap.get(cv2.CAP_PROP_FPS))
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))

# command and params for ffmpeg
command = ['ffmpeg',
 '-re',
 '-f', 'rawvideo', # Apply raw video as input - it's more efficient than encoding each frame to PNG
 '-s', f'{width}x{height}',
 '-pixel_format', 'bgr24',
 '-r', f'{fps}',
 '-i', '-',
 '-pix_fmt', 'yuv420p',
 '-c:v', 'libx264',
 '-bufsize', '64M',
 '-maxrate', '4M',
 '-rtsp_transport', 'udp',
 '-f', 'rtsp',
 #'-muxdelay', '0.1',
 rstp_url ]


# using subprocess and pipe to fetch frame data
p = subprocess.Popen(command, stdin=subprocess.PIPE)


while cap.isOpened():
 ret, frame = cap.read()
 if not ret:
 print("frame read failed")
 break

 pdb.set_trace()
 # YOUR CODE FOR PROCESSING FRAME HERE

 # write to pipe
 p.stdin.write(frame.tobytes())

 cv2.imshow('current_img', frame) # Show image for testing

 # time.sleep(1/FPS)
 key = cv2.waitKey(int(round(1000/fps))) # We need to call cv2.waitKey after cv2.imshow

 if key == 27: # Press Esc for exit
 break

p.stdin.close() # Close stdin pipe
p.wait() # Wait for FFmpeg sub-process to finish
cv2.destroyAllWindows() # Close OpenCV window



The error ocurs as below :




Connection to tcp ://localhost:31415 ?timeout=0 failed : Connection >refused
Could not write header for output file #0 (incorrect codec >parameters ?) : Connection refused
Error initializing output stream 0:0 —
Conversion failed !
c
Qt : Session management error : None of the authentication protocols >specified are supported.




-
Use FFmpeg for continuous streaming from other source
28 septembre 2017, par widggWe have an app that pipes its output, and its output is compress H264 data. The source of the data is from a 3d engine running in same app.
We can easily pipe the output in FFmpeg to save as mp4 or even m3u8.
It’s also possible to turn FFmpeg as a server to feed video files.
So our objective is to have FFmpeg read that data, convert into into mp4 or m3u8 internally and then stream so that it can be read in the web browser.
We don’t care about be able to replay some file, go back in time or whatever, we just care about the current value.
Is there a way to do that ? Or a similar solution that would allow some close to that.
Thanks
I guess, if it’s possible, it’s like wanting to stream your personal webcam into the web browser. Then you could connect to that and see what is happening at home or wherever your webcam is.
-
Why doesn't the ffmpeg output display the stream in the browser ? [closed]
10 mai 2024, par TebyyWhy is it that when I create a livestream in Python using ffmpeg, and then I open the browser and visit the page, the page keeps loading continuously, and in PyCharm logs, I see binary data ? There are no errors displayed, and the code seems correct to me. I even tried saving to a file for testing purposes, and when I play the video, everything works fine. Does anyone know what might be wrong here ?


Code :


def generate_frames():
 cap = cv2.VideoCapture(os.path.normpath(app_root_dir().joinpath("data/temp", "video-979257305707693982.mp4")))
 while cap.isOpened():
 ret, frame = cap.read()
 if not ret:
 break

 yield frame


@app.route('/video_feed')
def video_feed():
 ffmpeg_command = [
 'ffmpeg', '-f', 'rawvideo', '-pix_fmt', 'bgr24',
 '-s:v', '1920x1080', '-r', '60',
 '-i', '-', '-vf', 'setpts=2.5*PTS', # Video Speed
 '-c:v', 'libvpx-vp9', '-g', '60', '-keyint_min', '60',
 '-b:v', '6M', '-minrate', '4M', '-maxrate', '12M', '-bufsize', '8M',
 '-crf', '0', '-deadline', 'realtime', '-tune', 'psnr', '-quality', 'good',
 '-tile-columns', '6', '-threads', '8', '-lag-in-frames', '16',
 '-f', 'webm', '-'
 ]
 ffmpeg_process = subprocess.Popen(ffmpeg_command, stdin=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=-1)
 frames_generator = generate_frames()
 for frame in frames_generator:
 ffmpeg_process.stdin.write(frame)
 ffmpeg_process.stdin.flush()

 ffmpeg_process.stdin.close()
 ffmpeg_process.wait()

 def generate_video_stream(process):
 startTime = time.time()
 buffer = []
 sentBurst = False
 for chunk in iter(lambda: process.stderr.read(4096), b''):
 buffer.append(chunk)

 # Minimum buffer time, 3 seconds
 if sentBurst is False and time.time() > startTime + 3 and len(buffer) > 0:
 sentBurst = True
 for i in range(0, len(buffer) - 2):
 print("Send initial burst #", i)
 yield buffer.pop(0)

 elif time.time() > startTime + 3 and len(buffer) > 0:
 yield buffer.pop(0)

 process.poll()
 if isinstance(process.returncode, int):
 if process.returncode > 0:
 print('FFmpeg Error', process.returncode)

 break

 return Response(stream_with_context(generate_video_stream(ffmpeg_process)), mimetype='video/webm', content_type="video/webm; codecs=vp9", headers=Headers([("Connection", "close")]))