Recherche avancée

Médias (2)

Mot : - Tags -/media

Autres articles (102)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

Sur d’autres sites (8264)

  • Firebase cloud function fluent-ffmpeg resize and convert

    16 août 2023, par Romeo

    In the firebase cloud functions I upload a video in .webm format, I want to resize it and convert it to .mp4.
I am able to generate a file, and reupload the generated file to the firebase storage bucket.

    


    Problem is : the file is unreadable.
How can I assess the file integrity and attributes before and after conversion ?

    


    this is the code of my firebase cloud function :

    


    /**
 * When a video is uploaded in the Storage bucket,
 * generate a resizing and if it's a webm file convert in mp4.
 */

export const resizeVideo = functions.storage.object().onFinalize(async (object) => {
  console.log(`Processing file: ${object.name}`);
  const tempFilePath = path.join(os.tmpdir(), object.name + "");
  const resizedTempFilePath = path.join(os.tmpdir(), "resized_" + object.name?.replace("webm", "mp4"));
  if (object.name?.includes("resized_")) {
    console.log("Already resized");
    return false;
  }
  return new Promise(()=>{
    ffmpeg(tempFilePath)
    .format("mp4")
    .toFormat("mp4")
    .size("1920x1080")
    .videoCodec("libx264")
    .audioCodec("aac")
    .audioBitrate("128k")
    .audioChannels(2)
    .withAudioBitrate("128k")
    .withAudioChannels(2)
    .withAudioCodec("aac")
    .withVideoCodec("libx264")
    .withVideoBitrate("1000k")
    .withSize("1920x1080")
    .outputOptions([
      '-c:v libx264',
      '-c:a aac',
      '-pix_fmt yuv420p',
      '-profile:v main',
      '-level 3.1',
      '-movflags +faststart',
      '-max_muxing_queue_size 9999',
    ])
    .output(resizedTempFilePath)
    .save(resizedTempFilePath)
    .on("error", function(err: { message: any; }, stdout: any, stderr: any) {
      console.log("Error on resize ", err.message);
      console.log("stdout ", stdout);
      console.log("stderr ", stderr);
    })
    .on("end", function() {
      console.log("Finished resizing! ", resizedTempFilePath);
      fs.readdirSync(os.tmpdir()).forEach((file) =>{
        if (file === ("resized_" + object.name?.replace("webm", "mp4"))){
          console.log(`${resizedTempFilePath} created!`);
          admin.storage().bucket().upload(path.join(os.tmpdir(), "resized_" + object.name), {
            destination: "resized_" + object.name?.replace("webm", "mp4"),
            metadata: {
              contentType: "video/mp4",
            },
          }).then(() => {
            console.log(`Uploaded ${resizedTempFilePath}`);
          }
          ).catch((err) => {
            console.log(`Error on upload ${resizedTempFilePath}`, err);
          }
          );
        }
      });
    });
  });
});


    


  • How do I get ffmpeg.exe to function on a cloud hosting site like Discloud ?

    16 septembre 2023, par Sc4rl3ttfir3

    So to keep my Discord bot running 24/7, I use the hosting site Discloud. I just added music playing capabilities to my bot, and they function fine when I run the bot locally, because it can access the .exe file for ffmpeg through the file path I have put in the code through the play command.

    


    Code :

    


    @bot.command(name='play', help='To play song')
async def play(ctx, url):
    voice_channel = ctx.author.voice.channel

    if voice_channel is None:
        return await ctx.send('You are not connected to a voice channel.')

    async with ctx.typing():
        filename = await YTDLSource.from_url(url, loop=bot.loop)
        
        if ctx.voice_client is not None:
            ctx.voice_client.stop()

        source = discord.FFmpegPCMAudio(
            executable="C:\\Users\\Scarlett Rivera\\Documents\\ffmpeg\\ffmpeg.exe",
            source=filename
        )
        
        voice_channel.play(source)

    await ctx.send('**Now playing:** {}'.format(filename))


    


    However, whenever I try to use the play command while the bot is running through Discloud, it gives me this error in the logs :

    


    Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, in wrapped
ret = await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user_686208406444572830/Sc4rl3ttb0t.py", line 351, in play
source = discord.FFmpegPCMAudio(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/discord/player.py", line 290, in __init__
super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
File "/usr/local/lib/python3.11/site-packages/discord/player.py", line 166, in __init__
self._process = self._spawn_process(args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/discord/player.py", line 183, in _spawn_process
raise ClientException(executable + ' was not found.') from None
discord.errors.ClientException: C:\Users\Scarlett Rivera\Documents\ffmpeg\ffmpeg.exe was not found.
  
The above exception was the direct cause of the following exception:
 
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1029, in invoke
await injected(*ctx.args, **ctx.kwargs)  # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/discord/ext/commands/core.py", line 244, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: C:\Users\Scarlett Rivera\Documents\ffmpeg\ffmpeg.exe was not found.


    


    I've tried reaching out to another programmer who helped me yesterday with programming my bot to fulfill the main purpose I wanted from it, and they weren't able to come up with anything because they don't have any experience with Discloud. If anyone at all could help me, that would be extremely appreciated

    


  • Empty error object produced by ffprobe in Google Cloud Function

    20 septembre 2023, par willbattel

    Update : After more digging I found an open GitHub issue where others appear to be encountering the same behavior.

    



    


    I have a Google Cloud Function (2nd gen) in which I am trying to use ffprobe to get metadata from a video file stored in a Google Cloud Storage bucket. It is my understanding that I can generate a signed url and, by passing that directly to ffprobe, avoid loading the entire video file into memory. I generate a signed url and pass it to ffprobe, and then parse the output like so :

    


    import ffmpeg from 'fluent-ffmpeg'
import ffprobeStatic from 'ffprobe-static'

async function getVideoData(srcFile: File) {
    const [signedUrl] = await srcFile.getSignedUrl({
        action: 'read',
        expires: (new Date()).getMilliseconds() + 60_000,
    })

    const videoData: ffmpeg.FfprobeData = await new Promise((resolve, reject) => {
        ffmpeg.setFfprobePath(ffprobeStatic.path)
        ffmpeg.ffprobe(signedUrl, (err, data) => {
            if (err) {
                reject(err)
            }
            else {
                resolve(data)
            }
        })
    })

    return videoData
}


    


    This code works (with the same signed URL) locally on my macOS machine, but does not when deployed in a 2nd generation Google Cloud Function. In the latter case, data is undefined and err is {}.

    


    My main question is how to properly use ffprobe in 2nd gen Google Cloud Functions. I have tried to research this but documentation on ffmpeg/ffprobe on GCP is sparse. I'm also trying to figure out exactly why the error object err is empty...it's not very helpful 😅

    


    Additional info :

    


      

    • Environment : Google Cloud Functions 2nd Gen
    • 


    • Runtime : Node 20
    • 


    • "ffprobe-static" : "3.1.0",
    • 


    • "fluent-ffmpeg" : "2.1.2"
    • 


    


    Thanks in advance.