Recherche avancée

Médias (5)

Mot : - Tags -/open film making

Autres articles (77)

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

  • 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

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (7990)

  • 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)


    


  • lavc/h264dec : don't error out when receiving multiple IDR slices

    26 septembre 2018, par Josh de Kock
    lavc/h264dec : don't error out when receiving multiple IDR slices
    

    This error isn't particularly helpful as checking for mixed IDR/non-IDR
    NALUs would need to be done at a higher level to actually be accurate.
    Removing the error allows an API user to send individual slice NALUs
    (i.e. incomplete frames) so they can take advantage of slice
    threading. The ticket which this error was added for (#4408) no
    longer segfaults after removing this error (as the bug was likely
    fixed more properly elsewhere).

    • [DH] libavcodec/h264dec.c
  • ffmpeg/mkvtoolnix - Remuxing new audio track to a specific 'track' position ?

    22 octobre 2018, par Saxon Rix

    I’m currently working on using this ’nightmode downmix’ script for ffmpeg which I found here.

    @echo off
    set PATH_MKVMERGE=D:\Programs\VideoProcessing\mkvtoolnix
    set PATH=%PATH%;%PATH_MKVMERGE%
    @echo on

    cd /d %~dp0

    For %%a IN ("*.mkv") Do (
    echo ---------------------- BATCH STARTING %%~na%%~xa
    ffmpeg.exe -report -loglevel verbose -i "%%~na%%~xa" -map 0:a:0 -f wav -acodec pcm_f32le -ac 2 -af "pan=stereo|FL=FC+0.25*FL+0.60*LFE|FR=FC+0.20*FR+0.60*LFE" - | qaac.exe --tvbr 127 --quality 2 --rate keep --ignorelength --no-delay - -o "%%~na-ffmpeg.m4a" 1>>qaac.log 2>&1
    If exist "%%~na.srt" (
       mkvmerge.exe --split 4000M -o "%%~na-2chnightmode%%~xa" --no-chapters --no-audio "%%~na%%~xa" "%%~na-ffmpeg.m4a" "%%~na.srt" 1>>"mkvmerge.log" 2>&1
    ) Else (
       mkvmerge.exe --split 4000M -o "%%~na-2chnightmode%%~xa" --no-chapters --no-audio "%%~na%%~xa" "%%~na-ffmpeg.m4a" 1>>"mkvmerge.log" 2>&1
    )
    )

    Currently this just encodes the audio, then remuxes it with the video and in the end it leaves me with a video file with the original (copied) video & the down-mixed audio track as well as the separate audio file that it created.

    However, this puts the new audio track to the bottom of the stack. Eg, The original file has audio tracks in this order :

    1. 5.1 Track
    2. Commentary Track

    The newly exported audio goes at the end like this :

    1. 5.1 Track
    2. Commentary Track
    3. nightmode track

    Is there any way to force the new track to be the 2nd track, and move all other tracks (except the default track) below it, as well as give the track a title such as ’NightMode 2.0’ ? And also to automatically delete the ’intermediate’ audio track it creates after it’s all been muxed back together ?

    So that in the end I’m left with a re-muxed video file that has all the original audio tracks in, as well as the newly created ’NightMode’ track too as the second audio track (after the default track).

    Is this possible please ?