Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (57)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • 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

Sur d’autres sites (8458)

  • TypeError : expected str, bytes or os.PathLike object, not module when trying to sream openCv frames to rtmp server

    30 novembre 2022, par seriously

    I am using openCv and face-recognition api to detect a face using a webcam then compare it with a previously taken image to check and see if the people on both images are the same and the openCv and face-recognition part of the code works properly now what I am trying to achieve is to stream the openCv processed video frames to an rtmp server so for this I am trying to use ffmpeg and running the command using subprocess but when I run the code I get error TypeError: expected str, bytes or os.PathLike object, not module. But I am writing the frames as bytes to stdin hence p.stdin.write(frame.tobytes()). How can I fix it and properly stream my openCv frames to an rtmp server using ffmpeg. Thanks in advance.

    


    Traceback (most recent call last):&#xA;  File "C:\Users\blah\blah\test.py", line 52, in <module>&#xA;    p = subprocess.Popen(command, stdin=subprocess.PIPE, shell=False)&#xA;  File "C:\Python310\lib\subprocess.py", line 969, in __init__&#xA;    self._execute_child(args, executable, preexec_fn, close_fds,&#xA;  File "C:\Python310\lib\subprocess.py", line 1378, in _execute_child&#xA;    args = list2cmdline(args)&#xA;  File "C:\Python310\lib\subprocess.py", line 561, in list2cmdline&#xA;    for arg in map(os.fsdecode, seq):&#xA;  File "C:\Python310\lib\os.py", line 822, in fsdecode&#xA;    filename = fspath(filename)  # Does type-checking of `filename`.&#xA;TypeError: expected str, bytes or os.PathLike object, not module&#xA;</module>

    &#xA;

    import cv2&#xA;import numpy as np&#xA;import face_recognition&#xA;import os&#xA;import subprocess&#xA;import ffmpeg&#xA;&#xA;path = &#x27;../attendance_imgs&#x27;&#xA;imgs = []&#xA;classNames = []&#xA;myList = os.listdir(path)&#xA;&#xA;for cls in myList:&#xA;    curruntImg = cv2.imread(f&#x27;{path}/{cls}&#x27;)&#xA;    imgs.append(curruntImg)&#xA;    classNames.append(os.path.splitext(cls)[0])&#xA;&#xA;def findEncodings(imgs):&#xA;    encodeList = []&#xA;    for img in imgs:&#xA;        img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)&#xA;        encode = face_recognition.face_encodings(img)[0]&#xA;        encodeList.append(encode)&#xA;    return encodeList&#xA;&#xA;encodeListKnown = findEncodings(imgs)&#xA;print(&#x27;Encoding Complete&#x27;)&#xA;&#xA;cap = cv2.VideoCapture(0)&#xA;&#xA;rtmp_url = "rtmp://127.0.0.1:1935/stream/webcam"&#xA;&#xA;fps = int(cap.get(cv2.CAP_PROP_FPS))&#xA;width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))&#xA;height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))&#xA;&#xA;# command and params for ffmpeg&#xA;command = [ffmpeg,&#xA;           &#x27;-y&#x27;,&#xA;           &#x27;-f&#x27;, &#x27;rawvideo&#x27;,&#xA;           &#x27;-vcodec&#x27;, &#x27;rawvideo&#x27;,&#xA;           &#x27;-pix_fmt&#x27;, &#x27;bgr24&#x27;,&#xA;           &#x27;-s&#x27;, "{}x{}".format(width, height),&#xA;           &#x27;-r&#x27;, str(fps),&#xA;           &#x27;-i&#x27;, &#x27;-&#x27;,&#xA;           &#x27;-c:v&#x27;, &#x27;libx264&#x27;,&#xA;           &#x27;-pix_fmt&#x27;, &#x27;yuv420p&#x27;,&#xA;           &#x27;-preset&#x27;, &#x27;ultrafast&#x27;,&#xA;           &#x27;-f&#x27;, &#x27;flv&#x27;,&#xA;           &#x27;rtmp://127.0.0.1:1935/stream/webcam&#x27;]&#xA;&#xA;p = subprocess.Popen(command, stdin=subprocess.PIPE, shell=False)&#xA;&#xA;&#xA;while True:&#xA;    ret, frame, success, img = cap.read()&#xA;    if not ret:&#xA;        print("frame read failed")&#xA;        break&#xA;    imgSmall = cv2.resize(img, (0,0), None, 0.25, 0.25)&#xA;    imgSmall = cv2.cvtColor(imgSmall, cv2.COLOR_BGR2RGB)&#xA;&#xA;    currentFrameFaces = face_recognition.face_locations(imgSmall)&#xA;    currentFrameEncodings = face_recognition.face_encodings(imgSmall, currentFrameFaces)&#xA;&#xA;    for encodeFace, faceLocation in zip(currentFrameEncodings, currentFrameFaces):&#xA;        matches = face_recognition.compare_faces(encodeListKnown, encodeFace)&#xA;        faceDistance = face_recognition.face_distance(encodeListKnown, encodeFace)&#xA;        matchIndex = np.argmin(faceDistance)&#xA;&#xA;        if matches[matchIndex]:&#xA;            name = classNames[matchIndex].upper()&#xA;            y1, x2, y2, x1 = faceLocation&#xA;            y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4 &#xA;            cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)&#xA;            cv2.rectangle(img, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)&#xA;            cv2.putText(img, name, (x1 &#x2B; 6, y2 - 6), cv2.FONT_HERSHEY_DUPLEX, 1, (255, 255, 255), 2) &#xA;&#xA;    # write to pipe&#xA;    p.stdin.write(frame.tobytes())&#xA;

    &#xA;

  • ffmpeg module saving not working after compression

    27 août 2022, par nickcoding2

    I'm just trying to save an mp4 to a different mp4 (before I even start playing around with the different compression settings). What exactly is going wrong here ?

    &#xA;

    const ffmpeg = require(&#x27;ffmpeg&#x27;);&#xA;&#xA;try {&#xA;    var process = new ffmpeg(&#x27;./original.mp4&#x27;);&#xA;    process.then(function (video) {&#xA;        video&#xA;        .save(&#x27;./new.mp4&#x27;, function (error, file) {&#xA;            if (!error) {&#xA;                console.log(&#x27;Video file: &#x27; &#x2B; file);&#xA;            } else {&#xA;                console.log(error)&#xA;            }&#xA;        });&#xA;    }, function (err) {&#xA;        console.log(&#x27;Error: &#x27; &#x2B; err);&#xA;    });&#xA;} catch (e) {&#xA;    console.log(e.code);&#xA;    console.log(e.msg);&#xA;}&#xA;

    &#xA;

    I get the following error :

    &#xA;

    Error: Command failed: ffmpeg -i ./original.mp4  ./new.mp4&#xA;/bin/sh: ffmpeg: command not found&#xA;&#xA;    at ChildProcess.exithandler (child_process.js:390:12)&#xA;    at ChildProcess.emit (events.js:400:28)&#xA;    at maybeClose (internal/child_process.js:1055:16)&#xA;    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {&#xA;  killed: false,&#xA;  code: 127,&#xA;  signal: null,&#xA;  cmd: &#x27;ffmpeg -i ./original.mp4  ./new.mp4&#x27;&#xA;}&#xA;

    &#xA;

  • sent file using axios using passthrough stream module in nodejs

    12 août 2022, par Harikrushna Patel

    Imports

    &#xA;

    const ffmpegPath = require(&#x27;@ffmpeg-installer/ffmpeg&#x27;).path;&#xA;const FfmpegCommand = require(&#x27;fluent-ffmpeg&#x27;);&#xA;const fs = require(&#x27;fs&#x27;);&#xA;const path = require(&#x27;path&#x27;);&#xA;const streamNode = require(&#x27;stream&#x27;);&#xA;const FormData = require(&#x27;form-data&#x27;);&#xA;const axios = require(&#x27;axios&#x27;).default;&#xA;

    &#xA;

    Code here

    &#xA;

    async function audios() {&#xA;  let stream = fs.createReadStream(path.join(__dirname, &#x27;../videos/video.mp4&#x27;));&#xA;  let writeStream = fs.createWriteStream(path.join(__dirname, &#x27;../response/audios/&#x27; &#x2B; &#x2B;new Date() &#x2B; &#x27;.wav&#x27;));&#xA;  let pass = new streamNode.PassThrough();&#xA;  let outputFile = path.join(__dirname, &#x27;../response/audios/&#x27; &#x2B; &#x2B;new Date() &#x2B; &#x27;.wav&#x27;);&#xA;  const ffmpeg = FfmpegCommand(file);&#xA;&#xA;  ffmpeg&#xA;    .setFfmpegPath(ffmpegPath)&#xA;    .format(&#x27;mp4&#x27;)&#xA;    .toFormat(&#x27;wav&#x27;)&#xA;    .on(&#x27;end&#x27;, function () {&#xA;      console.log(&#x27;file has been converted successfully&#x27;);&#xA;    })&#xA;    .on(&#x27;error&#x27;, function (err, stdout, stderr) {&#xA;      console.log(&#x27;an error happened: &#x27; &#x2B; err.message);&#xA;      console.log(&#x27;ffmpeg stdout: &#x27; &#x2B; stdout);&#xA;      console.log(&#x27;ffmpeg stderr: &#x27; &#x2B; stderr);&#xA;    })&#xA;    .on(&#x27;end&#x27;, function() {&#xA;      console.log(&#x27;Processing finished !&#x27;);&#xA;    })&#xA;    .stream(pass, { end: false })&#xA;    var bodyFormData = new FormData();&#xA;    bodyFormData.append(&#x27;file&#x27;, pass);&#xA;    let headers = bodyFormData.getHeaders(); &#xA;&#xA;    try {&#xA;      const jdata = await axios.post(&#x27;http://localhost:4080/video&#x27;,bodyFormData, {    maxContentLength: Infinity,&#xA;      maxBodyLength: Infinity,validateStatus: (status) => true ,headers:headers });&#xA;      console.log(jdata.data);&#xA;    } catch (error) {&#xA;      console.log("error" ,error.message);&#xA;    }&#xA;&#xA;}&#xA;

    &#xA;

    I am getting errors to sent passthrough stream through formdata ;&#xA;issue is ffmpeg not creating readstrem so I am created passthrough from it and passed in formdata but not working right now

    &#xA;