Recherche avancée

Médias (0)

Mot : - Tags -/alertes

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

Autres articles (56)

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

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

Sur d’autres sites (8122)

  • React Native (Android) : Download mp3 file

    21 février 2024, par Batuhan Fındık

    I get the youtube video link from the ui. I download the video from this link and convert it to mp3. I download it to my phone as mp3. The song opens on WhatsApp on the phone. but it doesn't open on the mp3 player. The song is not broken because it opens on WhatsApp too. Why do you think the mp3 player doesn't open ? Could it be from the file information ? I tried to enter some file information but it still won't open. For example, there is from information in songs played on an mp3 player. There is no from information in my song file. I tried to add it but it wasn't added.

    


    .net 8 api return :

    


        [HttpPost("ConvertVideoToMp3")]&#xA;public async Task<iactionresult> ConvertVideoToMp3(Mp3 data)&#xA;{&#xA;    try&#xA;    {&#xA;        string videoId = GetYoutubeVideoId(data.VideoUrl);&#xA;&#xA;        var streamInfoSet = await _youtubeClient.Videos.Streams.GetManifestAsync(videoId);&#xA;        var videoStreamInfo = streamInfoSet.GetAudioOnlyStreams().GetWithHighestBitrate();&#xA;&#xA;        if (videoStreamInfo != null)&#xA;        {&#xA;            var videoStream = await _youtubeClient.Videos.Streams.GetAsync(videoStreamInfo);&#xA;            var memoryStream = new MemoryStream();&#xA;&#xA;            await videoStream.CopyToAsync(memoryStream);&#xA;            memoryStream.Seek(0, SeekOrigin.Begin);&#xA;&#xA;            var videoFilePath = $"{videoId}.mp4";&#xA;            await System.IO.File.WriteAllBytesAsync(videoFilePath, memoryStream.ToArray());&#xA;&#xA;            var mp3FilePath = $"{videoId}.mp3";&#xA;            var ffmpegProcess = Process.Start(new ProcessStartInfo&#xA;            {&#xA;                FileName = "ffmpeg",&#xA;                Arguments = $"-i \"{videoFilePath}\" -vn -acodec libmp3lame -ab 128k -id3v2_version 3 -metadata artist=\"YourArtistName\" -metadata title=\"YourTitle\" -metadata from=\"youtube\" \"{mp3FilePath}\"",&#xA;                RedirectStandardError = true,&#xA;                UseShellExecute = false,&#xA;                CreateNoWindow = true&#xA;            });&#xA;&#xA;            await ffmpegProcess.WaitForExitAsync();&#xA;&#xA;            var file = TagLib.File.Create(mp3FilePath);&#xA;&#xA;   &#xA;            file.Tag.Artists = new string [] { "YourArtistName"};&#xA;            file.Tag.Title = "YourTitle";&#xA;            file.Tag.Album = "YourAlbumName"; &#xA;            file.Tag.Comment = "Source: youtube";&#xA;  &#xA;&#xA;            file.Save();&#xA;&#xA;            var mp3Bytes = await System.IO.File.ReadAllBytesAsync(mp3FilePath);&#xA;&#xA;            System.IO.File.Delete(videoFilePath);&#xA;            System.IO.File.Delete(mp3FilePath);&#xA;&#xA;            return File(mp3Bytes, "audio/mpeg", $"{videoId}.mp3");&#xA;        }&#xA;        else&#xA;        {&#xA;            return NotFound("Video stream not found");&#xA;        }&#xA;    }&#xA;    catch (Exception ex)&#xA;    {&#xA;        return StatusCode(500, $"An error occurred: {ex.Message}");&#xA;    }&#xA;}&#xA;</iactionresult>

    &#xA;

    React Native :

    &#xA;

         const handleConvertAndDownload = async () => {&#xA;    try {&#xA;      const url = &#x27;http://192.168.1.5:8080/api/Mp3/ConvertVideoToMp3&#x27;;&#xA;      const fileName = &#x27;example&#x27;;&#xA;      const newFileName = generateUniqueSongName(fileName);&#xA;      const filePath = RNFS.DownloadDirectoryPath &#x2B; &#x27;/&#x27;&#x2B;newFileName;&#xA;&#xA;      fetch(url, {&#xA;        method: &#x27;POST&#x27;,&#xA;        headers: {&#xA;          &#x27;Content-Type&#x27;: &#x27;application/json&#x27;,&#xA;        },&#xA;        body: JSON.stringify({videoUrl:videoUrl}),&#xA;      })&#xA;      .then((response) => {&#xA;        if (!response.ok) {&#xA;          Alert.alert(&#x27;Error&#x27;, &#x27;Network&#x27;);&#xA;          throw new Error(&#x27;Network response was not ok&#x27;);&#xA;        }&#xA;        return response.blob();&#xA;      })&#xA;      .then((blob) => {&#xA;        return new Promise((resolve, reject) => {&#xA;          const reader = new FileReader();&#xA;          reader.onloadend = () => {&#xA;            resolve(reader.result.split(&#x27;,&#x27;)[1]); &#xA;          };&#xA;          reader.onerror = reject;&#xA;          reader.readAsDataURL(blob);&#xA;        });&#xA;      })&#xA;      .then((base64Data) => {&#xA;        // Dosyanın varlığını kontrol et&#xA;        return RNFS.exists(filePath)&#xA;          .then((exists) => {&#xA;            if (exists) {&#xA;              console.log(&#x27;File already exists&#x27;);&#xA;              return RNFS.writeFile(filePath, base64Data, &#x27;base64&#x27;, &#x27;append&#x27;);&#xA;            } else {&#xA;              console.log(&#x27;File does not exist&#x27;);&#xA;              return RNFS.writeFile(filePath, base64Data, &#x27;base64&#x27;);&#xA;            }&#xA;          })&#xA;          .catch((error) => {&#xA;            console.error(&#x27;Error checking file existence:&#x27;, error);&#xA;            throw error;&#xA;          });&#xA;      })&#xA;      .then(() => {&#xA;        Alert.alert(&#x27;Success&#x27;, &#x27;MP3 file downloaded successfully.&#x27;);&#xA;        console.log(&#x27;File downloaded successfully!&#x27;);&#xA;      })&#xA;      .catch((error) => {&#xA;        Alert.alert(&#x27;Error&#x27;, error.message);&#xA;        console.error(&#x27;Error downloading file:&#x27;, error);&#xA;      });&#xA;    } catch (error) {&#xA;      Alert.alert(&#x27;Error&#x27;, error.message);&#xA;      console.error(error);&#xA;    }&#xA;  };&#xA;

    &#xA;

  • How to Correctly Implement ffmpeg Complex Filters in Node.js for Image Processing ?

    24 janvier 2024, par Luke

    Problem :

    &#xA;

    I am trying to add filters and transitions between my image slideshow array, and am struggling to apply the proper filters. For example, I get errors like this :

    &#xA;

    {&#xA;  "errorType": "Error",&#xA;  "errorMessage": "ffmpeg exited with code 234: Failed to set value &#x27;fade=type=in:start_time=0:duration=1,zoompan=z=zoom&#x2B;0.002:d=120:x=if(gte(zoom,1.2),x,x&#x2B;1):y=if(gte(zoom,1.2),y,y&#x2B;1)&#x27; for option &#x27;filter_complex&#x27;: Invalid argument\nError parsing global options: Invalid argument\n",&#xA;  "trace": [&#xA;    "Error: ffmpeg exited with code 234: Failed to set value &#x27;fade=type=in:start_time=0:duration=1,zoompan=z=zoom&#x2B;0.002:d=120:x=if(gte(zoom,1.2),x,x&#x2B;1):y=if(gte(zoom,1.2),y,y&#x2B;1)&#x27; for option &#x27;filter_complex&#x27;: Invalid argument",&#xA;    "Error parsing global options: Invalid argument",&#xA;    "",&#xA;    "    at ChildProcess.<anonymous> (/opt/nodejs/node_modules/fluent-ffmpeg/lib/processor.js:182:22)",&#xA;    "    at ChildProcess.emit (node:events:517:28)",&#xA;    "    at ChildProcess._handle.onexit (node:internal/child_process:292:12)"&#xA;  ]&#xA;}&#xA;</anonymous>

    &#xA;

    Lambda Function Code :

    &#xA;

     async function concat(bucketName, imageKeys) {&#xA;      const imageStreams = await Promise.all(&#xA;        imageKeys.map(async (key, i) => {&#xA;          const command = new GetObjectCommand({ Bucket: bucketName, Key: key });&#xA;          const response = await s3.send(command);&#xA;          // Define the temporary file path based on the index&#xA;          const tempFilePath = `/tmp/${i}.png`;&#xA;    &#xA;          // Write the image data to the temporary file&#xA;          await fs.writeFile(tempFilePath, response.Body);&#xA;    &#xA;          // Return the file path to be used later&#xA;          return tempFilePath;&#xA;        })&#xA;      );&#xA;    &#xA;      // Create a file list content with durations&#xA;      let fileContent = "";&#xA;      for (let i = 0; i &lt; imageStreams.length; i&#x2B;&#x2B;) {&#xA;        fileContent &#x2B;= `file &#x27;${imageStreams[i]}&#x27;\nduration 1\n`;&#xA;    &#xA;        // Check if it&#x27;s the last image, and if so, add it again&#xA;        if (i === imageStreams.length - 1) {&#xA;          fileContent &#x2B;= `file &#x27;${imageStreams[i]}&#x27;\nduration 1\n`;&#xA;        }&#xA;      }&#xA;    &#xA;      // Define the file path for the file list&#xA;      const fileListPath = "/tmp/file_list.txt";&#xA;    &#xA;      // Write the file list content to the file&#xA;      await fs.writeFile(fileListPath, fileContent);&#xA;    &#xA;      try {&#xA;        await fs.writeFile(fileListPath, fileContent);&#xA;      } catch (error) {&#xA;        console.error("Error writing file list:", error);&#xA;        throw error;&#xA;      }&#xA;    &#xA;      // Create a complex filter to add zooms and pans&#xA;      // Simplified filter example&#xA;  let complexFilter = [&#xA;    // Example of a fade transition&#xA;    {&#xA;      filter: &#x27;fade&#x27;,&#xA;      options: { type: &#x27;in&#x27;, start_time: 0, duration: 1 },&#xA;      inputs: &#x27;0:v&#x27;, // first video stream&#xA;      outputs: &#x27;fade0&#x27;&#xA;    },&#xA;    // Example of dynamic zoompan&#xA;    {&#xA;      filter: &#x27;zoompan&#x27;,&#xA;      options: {&#xA;        z: &#x27;zoom&#x2B;0.002&#x27;,&#xA;        d: 120, // duration for this image&#xA;        x: &#x27;if(gte(zoom,1.2),x,x&#x2B;1)&#x27;, // dynamic x position&#xA;        y: &#x27;if(gte(zoom,1.2),y,y&#x2B;1)&#x27; // dynamic y position&#xA;      },&#xA;      inputs: &#x27;fade0&#x27;,&#xA;      outputs: &#x27;zoom0&#x27;&#xA;    }&#xA;    // Continue adding filters for each image&#xA;  ];&#xA;&#xA;  let filterString = complexFilter&#xA;    .map(&#xA;      (f) =>&#xA;        `${f.filter}=${Object.entries(f.options)&#xA;          .map(([key, value]) => `${key}=${value}`)&#xA;          .join(":")}`&#xA;    )&#xA;    .join(",");&#xA;    &#xA;      let filterString = complexFilter&#xA;        .map(&#xA;          (f) =>&#xA;            `${f.filter}=${Object.entries(f.options)&#xA;              .map(([key, value]) => `${key}=${value}`)&#xA;              .join(":")}`&#xA;        )&#xA;        .join(",");&#xA;    &#xA;      console.log("Filter String:", filterString);&#xA;    &#xA;      return new Promise((resolve, reject) => {&#xA;        ffmpeg()&#xA;          .input(fileListPath)&#xA;          .complexFilter(filterString)&#xA;          .inputOptions(["-f concat", "-safe 0"])&#xA;          .outputOptions("-c copy")&#xA;          .outputOptions("-c:v libx264")&#xA;          .outputOptions("-pix_fmt yuv420p")&#xA;          .outputOptions("-r 30")&#xA;          .on("end", () => {&#xA;            resolve();&#xA;          })&#xA;          .on("error", (err) => {&#xA;            console.error("Error during video concatenation:", err);&#xA;            reject(err);&#xA;          })&#xA;          .saveToFile("/tmp/output.mp4");&#xA;      });&#xA;    }&#xA;

    &#xA;

    Filter String Console Log :

    &#xA;

    Filter String: fade=type=in:start_time=0:duration=1,zoompan=z=zoom&#x2B;0.002:d=120:x=if(gte(zoom,1.2),x,x&#x2B;1):y=if(gte(zoom,1.2),y,y&#x2B;1)&#xA;

    &#xA;

    Questions :

    &#xA;

      &#xA;
    1. What is the correct syntax for implementing complex filters like zoompan and fade in ffmpeg when used in a Node.js environment ?
    2. &#xA;

    3. How do I ensure the filters are applied correctly to each image in the sequence ?
    4. &#xA;

    5. Is there a better way to dynamically generate these filters based on the number of images or their content ?
    6. &#xA;

    &#xA;

    Any insights or examples of correctly implementing this would be greatly appreciated !

    &#xA;

  • How do I merge images and an audio file into a single video ?

    3 janvier 2024, par Anil

    I am creating a web application using next js.&#xA;I want to create a video by combining three images and an audio track in such a way that each image is displayed for an equal duration that collectively matches the length of the audio. It will all happen locally on the browser.

    &#xA;

    This is my code for converting images and audio into a video.

    &#xA;

    import {FFmpeg} from &#x27;@ffmpeg/ffmpeg&#x27;;&#xA;import { fetchFile, toBlobURL } from &#x27;@ffmpeg/util&#x27;;&#xA;&#xA;&#xA;export async function createVideo(ImageFiles, audioFile) {&#xA;&#xA;  try {&#xA;    const baseURL = &#x27;https://unpkg.com/@ffmpeg/core@0.12.4/dist/umd&#x27;;&#xA;    const ffmpeg = new FFmpeg({ log: true});&#xA;&#xA;    console.log(&#x27;Loading ffmpeg core&#x27;);&#xA;    await ffmpeg.load({&#xA;      corePath: await toBlobURL(`${baseURL}/ffmpeg-core.js`, &#x27;text/javascript&#x27;),&#xA;      wasmPath: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, &#x27;application/wasm&#x27;),&#xA;    });&#xA;    await ffmpeg.load();&#xA;    console.log(&#x27;Finished loading ffmpeg core&#x27;);&#xA;&#xA;    for (let i = 0; i &lt; ImageFiles.length; i&#x2B;&#x2B;) {&#xA;      ffmpeg.writeFile(&#xA;        `image${i&#x2B;1}.jpg`,&#xA;        await fetchFile(ImageFiles[i].imageUrl)&#xA;      );&#xA;    }&#xA;&#xA;    ffmpeg.FS(&#x27;writeFile&#x27;, &#x27;audio.mp3&#x27;, await fetchFile(audioFile));&#xA;&#xA;&#xA;    const durationPerImage = (await getAudioDuration(ffmpeg, &#x27;audio.mp3&#x27;)) / ImageFiles.length;&#xA;    let filterComplex = &#x27;&#x27;;&#xA;    for (let i = 0; i &lt; ImageFiles.length - 1; i&#x2B;&#x2B;) {filterComplex &#x2B;= `[${i}:v]trim=duration=${durationPerImage},setpts=PTS-STARTPTS[v${i}]; `;&#xA;    }&#xA;    filterComplex &#x2B;= `${ImageFiles.slice(0, -1).map((_, i) => `[v${i}]`).join(&#x27;&#x27;)}concat=n=${ImageFiles.length - 1}:v=1:a=0,format=yuv420p[v];`;&#xA;&#xA;    await ffmpeg.run(&#xA;      &#x27;-framerate&#x27;, &#x27;1&#x27;, &#x27;-loop&#x27;, &#x27;1&#x27;, &#x27;-t&#x27;, durationPerImage, &#x27;-i&#x27;, &#x27;image%d.jpg&#x27;, &#x27;-i&#x27;, &#x27;audio.mp3&#x27;,&#xA;      &#x27;-filter_complex&#x27;, filterComplex, &#x27;-map&#x27;, &#x27;[v]&#x27;, &#x27;-map&#x27;, &#x27;1:a&#x27;,&#xA;      &#x27;-c:v&#x27;, &#x27;libx264&#x27;, &#x27;-tune&#x27;, &#x27;stillimage&#x27;, &#x27;-c:a&#x27;, &#x27;aac&#x27;, &#x27;-b:a&#x27;, &#x27;192k&#x27;, &#x27;output.mp4&#x27;&#xA;    );&#xA;&#xA;    const data = ffmpeg.FS(&#x27;readFile&#x27;, &#x27;output.mp4&#x27;);&#xA;&#xA;    const videoURL = URL.createObjectURL(new Blob([data.buffer], { type: &#x27;video/mp4&#x27; }));&#xA;    return videoURL;&#xA;  } catch (error) {&#xA;    console.error(&#x27;Error creating video:&#x27;, error);&#xA;    throw new Error(&#x27;Failed to create video&#x27;);&#xA;  }&#xA;}&#xA;&#xA;async function getAudioDuration(ffmpeg, audioFilename) {&#xA;  await ffmpeg.run(&#x27;-i&#x27;, audioFilename, &#x27;-show_entries&#x27;, &#x27;format=duration&#x27;, &#x27;-of&#x27;, &#x27;default=noprint_wrappers=1:nokey=1&#x27;, &#x27;duration.txt&#x27;);&#xA;  const data = ffmpeg.FS(&#x27;readFile&#x27;, &#x27;duration.txt&#x27;);&#xA;  const durationString = new TextDecoder().decode(data);&#xA;  const duration = Math.floor(parseFloat(durationString.trim())); &#xA;  return duration;&#xA;}&#xA;

    &#xA;

    I am getting this error :

    &#xA;

    CreateVideo.js:65  Error creating video: RuntimeError: Aborted(LinkError: WebAssembly.instantiate(): Import #70 module="a" function="qa": function import requires a callable). Build with -sASSERTIONS for more info.&#xA;

    &#xA;

    Can someone help me with this ?

    &#xA;