
Recherche avancée
Médias (91)
-
MediaSPIP Simple : futur thème graphique par défaut ?
26 septembre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Video
-
avec chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
sans chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
config chosen
13 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
SPIP - plugins - embed code - Exemple
2 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
Autres articles (83)
-
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...) -
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)
Sur d’autres sites (14023)
-
Recorded Video Ending Prematurely with WebSocket and FFmpeg
7 septembre 2024, par ZaidI am working on a screen recording application where it allows users to record their screen and I use websocket to send their bytes data in real time to my FastAPI Python server. The bytes are sent every 2 second and I use FFmpeg to keep saving the bytes in the output MP4 video file.


Problem :
Everything was working fine when I had the server running on my local machine, however, I just deployed the server to EC2 instanceus-ease-1
and when I try to record the videos, the videos are really short, IE, if I record a 30 second video, it only has the video for 3 second. Sometimes it saves 90% of the video and sometimes less. I am not sure what is the problem here.
I have been trying to debug the code for the past few days, but with no success

Here is my code :


FRONTEND


const recorder = new MediaRecorder(stream, {
 mimeType: 'video/webm;codecs=H264',
 videoBitsPerSecond: 8000000
 });

recorder.ondataavailable = (e: BlobEvent) => {
 socketRef.socket.send(e.data)
}



And here is my python code :-


@router.websocket("/stream")
async def websocket_endpoint(websocket: WebSocket, token: str = Query(...), videoId: str = Query(...), authorize: AuthJWT = Depends()):
 await manager.connect(websocket)
 dataNumber = 1

 recordingFile = os.path.join(temp_dir, f"recording_{videoId}.mp4")

 command = [
 'ffmpeg', 
 '-y',
 '-i', 
 '-', 
 '-codec:v', 
 'copy', 
 '-f', 'mp4',
 recordingFile,
 ]

 process = subprocess.Popen(command, stdin=subprocess.PIPE)
 try:
 while True:
 try:
 data = await websocket.receive_bytes()
 if not data:
 break
 process.stdin.write(data)
 await websocket.send_json({"chunkNumber": dataNumber, "status": 200})
 dataNumber = dataNumber + 1
 except RuntimeError:
 break 
 except WebSocketDisconnect:
 print(f"Client disconnected: {websocket.client.host}")
 finally:
 manager.disconnect(websocket)

 # Close stdin to signal EOF
 process.stdin.close()

 # Wait for FFmpeg to finish processing
 process.wait()

 # Ensure that the process is terminated
 process.terminate() 



I also get this error in the console :-



Editor's note : Text is auto-extracted by an AI (ie : may not be 100% correct)


libpostproc 57. 3.100/57. 3.100
Input #6, matroska, webm, from 'fd:':
Metadata:
encoder: Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Video: h264 (Constrained Baseline), yuv420p(tv, bt789, progressive), 1920x1080, SAR 1:1 DAR 16:9, 30
.30 fps, 56 tbr, 1k tbn (default)

Output #8, mp4, to /tmp/recording_d367d8d3-60de-483e-bf29-1849841b82f3.mp4':
Metadata:
encoder: Lavf60.16.100
Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [
SAR 1:1 DAR 16:9], q=2-31, 38.30 fps, 56 tbr, 16k tbn (default)
Stream mapping:
Stream #0:0> #0:6 (copy)
Client disconnected: 127.0.0.189 bitrate=3374.0kbits/s speed=0.999x
[matroska, webm @ 8x61e88988f3c0]
9493864 (0x98dd68)
[out#0/mp4 @ 0x61e8898cc488] video:9263kB audio:0kB subtitle:0kB other streams: 9kB global headers: 8kB muxing overhead: 0
.143342%
size= 9276kB time=00:00:21.85 bitrate=3476.8kbits/s speed=1.08x
INFO:
connection closed
INFO: 127.0.0.1:52546 "POST /api/process HTTP/1.1" 200 ок



-
No audio in the final video when converting webm blobs to mp4 using ffmpeg
28 septembre 2024, par alpeccaI trying to record user camera and microphone and using MediaRecorder to convert the stream to blobs and sending the blobs every 2 second to the backend using websocket. Everything is working fine, but when I checked the final mp4 video in the backend, it doesn't have any audio to it, I try specifying the audio codec, but still no help.


My frontend code :-


const micStream = await navigator.mediaDevices.getUserMedia({ audio: true });

const recorder = new MediaRecorder(stream, {
 mimeType: 'video/webm;codecs=H264',
 videoBitsPerSecond: 8000000,
 audioBitsPerSecond : 8000000
});

recorder.ondataavailable = (e: BlobEvent) => {
 websocket.send(e.data) 
} 
recorder.start(2000);



And here is the backend code :-


@router.websocket("/streamaudio")
async def websocket_endpoint(websocket: WebSocket):
 await manager.connect(websocket)

 recordingFile = os.path.join(os.getcwd(), f"recording_.mp4")

 command = [
 'ffmpeg', 
 '-y',
 '-i', 
 '-', 
 '-codec:v', 
 'copy', 
 '-c:a', 'aac', 
 '-y',
 '-f', 'mp4',
 recordingFile,
 # "-"
 # f'output{queueNumber}.mp4',
 ] 

 
 try:
 while True:
 try:
 
 data = await websocket.receive_bytes()
 
 process.stdin.send(data)
 
 except RuntimeError:
 break 
 except WebSocketDisconnect:
 print(f"Client disconnected: {websocket.client.host}")
 finally:
 manager.disconnect(websocket)
 await process.stdin.aclose()
 await process.wait() 



-
Write buffer to ffmpeg stdin and send websocket message after that
6 septembre 2024, par alpeccaI am working on a streaming application in which user can stream videos in real time to my server usig websocket and media recorder. I have written my backend code using fastapi python and I setup a websocket endpoint that would receive buffer data from the frontend every two second. But the problem I am facing is here :-


process.stdin.write(data)
await websocket.send_json



Here the code ffmpeg process write could take some time to take a buffer and write a mp4 for it, but the websocket send json won't wait for it and thus just send the message back to the client, which is causing videos being too short and currupted once the user stops the recording.


Here is the full code


@router.websocket("/stream")
async def websocket_endpoint(websocket: WebSocket, token: str = Query(...), videoId: str = Query(...), authorize: AuthJWT = Depends()):
 await manager.connect(websocket)
 dataNumber = 1

 recordingFile = os.path.join(temp_dir, f"recording_{videoId}.mp4")

 command = [
 'ffmpeg', 
 '-y',
 '-i', 
 '-', 
 '-codec:v', 
 'copy', 
 '-f', 'mp4',
 recordingFile,
 # "-"
 # f'output{queueNumber}.mp4',
 ]

 process = subprocess.Popen(command, stdin=subprocess.PIPE)

 try:
 while True:
 try:
 data = await websocket.receive_bytes()
 if not data:
 break
 process.stdin.write(data)
 process.stdin.flush()
 await websocket.send_json({"chunkNumber": dataNumber, "status": 200})
 dataNumber = dataNumber + 1
 except RuntimeError:
 break 
 except WebSocketDisconnect:
 print(f"Client disconnected: {websocket.client.host}")
 finally:
 manager.disconnect(websocket)
 process.stdin.close()
 process.wait()
 process.terminate()



What I want to do is on each buffer send from the client, I want to make sure that ffmpeg writes that to the filesystem compeletly and than only to send the websocket message back to the client. And also, as the request are coming from the client every 2 second no matter what, If the write is taking too long for the previous message, I want to make sure that that the ffmpeg first write that part to the file and send the message and than do the newer one