Recherche avancée

Médias (91)

Autres articles (37)

  • 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

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

  • Configuration spécifique pour PHP5

    4 février 2011, par

    PHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
    Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
    Modules spécifiques
    Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)

Sur d’autres sites (3394)

  • Start and end time of MoviePy's VideoClip not working

    21 mars 2024, par ernesto casco velazquez

    I'm trying to add captions to a video. The desired outcome is to show each word in the exact moment is being said.

    


    I have a method that gives me the accurate time start and end per each word :

    


    def get_words_per_time(audio_speech_file):
    model = whisper.load_model("base")
    transcribe = model.transcribe(
        audio=audio_speech_file, fp16=False, word_timestamps=True
    )
    segments = transcribe["segments"]
    words = []

    for seg in segments:
        for word in seg["words"]:
            words.append(
                {
                    "word": word["word"],
                    "start": word["start"],
                    "end": word["end"],
                    "prob": round(word["probability"], 4),
                }
            )
    return words


    


    Then I have a code that uses MoviePy to create TextClip and assing a given start and end time per pair of words (I know there are redundant statements, srry) :

    


    def generate_captions(
    words,
    font="Komika",
    fontsize=32,
    color="White",
    align="center",
    stroke_width=3,
    stroke_color="black",
):
    text_comp = []
    for i in track(range(0, len(words), 2), description="Creating captions..."):
        word1 = words[i]
        if i + 1 < len(words):
            word2 = words[i + 1]
        text_clip = TextClip(
            f"{word1['word']} {word2['word'] if i + 1 < len(words) else ''}",
            font=font,  # Change Font if not found
            fontsize=fontsize,
            color=color,
            align=align,
            method="caption",
            size=(660, None),
            stroke_width=stroke_width,
            stroke_color=stroke_color,
        )
        text_clip = text_clip.set_start(word1["start"])
        text_clip = text_clip.set_end(
            word2["end"] if i + 1 < len(words) else word1["end"]
        )
        text_comp.append(text_clip)
    return text_comp


    


    Finally, I concatenate the words into a single video :

    


    vid_clip = CompositeVideoClip(
    [vid_clip, concatenate_videoclips(text_comp).set_position(("center", 860))]
)


    


    The output is this, but you can clearly see the words are not flowing with the speech. They somehow move faster as if the start/end time did not matter. Here's the video

    


    The words with their respective start/end time, look like this :

    


    [
    {
        'word': 'This',
        'start': 0.0,
        'end': 0.22,
        'prob': 0.805
    },
    {
        'word': 'is',
        'start': 0.22,
        'end': 0.42,
        'prob': 0.9991
    },
    {
        'word': 'a',
        'start': 0.42,
        'end': 0.6,
        'prob': 0.999
    },
    {
        'word': 'test,
        ',
        'start': 0.6,
        'end': 1.04,
        'prob': 0.9939
    },
    {
        'word': 'to',
        'start': 1.18,
        'end': 1.3,
        'prob': 0.9847
    },
    {
        'word': 'show',
        'start': 1.3,
        'end': 1.54,
        'prob': 0.9971
    },
    {
        'word': 'words',
        'start': 1.54,
        'end': 1.9,
        'prob': 0.995
    },
    {
        'word': 'does',
        'start': 1.9,
        'end': 2.16,
        'prob': 0.997
    },
    {
        'word': 'not',
        'start': 2.16,
        'end': 2.4,
        'prob': 0.9978
    },
    {
        'word': 'appear.',
        'start': 2.4,
        'end': 2.82,
        'prob': 0.9984
    },
    {
        'word': 'At',
        'start': 3.46,
        'end': 3.6,
        'prob': 0.9793
    },
    {
        'word': 'their',
        'start': 3.6,
        'end': 3.8,
        'prob': 0.9984
    },
    {
        'word': 'proper',
        'start': 3.8,
        'end': 4.22,
        'prob': 0.9976
    },
    {
        'word': 'time.',
        'start': 4.22,
        'end': 4.72,
        'prob': 0.999
    },
    {
        'word': 'Thanks',
        'start': 5.04,
        'end': 5.4,
        'prob': 0.9662
    },
    {
        'word': 'for,
        ',
        'start': 5.4,
        'end': 5.66,
        'prob': 0.9941
    },
    {
        'word': 'watching.',
        'start': 5.94,
        'end': 6.36,
        'prob': 0.7701
    }
]


    


    What could be causing this ?

    


  • Socket.io client in js and server in Socket.io go doesn't send connected messege and data

    24 mars 2023, par OmriHalifa

    I am using ffmpeg and socket.io and I have some issues. I'm trying to send a connection request to a server written in Go through React, but I'm unable to connect to it. I tried adding the events in useEffect and it's still not working, what should I do ? i attaching my code in js and in go :
main.go

    


    package main

import (
    "log"

    "github.com/gin-gonic/gin"

    socketio "github.com/googollee/go-socket.io"
)

func main() {
    router := gin.New()

    server := socketio.NewServer(nil)

    server.OnConnect("/", func(s socketio.Conn) error {
        s.SetContext("")
        log.Println("connected:", s.ID())
        return nil
    })

    server.OnEvent("/", "notice", func(s socketio.Conn, msg string) {
        log.Println("notice:", msg)
        s.Emit("reply", "have "+msg)
    })

    server.OnEvent("/", "transcoded-video", func(s socketio.Conn, data string) {
        log.Println("transcoded-video:", data)
    })

    server.OnEvent("/", "bye", func(s socketio.Conn) string {
        last := s.Context().(string)
        s.Emit("bye", last)
        s.Close()
        return last
    })

    server.OnError("/", func(s socketio.Conn, e error) {
        log.Println("meet error:", e)
    })

    server.OnDisconnect("/", func(s socketio.Conn, reason string) {
        log.Println("closed", reason)
    })

    go func() {
        if err := server.Serve(); err != nil {
            log.Fatalf("socketio listen error: %s\n", err)
        }
    }()
    defer server.Close()

    if err := router.Run(":8000"); err != nil {
        log.Fatal("failed run app: ", err)
    }
}



    


    App.js

    


    import &#x27;./App.css&#x27;;&#xA;import { useEffect } from &#x27;react&#x27;;&#xA;import { createFFmpeg, fetchFile } from &#x27;@ffmpeg/ffmpeg&#x27;;&#xA;import { io } from &#x27;socket.io-client&#x27;; &#xA;&#xA;function App() {&#xA;  const socket = io("http://localhost:8000",function() {&#xA;    // Send a message to the server when the client is connected&#xA;    socket.emit(&#x27;clientConnected&#x27;, &#x27;Client has connected to the server!&#x27;);&#xA;  })&#xA;&#xA;  const ffmpegWorker = createFFmpeg({&#xA;    log: true&#xA;  })&#xA;&#xA;  // Initialize FFmpeg when the component is mounted&#xA;  async function initFFmpeg() {&#xA;    await ffmpegWorker.load();&#xA;  }&#xA;&#xA;  async function transcode(webcamData) {&#xA;    const name = &#x27;record.webm&#x27;;&#xA;    await ffmpegWorker.FS(&#x27;writeFile&#x27;, name, await fetchFile(webcamData));&#xA;    await ffmpegWorker.run(&#x27;-i&#x27;, name, &#x27;-preset&#x27;, &#x27;ultrafast&#x27;, &#x27;-threads&#x27;, &#x27;4&#x27;, &#x27;output.mp4&#x27;);&#xA;    const data = ffmpegWorker.FS(&#x27;readFile&#x27;, &#x27;output.mp4&#x27;);&#xA;    &#xA;    // Set the source of the output video element to the transcoded video data&#xA;    const video = document.getElementById(&#x27;output-video&#x27;);&#xA;    video.src = URL.createObjectURL(new Blob([data.buffer], { type: &#x27;video/mp4&#x27; }));&#xA;    &#xA;    // Remove the output.mp4 file from the FFmpeg virtual file system&#xA;    ffmpegWorker.FS(&#x27;unlink&#x27;, &#x27;output.mp4&#x27;);&#xA;    &#xA;    // Emit a "transcoded-video" event to the server with the transcoded video data&#xA;    socket.emit("transcoded-video", data.buffer)&#xA;  }&#xA;  &#xA;  &#xA;&#xA;  let mediaRecorder;&#xA;  let chunks = [];&#xA;  &#xA;  // Request access to the user&#x27;s camera and microphone and start recording&#xA;  function requestMedia() {&#xA;    const webcam = document.getElementById(&#x27;webcam&#x27;);&#xA;    navigator.mediaDevices.getUserMedia({ video: true, audio: true })&#xA;    .then(async (stream) => {&#xA;      webcam.srcObject = stream;&#xA;      await webcam.play();&#xA;&#xA;      // Set up a MediaRecorder instance to record the video and audio&#xA;      mediaRecorder = new MediaRecorder(stream);&#xA;&#xA;      // Add the recorded data to the chunks array&#xA;      mediaRecorder.ondataavailable = async (e) => {&#xA;        chunks.push(e.data);&#xA;      }&#xA;&#xA;      // Transcode the recorded video data after the MediaRecorder stops&#xA;      mediaRecorder.onstop = async () => {&#xA;        await transcode(new Uint8Array(await (new Blob(chunks)).arrayBuffer()));&#xA;&#xA;        // Clear the chunks array after transcoding&#xA;        chunks = [];&#xA;&#xA;        // Start the MediaRecorder again after a 0 millisecond delay&#xA;        setTimeout(() => {&#xA;          mediaRecorder.start();&#xA;          &#xA;          // Stop the MediaRecorder after 3 seconds&#xA;          setTimeout(() => {&#xA;            mediaRecorder.stop();&#xA;          }, 500);&#xA;        }, 0);&#xA;      }&#xA;&#xA;      // Start the MediaRecorder&#xA;      mediaRecorder.start();&#xA;&#xA;      // Stop the MediaRecorder after 3 seconds&#xA;      setTimeout(() => {&#xA;        mediaRecorder.stop();&#xA;      }, 700);&#xA;    })&#xA;  }&#xA;  &#xA;  useEffect(() => {&#xA;    // Set up event listeners for the socket connection&#xA;    socket.on(&#x27;/&#x27;, function(){&#xA;      // Log a message when the client is connected to the server&#xA;      console.log("Connected to server!"); &#xA;    });&#xA;&#xA;    socket.on(&#x27;transcoded-video&#x27;, function(data){&#xA;      // Log the received data for debugging purposes&#xA;      console.log("Received transcoded video data:", data); &#xA;    });&#xA;&#xA;    socket.on(&#x27;notice&#x27;, function(data){&#xA;      // Emit a "notice" event back to the server to acknowledge the received data&#xA;      socket.emit("notice", "ping server!");&#xA;    });&#xA;&#xA;    socket.on(&#x27;bye&#x27;, function(data){&#xA;      // Log the received data and disconnect from the server&#xA;      console.log("Server sent:", data); &#xA;      socket.disconnect();&#xA;    });&#xA;&#xA;    socket.on(&#x27;disconnect&#x27;, function(){&#xA;      // Log a message when the client is disconnected from the server&#xA;      console.log("Disconnected from server!"); &#xA;    });&#xA;  }, [])&#xA;&#xA;  return (&#xA;    <div classname="App">&#xA;      <div>&#xA;          <video muted="{true}"></video>&#xA;          <video autoplay="autoplay"></video>&#xA;      </div>&#xA;      <button>start streaming</button>&#xA;    </div>&#xA;  );&#xA;}&#xA;&#xA;export default App;&#xA;

    &#xA;

    What can i do to fix it ? thank you !!

    &#xA;

  • Is there a way to send ffmpeg data directly to a TCP Client ?

    3 février 2021, par KosmosisDire

    I am using ffmpeg to send screen capture directly to a C# TCP server. However, due to some bug or technical limitation, the Quest 2 (my build device) cannot bind ports. (There is very little info regarding this bug online, but as far as I can tell I can't get around it). So I cannot have a C# server on the Quest, I must have a client on the quest to receive data. However, ffmpeg sends data as a TCP client. So I need ffmpeg to act as a server.

    &#xA;

    I tried sending the data through a server on my computer that then sends the data to the C# client. But I get less than 1 fps with huge lag. Normally, I get a good 30 fps with low latency when sending directly to a server.

    &#xA;

    So my question :

    &#xA;

    Is there a way to get ffmpeg data directly to a client, or indirectly without increasing the latency ?

    &#xA;

    Here is the ffmpeg command I am using :

    &#xA;

    ffmpeg -f gdigrab -i desktop -pixel_format rgb8 -video_size 896x504 -vf scale=896:504 -framerate 5 -r 30 -f rawvideo tcp://127.0.0.1:846&#xA;

    &#xA;

    I can include code for my C# client and server attempts as well as the middleman server, if I need.

    &#xA;

    Thanks for any help !

    &#xA;