Recherche avancée

Médias (91)

Autres articles (43)

  • MediaSPIP : Modification des droits de création d’objets et de publication définitive

    11 novembre 2010, par

    Par défaut, MediaSPIP permet de créer 5 types d’objets.
    Toujours par défaut les droits de création et de publication définitive de ces objets sont réservés aux administrateurs, mais ils sont bien entendu configurables par les webmestres.
    Ces droits sont ainsi bloqués pour plusieurs raisons : parce que le fait d’autoriser à publier doit être la volonté du webmestre pas de l’ensemble de la plateforme et donc ne pas être un choix par défaut ; parce qu’avoir un compte peut servir à autre choses également, (...)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (8025)

  • writing jpg images from ffmpeg pipe

    18 septembre 2024, par seandoucette

    Using php to read an rtsp stream from an ffmpeg command utilizing image2pipe, I'm finding the images are truncated in some manner and only display a partial image. My task is to write unique jpg filenames at 30fps. Below is the php code. I've simplified the filename structure in this example for clarity. The script performs as expected with no obvious errors writing out 30fps consistently. I can't figure out what extraneous or missing information in the content is causing the output images to appear corrupt.

    


    $cmd = "ffmpeg -rtsp_transport tcp -framerate 30 -i rtsp://".$camera_url." -f image2pipe pipe:1";

$fp = popen($cmd, 'r');

if (!$fp)
{
    die('Could not open ffmpeg process');
}

define('JPEG_START', "\xFF\xD8");
define('JPEG_END', "\xFF\xD9");

$buffer = '';
$jpeg = '';
$isReadingJpeg = false;

stream_set_blocking($fp, false); // Set non-blocking mode

while (!feof($fp))
{
    $chunk = fread($fp, 4096);

    if ($chunk === false)
    {
        usleep(100);
        continue;
    }

    $buffer .= $chunk;

    if (!$isReadingJpeg && ($startPos = strpos($buffer, JPEG_START)) !== false)
    {
        $isReadingJpeg = true;
        $jpeg = substr($buffer, $startPos);
        $buffer = substr($buffer, $startPos + 2);  // Move past the start marker
    }

    if ($isReadingJpeg && ($endPos = strpos($buffer, JPEG_END)) !== false)
    {
        $jpeg .= substr($buffer, 0, $endPos + 2);
        $buffer = substr($buffer, $endPos + 2);  // Move past the end marker

        file_put_contents(microtime(true),$jpeg);

        $isReadingJpeg = false;
        $jpeg = '';
    }

    if ($isReadingJpeg)
    {
        $jpeg .= $buffer;
        $buffer = '';
    }
}

pclose($fp);


    


  • Combining Video and Audio Buffers in Memory Using FFmpeg and Python

    22 août 2024, par RUBICK

    I need to combine video and audio streams into a single MP4 file. My goal is to handle this entirely in memory and then send the resulting file directly to the user without storing any files on disk.

    


    I am consistently facing problems with the FFmpeg process when trying to combine the video and audio streams

    


    @bot.callback_query_handler(func=lambda call: call.data.startswith("download_mp4"))
def handle_download_mp4(call):
    itag, url = call.data.split("|")[1:]
    yt = YouTube(url)
    
    video_stream = yt.streams.get_by_itag(itag)
    audio_stream = yt.streams.filter(only_audio=True).first()

    video_buffer = io.BytesIO()
    audio_buffer = io.BytesIO()

    # downloading video and audio to memory
    video_stream.stream_to_buffer(video_buffer)
    audio_stream.stream_to_buffer(audio_buffer)

    video_buffer.seek(0)
    audio_buffer.seek(0)
    combined_buffer = io.BytesIO()

    process = None
    try:
        process = (
            ffmpeg
            .input('pipe:0')
            .input('pipe:1')
            .output('pipe:2', format='mp4', vcodec='libx264', acodec='aac')
            .run_async(pipe_stdin=True, pipe_stdout=True, pipe_stderr=True)
        )

        # video and audio buffers to ffmpeg stdin
        process.stdin.write(video_buffer.read())
        process.stdin.write(audio_buffer.read())
        process.stdin.close()

        combined_buffer.write(process.stdout.read())
        process.wait()
        combined_buffer.seek(0)
        
    except Exception as e:
        bot.send_message(call.message.chat.id, f"Error during processing: {str(e)}")
        if process:
            process.kill()
        return

    file_size = combined_buffer.getbuffer().nbytes

    if file_size > MAX_FILE_SIZE:
        bot.send_message(call.message.chat.id, "The combined file is too large to download :(")
        combined_buffer.close()
        return

    # sending combined bufer to user
    bot.send_document(call.message.chat.id, combined_buffer, visible_file_name=f"{yt.title}.mp4")


    


    Here's the workflow I'm aiming for :

    


    1. Download video and audio streams from YouTube.
2. Combine these streams in memory using FFmpeg.
3. Send the combined MP4 file to the user.

    


    Im using pytube to download the video and audio streams and ffmpeg to merge them. However, I'm encountering issues with the combination process. Specifically, I’m struggling with how to correctly handle merging the video and audio streams using in-memory buffers

    


  • How to set the ffmpeg path in a Windows Electron app

    21 août 2024, par Arco Voltaico

    My electron app has these dependencies at app folder level (node), not /src (angular) :

    


        "ffmpeg-static-electron": "2.0.3",
    "fluent-ffmpeg-corrected": "1.0.0",


    


    On main.ts I execute this function :

    


    function initFfmpeg() {
    const p = detectPlatformAndArch();
    const originalPath = ffmpegBin.path;
    let ffmpegPath2 = originalPath;
    if (!serve) {
        console.log('Running in packaged mode');

        if (p.os !== 'mac') {
             // forcing for now win x64
             ffmpegPath2 = path.join(process.resourcesPath, 'app.asar.unpacked', 'node_modules', 'ffmpeg-static-electron', 'bin', 'win', 'x64', 'ffmpeg.exe');
        }
....
    } 
....
    ffmpeg.setFfmpegPath(ffmpegPath2);
    mainWindow.webContents.send('ffmpegPath', {"path": ffmpegPath2, "originalPath": originalPath});
}


    


    When the electron is compiled/packed and running in a Mac, ffmpeg works, but in Windows does not.
I suspect the path is not the right one on the latter.

    


    I have no acccess to the Win PC, so I'm sending the path values to the mainWindow and there I persist it to a DB, so I know the ffmpegPath2 is :
C:\Users\aran\AppData\Local\Temp\2kQuOPO86a60WbRClif2pSzIOMn\resources\app.asar.unpacked\node_modules\ffmpeg-static-electron\bin\win\x64\ffmpeg.exe

    


    when in my Mac from where I code it is :

    


    /Users/me/myApp/release/win-unpacked/resources/app.asar.unpacked/node_modules/ffmpeg-static-electron/bin/win/x64/ffmpeg.exe