Recherche avancée

Médias (1)

Mot : - Tags -/Rennes

Autres articles (45)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

Sur d’autres sites (7923)

  • PHP-FFMPEG Waveform is not clean, is it a bug ?

    6 février 2024, par Maxi

    I made a waveform through sample code :

    


    $waveform = $audio->waveform(2000, 500, array('#FFA500'));
$waveform->save('waveform.png');


    


    But result has some noise in top & bottom of edges.
How can make it better ?

    


    PHP-FFMpeg : 23 | FFMpeg : 2023-02-27-git-891ed24f77 (Win X64) | PHP : 8.3

    


  • Flask app using OpenCv crash when i start recording

    17 mai 2023, par Mulham Darwish

    I build this flask app to live stream security cameras and the live stream works with the screenshot function but when start recording it crash but few times same code it worked and saved the video here the code. with the html file using js.

    


    from flask import Flask, render_template, Response, request
import cv2
import os
import time
import threading
import requests

app = Flask(__name__)

# Define the IP cameras
cameras = [
    {'url': 'rtsp://****:*****@******', 'name': 'Camera 1'},
    {'url': 'rtsp://****:*****@******', 'name': 'Camera 2'},
    {'url': 'rtsp://****:*****@******', 'name': 'Camera 3'},
    {'url': 'rtsp://****:*****@******', 'name': 'Camera 4'}
]

# Create a VideoCapture object for each camera
capture_objs = [cv2.VideoCapture(cam['url']) for cam in cameras]
stop_events = {i: threading.Event() for i in range(len(cameras))}
# Define the directory to save the recorded videos
recording_dir = os.path.join(os.getcwd(), 'recordings')

# Ensure the recording directory exists
if not os.path.exists(recording_dir):
    os.makedirs(recording_dir)

# Define the function to capture and save a video
def record_video(camera_index, stop_recording):
    # Define the codec and file extension
    fourcc = cv2.VideoWriter_fourcc(*'mp4v')
    file_extension = '.mp4'

    # Get the current timestamp for the filename
    timestamp = time.strftime("%Y%m%d-%H%M%S")

    # Define the filename and path
    filename = f'{cameras[camera_index]["name"]}_{timestamp}{file_extension}'
    filepath = os.path.join(recording_dir, filename)

    # Create a VideoWriter object to save the video
    width = int(capture_objs[camera_index].get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(capture_objs[camera_index].get(cv2.CAP_PROP_FRAME_HEIGHT))
    fps = int(capture_objs[camera_index].get(cv2.CAP_PROP_FPS))
    video_writer = cv2.VideoWriter(filepath, fourcc, fps, (width, height))

    # Capture frames and write them to the file
    while True:
        if stop_recording.is_set():
            break  # stop recording if stop_recording is set
        ret, frame = capture_objs[camera_index].read()
        if ret:
            video_writer.write(frame)
        else:
            break

    # Release the VideoWriter object and the VideoCapture object
    video_writer.release()
    capture_objs[camera_index].release()

@app.route('/')
def index():
    # Render the index page with the list of cameras
    return render_template('index.html', cameras=cameras)

def generate(camera_index):
    # Generate frames from the video feed
    while True:
        ret, frame = capture_objs[camera_index].read()
        if not ret:
            break

        # Encode the frame as JPEG
        _, jpeg = cv2.imencode('.jpg', frame)

        # Yield the frame as a Flask response
        yield (b'--frame\r\n'
               b'Content-Type: image/jpeg\r\n\r\n' + jpeg.tobytes() + b'\r\n')

@app.route('/video_feed')
def video_feed():
    # Get the camera index from the request arguments
    camera_index = int(request.args.get('camera_index'))

    # Generate the video feed
    return Response(generate(camera_index),
                    mimetype='multipart/x-mixed-replace; boundary=frame')

@app.route('/record', methods=['POST'])
def record():
    # Get the camera index from the request form
    camera_index = int(request.form['camera_index'])

    stop_recording = stop_events[camera_index]  # get the stop_recording event for the camera
    thread = threading.Thread(target=record_video, args=(camera_index, stop_recording))
    thread.start()  # start a thread to record video

    # Return a response indicating that the recording has started
    return 'Recording started.'

@app.route('/stop_record', methods=['POST'])
def stop_record():
    # Get the camera index from the request form
    camera_index = int(request.form['camera_index'])

    # Set the stop_recording event for the corresponding camera thread
    stop_events[camera_index].set()

    # Return a response indicating that recording has been stopped
    return 'Recording stopped.'

@app.route('/screenshot', methods=['POST'])
def take_screenshot():
    # Take a screenshot of the video stream and save it as a file
    camera = capture_objs[int(request.form['camera_id'])]
    success, frame = camera.read()
    if success:
        timestamp = time.strftime("%Y%m%d-%H%M%S")
        filename = f'screenshot_{timestamp}.jpg'
        cv2.imwrite(filename, frame)
        return 'Screenshot taken and saved'
    else:
        return 'Failed to take screenshot'

if __name__ == '__main__':
    app.run()


    


    I tried to update ffmpeg to the latest version and installed pip install opencv-python-headless and installed pip install opencv-python but most of the time i come to this crash code

    


    * Serving Flask app 'run'
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
127.0.0.1 - - [17/May/2023 13:24:11] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [17/May/2023 13:24:11] "GET /video_feed?camera_index=0 HTTP/1.1" 200 -
127.0.0.1 - - [17/May/2023 13:24:11] "GET /video_feed?camera_index=1 HTTP/1.1" 200 -
127.0.0.1 - - [17/May/2023 13:24:11] "GET /video_feed?camera_index=2 HTTP/1.1" 200 -
127.0.0.1 - - [17/May/2023 13:24:11] "GET /video_feed?camera_index=3 HTTP/1.1" 200 -
127.0.0.1 - - [17/May/2023 13:24:44] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [17/May/2023 13:24:45] "GET /video_feed?camera_index=3 HTTP/1.1" 200 -
127.0.0.1 - - [17/May/2023 13:24:45] "GET /video_feed?camera_index=0 HTTP/1.1" 200 -
127.0.0.1 - - [17/May/2023 13:24:45] "GET /video_feed?camera_index=1 HTTP/1.1" 200 -
127.0.0.1 - - [17/May/2023 13:24:45] "GET /video_feed?camera_index=2 HTTP/1.1" 200 -
[h264 @ 0x5605285fc5c0] error while decoding MB 28 29, bytestream -9
[h264 @ 0x560529110040] error while decoding MB 15 37, bytestream -6
[h264 @ 0x560528624980] error while decoding MB 45 45, bytestream -23
[h264 @ 0x5605286f1900] error while decoding MB 50 34, bytestream -7
[h264 @ 0x5605285fc5c0] error while decoding MB 25 9, bytestream -17
[h264 @ 0x5605292b0080] error while decoding MB 28 41, bytestream -5
[h264 @ 0x560528660040] error while decoding MB 101 45, bytestream -17
[h264 @ 0x5605285fc5c0] error while decoding MB 42 44, bytestream -5
[h264 @ 0x5605286f1900] error while decoding MB 118 42, bytestream -9
[h264 @ 0x560529110040] error while decoding MB 92 43, bytestream -5
[h264 @ 0x560528660040] error while decoding MB 99 34, bytestream -11
[h264 @ 0x56052932b0c0] error while decoding MB 92 36, bytestream -13
[h264 @ 0x560528667ac0] error while decoding MB 44 54, bytestream -5
[h264 @ 0x560529110040] error while decoding MB 93 33, bytestream -7
[h264 @ 0x5605286dd880] error while decoding MB 27 37, bytestream -19
[h264 @ 0x560528660040] error while decoding MB 66 56, bytestream -9
127.0.0.1 - - [17/May/2023 13:36:45] "POST /record HTTP/1.1" 200 -
Assertion fctx->async_lock failed at libavcodec/pthread_frame.c:175
Aborted (core dumped)


    


  • why ffmpeg process successfully terminated with return code of 1 without play anything

    24 juillet 2023, par Exc

    `I tried replacing youtube_dl with yt_dlp and replaced some of the code, the code worked fine but when using the command, the bot doesn't play music but immediately ffmpeg process 15076 successfully terminated with return code of 1

    


    Is there a problem with my code or the ffmpg option or ytdlp option that doesn't support the yt_dlp library ?`

    


     self.YTDL_OPTIONS = {
        'format': 'bestaudio/best',
        'outtmpl': 'F:/DISCORD BOT/Ex/music/%(extractor)s-%(id)s-%(title)s.%(ext)s',
        'restrictfilenames': True,
        'retry_max': 'auto',
        'noplaylist': True,
        'nocheckcertificate': True,
        'ignoreerrors': True,
        'logtostderr': False,
        'quiet': True,
        'no_warnings': True,
        'default_search': 'auto',
        'source_address': '0.0.0.0',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
        }],
        'youtube_api_key': 'api'
    }
self.FFMPEG_OPTIONS = {
         'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
         'options': '-vn',
         'executable':r'F:\DISCORD BOT\Ex\ffmpeg\bin\ffmpeg.exe'
         }

    
    @commands.hybrid_command(
        name="play",
        aliases=["p"],
        usage="",
        description="KARAUKENAN.",
         
    )
    @app_commands.describe(
        judul_lagu="link ato judul lagunya"
    )
    async def play(self, ctx, judul_lagu:str):
        await ctx.defer()
        voice_channel = ctx.author.voice
        if not voice_channel or not voice_channel.channel:
            await ctx.send("Join voice channel dulu gblk!")
            return

        voice_channel = voice_channel.channel
        song = self.search_song(judul_lagu)
        if not song:
            await ctx.send("Lagnya tdk ditemukan, coba keword lain.")
            return

        if not self.bot.voice_clients:
            voice_client = await voice_channel.connect()
        else:
            voice_client = self.bot.voice_clients[0]
            if voice_client.channel != voice_channel:
                await voice_client.move_to(voice_channel)

        self.music_queue.append([song, voice_client])
        if not self.is_playing:
            await self.play_music(ctx)
    
    async def play_music(self, ctx):
        self.is_playing = True
        while len(self.music_queue) > 0:
            song = self.music_queue[0][0]
            voice_client = self.music_queue[0][1]
            await ctx.send(f"Playing {song['title']}")

            voice_client.play(discord.FFmpegPCMAudio(song['source'], **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())
            voice_client.is_playing()

            while voice_client.is_playing():
                await asyncio.sleep(1)

            self.music_queue.pop(0)
            self.is_playing = False

        await ctx.send("Queue is empty.")
        voice_client.stop()

    def play_next(self):
        if len(self.music_queue) > 0:
            self.is_playing = False

    def search_song(self, judul_lagu):
        ydl = yt_dlp.YoutubeDL(self.YTDL_OPTIONS)
        with ydl:
            try:
                info = ydl.extract_info(f"ytsearch:{judul_lagu}", download=False)['entries'][0]
                return {'source': info['formats'][0]['url'], 'title': info['title']}
            except Exception:
                return None




    


    when i use /play the bot sucess serch song but immediately terminate does not play any music

    


    2023-04-10 13:06:45 INFO     discord.voice_client Connecting to voice...
2023-04-10 13:06:45 INFO     discord.voice_client Starting voice handshake... (connection attempt 1)
2023-04-10 13:06:46 INFO     discord.voice_client Voice handshake complete. Endpoint found singapore11075.discord.media
2023-04-10 13:06:50 INFO     discord.player ffmpeg process 15076 successfully terminated with return code of 1.


    


    this image whe i use /play