
Recherche avancée
Médias (91)
-
GetID3 - Boutons supplémentaires
9 avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
-
Core Media Video
4 avril 2013, par
Mis à jour : Juin 2013
Langue : français
Type : Video
-
The pirate bay depuis la Belgique
1er avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
-
Bug de détection d’ogg
22 mars 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Video
-
Exemple de boutons d’action pour une collection collaborative
27 février 2013, par
Mis à jour : Mars 2013
Langue : français
Type : Image
-
Exemple de boutons d’action pour une collection personnelle
27 février 2013, par
Mis à jour : Février 2013
Langue : English
Type : Image
Autres articles (98)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...) -
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)
Sur d’autres sites (7793)
-
Youtube automatic creating and starting live stream with ffmpeg Python
20 août 2023, par MrKolia1_1I'm trying to create a new broadcast on the channel and then start the stream so that the video is broadcast, the problem is that I can't start the broadcast after it is created, it is in the scheduled, how can I start the broadcast ?




import datetime
import json
import os
import threading
import time

import cv2
import subprocess
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build

APP_TOKEN_FILE = "client_secret.json"
USER_TOKEN_FILE = "user_token.json"

SCOPES = [
 'https://www.googleapis.com/auth/youtube.force-ssl',
 'https://www.googleapis.com/auth/userinfo.profile',
]


def get_stream_info(stream_id):
 creds = get_creds_saved()
 service = build('youtube', 'v3', credentials=creds)

 request = service.liveBroadcasts().list(
 part='snippet,contentDetails,status',
 id=stream_id
 )

 response = request.execute()

 if 'items' in response and len(response['items']) > 0:
 return response['items'][0]
 else:
 return None


def get_creds_cons():
 # Create credentials via console flow
 flow = InstalledAppFlow.from_client_secrets_file(APP_TOKEN_FILE, SCOPES)
 return flow.run_console()


def get_creds_saved():
 creds = None

 if os.path.exists(USER_TOKEN_FILE):
 # Load user credentials from a saved file
 creds = Credentials.from_authorized_user_file(USER_TOKEN_FILE, SCOPES)

 if not creds or not creds.valid:
 if creds and creds.expired and creds.refresh_token:
 creds.refresh(Request())
 else:
 # Create new credentials via local server flow
 flow = InstalledAppFlow.from_client_secrets_file(APP_TOKEN_FILE, SCOPES)
 creds = flow.run_local_server(port=0)

 with open(USER_TOKEN_FILE, 'w') as token:
 token.write(creds.to_json())

 return creds


def get_service():
 # Get YouTube API service using credentials
 creds = get_creds_saved()
 service = build('youtube', 'v3', credentials=creds)
 return service


def create_live_stream(title, description):
 service = get_service()
 scheduled_start_time = datetime.datetime.utcnow().isoformat()

 request = service.liveBroadcasts().insert(
 part="snippet,status,contentDetails",
 body={
 "snippet": {
 "title": title,
 "description": description,
 "scheduledStartTime": scheduled_start_time,
 },
 "status": {
 "privacyStatus": "private",
 "lifeCycleStatus": "ready",
 "recordingStatus": "notRecording",
 "selfDeclaredMadeForKids": False
 },
 "contentDetails": {
 "enableAutoStart": False
 }
 }
 )
 response = request.execute()
 return response['id']


def stream_video(video_path, stream_key):
 args = [
 '-re',
 '-i', video_path,
 '-c:v', 'libx264',
 '-preset', 'veryfast',
 '-c:a', 'aac',
 '-f', 'flv',
 f'rtmp://a.rtmp.youtube.com/live2/{stream_key}'
 ]

 subprocess.run(['ffmpeg'] + args)


def get_scheduled_stream_info(stream_id):
 creds = get_creds_saved()
 service = build('youtube', 'v3', credentials=creds)

 request = service.liveBroadcasts().list(
 part='snippet,status',
 id=stream_id
 )

 response = request.execute()

 if 'items' in response and len(response['items']) > 0:
 return response['items'][0]
 else:
 return None



if __name__ == '__main__':
 print("** Hello, Azzrael_YT subscribers!!!\n")

 strId = create_live_stream("tittle", "description")
 pretty_json = json.dumps(get_scheduled_stream_info(strId), indent=4)

 print(pretty_json)

 # Stream video
 video_path = "C:/Users/admin/PycharmProjects/pythonProject/video.mp4" # Update this with your video file path
 stream_key = 'dh9z-jtkx-wbq3-6wvp-2tac' # Replace with your YouTube stream key
 video_thread = threading.Thread(target=stream_video, args=(video_path, stream_key))
 #video_thread.start()




json responce info from created stream :
,
"scheduledStartTime" : "2023-08-20T10:51:22Z",
"isDefaultBroadcast" : false,
"liveChatId" : "KicKGFVDZ01UNS1CLVNfV0FJencxVXY4cC1ZQRILSG9QU0RJZ2hQMkE"
,
"status" : 
"lifeCycleStatus" : "created",
"privacyStatus" : "private",
"recordingStatus" : "notRecording",
"madeForKids" : false,
"selfDeclaredMadeForKids" : false




-
Building FFmpeg with NVIDIA GPU Hardware Acceleration in docker image, cannot load libnvcuvid.so.1 and libnvidia-encode.so.1
22 mars 2023, par konovificationI'm trying to build FFmpeg with NVIDIA GPU Hardware Acceleration following these instructions : https://docs.nvidia.com/video-technologies/video-codec-sdk/ffmpeg-with-nvidia-gpu/index.html#compiling-for-linux. The Docker image I'm using is
nvidia/cuda:12.0.1-devel-ubuntu20.04


Running the test command
ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i bbb.mp4 -c:a copy -c:v h264_nvenc -b:v 5M output.mp4
, I get the following output :

ffmpeg version N-109965-ge50a02b0f6 Copyright (c) 2000-2023 the FFmpeg developers 
 built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) 
 configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared 
 libavutil 58. 3.100 / 58. 3.100 
 libavcodec 60. 6.100 / 60. 6.100 
 libavformat 60. 4.100 / 60. 4.100 
 libavdevice 60. 2.100 / 60. 2.100 
 libavfilter 9. 4.100 / 9. 4.100 
 libswscale 7. 2.100 / 7. 2.100 
 libswresample 4. 11.100 / 4. 11.100 
-vsync is deprecated. Use -fps_mode 
Passing a number to -vsync is deprecated, use a string argument as described in the manual. 
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bbb.mp4': 
 Metadata: 
 major_brand : isom 
 minor_version : 1 
 compatible_brands: isomavc1 
 creation_time : 2013-12-16T17:44:39.000000Z 
 title : Big Buck Bunny, Sunflower version 
 artist : Blender Foundation 2008, Janus Bager Kristensen 2013 
 comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net 
 genre : Animation 
 composer : Sacha Goedegebure 
 Duration: 00:10:34.60, start: 0.000000, bitrate: 3481 kb/s 
 Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 2998 kb/s, 30 fps, 30 tbr, 30k tbn (default)
 Metadata: 
 creation_time : 2013-12-16T17:44:39.000000Z 
 handler_name : GPAC ISO Video Handler 
 vendor_id : [0][0][0][0] 
 Stream #0:1[0x2](und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default) 
 Metadata: 
 creation_time : 2013-12-16T17:44:42.000000Z 
 handler_name : GPAC ISO Audio Handler 
 vendor_id : [0][0][0][0] 
 Stream #0:2[0x3](und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default) 
 Metadata: 
 creation_time : 2013-12-16T17:44:42.000000Z 
 handler_name : GPAC ISO Audio Handler 
 vendor_id : [0][0][0][0] 
 Side data: 
 audio service type: main 
Stream mapping: 
 Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc)) 
 Stream #0:2 -> #0:1 (copy) 
Press [q] to stop, [?] for help 
[h264 @ 0x55bd878c2d80] Cannot load libnvcuvid.so.1 
[h264 @ 0x55bd878c2d80] Failed loading nvcuvid. 
[h264 @ 0x55bd878c2d80] Failed setup for format cuda: hwaccel initialisation returned error. 
[h264_nvenc @ 0x55bd86f5e680] Cannot load libnvidia-encode.so.1 
[h264_nvenc @ 0x55bd86f5e680] The minimum required Nvidia driver for nvenc is 520.56.06 or newer 
[vost#0:0/h264_nvenc @ 0x55bd86f5e1c0] Error initializing output stream: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed! 



Output from
nvidia-smi
:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.85.05 Driver Version: 525.85.05 CUDA Version: 12.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 On | N/A |
| 27% 43C P8 12W / 250W | 500MiB / 11264MiB | 1% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
 
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+



The shared libraries are not part of the docker image. What are my options to add them ?


-
input/output error with ffmpeg using an input URL in docker
12 décembre 2023, par GrimouI need to use ffmpeg to listen to an rtmp url within a running docker container using ffmpeg.
my ffmpeg command is quite simple :
ffmpeg -listen 1 -i rtmp://localhost:1935/live/app ./output.wav


ffmpeg seems to start correctly and listen to the url.


But, when I start the stream (using OBS Studio) I have an input/output error. Here is the logs (with debug log level)


❯ ffmpeg -loglevel debug -listen 1 -i rtmp://127.0.0.1:1935/live/app ./output.wav
ffmpeg version 5.1.4-0+deb12u1 Copyright (c) 2000-2023 the FFmpeg developers
 built with gcc 12 (Debian 12.2.0-14)
 configuration: --prefix=/usr --extra-version=0+deb12u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
 libavutil 57. 28.100 / 57. 28.100
 libavcodec 59. 37.100 / 59. 37.100
 libavformat 59. 27.100 / 59. 27.100
 libavdevice 59. 7.100 / 59. 7.100
 libavfilter 8. 44.100 / 8. 44.100
 libswscale 6. 7.100 / 6. 7.100
 libswresample 4. 7.100 / 4. 7.100
 libpostproc 56. 6.100 / 56. 6.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-listen' ... matched as AVOption 'listen' with argument '1'.
Reading option '-i' ... matched as input url with argument 'rtmp://127.0.0.1:1935/live/app'.
Reading option './output.wav' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url rtmp://127.0.0.1:1935/live/app.
Successfully parsed a group of options.
Opening an input file: rtmp://127.0.0.1:1935/live/app.
[NULL @ 0x56288f8e7a00] Opening 'rtmp://127.0.0.1:1935/live/app' for reading
[rtmp @ 0x56288f8e8200] No default whitelist set
[tcp @ 0x56288f8e8d40] No default whitelist set
[rtmp @ 0x56288f8e8200] Proto = rtmp, path = /live/app, app = live, fname = app
[rtmp @ 0x56288f8e8200] New incoming chunk size = 4096
rtmp://127.0.0.1:1935/live/app: Input/output error



The last 3 lines only appear when I start the stream.


It doesn't seems to be a permission problem with the file system, since using
ffmpeg -i ./test.mp4 ./output.wav
works inside the container.

I also did not find any problem with the network. I am currently using
network_mode: "host"
in my docker_compose.yml and the logs show that it did receive data before the error appear.

It also doesn't seem to be a problem with the ffmpeg command, since the exact same command works when using it without docker involved.


What else could be the problem ?


here is my docker_compose.yml


version: '3'

services:
 ffmpeg-container:
 build:
 context: .
 network_mode: "host"
 tty: true # Allocate a pseudo-TTY for interactive use




Dockerfile


FROM python:3

# Install ffmpeg
RUN apt-get update && apt-get install -y ffmpeg

# Create a working directory
WORKDIR app

# Copy the Python script to the container
COPY app.py .
COPY test.mp4 .

# Run the Python script
CMD ["python", "app.py"]