Recherche avancée

Médias (1)

Mot : - Tags -/getid3

Autres articles (60)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • (Dés)Activation de fonctionnalités (plugins)

    18 février 2011, par

    Pour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
    SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
    Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
    MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...)

Sur d’autres sites (11487)

  • ffmpeg app using node occasionally crashes as file doesn't appear to be read correctly

    31 mai 2022, par Zabs

    I have an simple Node application that allows me to pass an AWS S3 URL link to a file (in this case video files). It uses the FFMPEG library to read the video file and return data like codecs, duration, bitrate etc..

    


    The script is called from PHP script which in turn send the data to the Node endpoint and passes the Amazon S3 URL to node. Sometimes for no obvious reasons the video file fails to return the expected values regarding container, codec, duration etc... and just returns '0'. But when I try the exact same file/request again it returns this data correctly e.g container:mp4

    


    I'm not sure but I think the script somehow needs the createWriteStream to be closed but I cannot be sure, the problem is the issue I have found doesn't happen all the time but sporadically so its hard to get to the issue when its difficult to replicate it.

    


    Any ideas ?

    


    router.post('/', async function(req, res) {
  const fileURL = new URL(req.body.file);
  var path = fileURL.pathname;
  path = 'tmp/'+path.substring(1);    // removes the initial / from the path

  let file = fs.createWriteStream(path);  // create the file locally
  const request = https.get(fileURL, function(response) {
    response.pipe(file);
  });
  
  // after file has saved
  file.on('finish', function () {
    var process = new ffmpeg(path);
    process.then(function (video) {
      let metadata = formatMetadata(video.metadata);

      res.send ({
        status: '200',
        data: metadata,
        errors: errors,
        response: 'success'
      });

    }, function (err) {
      console.warn('Error: ' + err);

      res.send ({
        status: '400',
        data: 'Something went wrong processing this video',
        response: 'fail',
      });
    });
  });

  file.on('error', function (err) {
    console.warn(err);
  });

});

function formatMetadata(metadata) {
  const data = {
    'video' : metadata.video,
    'audio' : metadata.audio,
    'duration' : metadata.duration
  };
  return data;
}


    


    // Expected output

    


    {"data":{"video":{"container":"mov","bitrate":400,"stream":0,"codec":"h264","resolution":{"w":1280,"h":720},"resolutionSquare":{"w":1280,"h":720},"aspect":{"x":16,"y":9,"string":"16:9","value":1.7777777777777777},"rotate":0,"fps":25,"pixelString":"1:1","pixel":1},"audio":{"codec":"aac","bitrate":"127","sample_rate":44100,"stream":0,"channels":{"raw":"stereo","value":2}},"duration":{"raw":"00:00:25.68","seconds":25}}


    


    // Actual output

    


    {"data":{"video":{"container":"","bitrate":0,"stream":0,"codec":"","resolution":{"w":0,"h":0},"resolutionSquare":{"w":0,"h":null},"aspect":{},"rotate":0,"fps":0,"pixelString":"","pixel":0},"audio":{"codec":"","bitrate":"","sample_rate":0,"stream":0,"channels":{"raw":"","value":""}},"duration":{"raw":"","seconds":0}}


    


    Note - this happens sporadically

    


  • node.js ffmpeg pass directly to aws s3 bucket

    30 décembre 2022, par Eivydas Vickus

    How to pass ffmpeg output directly to aws s3 bucket ? It should not store output file on my pc. This is my code.

    


    &#xA;    import {&#xA;      DeleteObjectCommand,&#xA;      GetObjectCommand,&#xA;      PutObjectCommand,&#xA;      PutObjectCommandInput,&#xA;      S3,&#xA;      S3Client,&#xA;    } from &#x27;@aws-sdk/client-s3&#x27;;&#xA;    import { Inject, Injectable } from &#x27;@nestjs/common&#x27;;&#xA;    import { ConfigType } from &#x27;@nestjs/config&#x27;;&#xA;    import { nanoid } from &#x27;nanoid&#x27;;&#xA;    import awsConfig from &#x27;./aws.config&#x27;;&#xA;    import * as path from &#x27;path&#x27;;&#xA;    import { VideoInterface } from &#x27;../video/video.interface&#x27;;&#xA;    import { PassThrough } from &#x27;node:stream&#x27;;&#xA;&#xA;    @Injectable()&#xA;    export class S3BucketService {&#xA;      public readonly client = new S3Client({&#xA;        region: this.config.AWS_BUCKET_REGION,&#xA;        credentials: {&#xA;          accessKeyId: this.config.AWS_ACCESS_KEY,&#xA;          secretAccessKey: this.config.AWS_SECRET_KEY,&#xA;        },&#xA;      });&#xA;      constructor(&#xA;        @Inject(awsConfig.KEY)&#xA;        private readonly config: ConfigType<typeof awsconfig="awsconfig">,&#xA;      ) {}&#xA;&#xA;      async videoPut(putObjectInput: Omit) {&#xA;        return new PutObjectCommand({&#xA;          ...putObjectInput,&#xA;          Bucket: this.config.AWS_BUCKET_NAME,&#xA;        });&#xA;      }&#xA;&#xA;      async uploadFile({ fileName, file, folder }: VideoInterface) {&#xA;        const fullPath = path.normalize(`${folder}/${fileName}`);&#xA;        return await this.client.send(&#xA;          await this.videoPut({&#xA;            Key: fullPath,&#xA;            Body: file,&#xA;          }),&#xA;        );&#xA;      }&#xA;     }&#xA;</typeof>

    &#xA;

    &#xA;        const passthroughs = new PassThrough();&#xA;        await new Promise<void>(async (resolve, reject) => {&#xA;          ffmpeg(fs.createReadStream(file.path))&#xA;            .format(&#x27;webm&#x27;)&#xA;            .outputOptions([&#xA;              `-vf scale=${videoOptions[2].scale}`,&#xA;              `-b:v ${videoOptions[2].avgBitRate}`,&#xA;              `-minrate ${videoOptions[2].minBitRate}`,&#xA;              `-maxrate ${videoOptions[2].maxBitRate}`,&#xA;              `-tile-columns ${videoOptions[2].tileColumns}`,&#xA;              `-g ${videoOptions[2].g}`,&#xA;              `-threads ${videoOptions[2].threads}`,&#xA;              `-quality ${videoOptions[2].quality}`,&#xA;              `-crf ${videoOptions[2].crf}`,&#xA;              `-c:v ${videoOptions[2].videoCodec}`,&#xA;              `-c:a ${videoOptions[2].audioCodec}`,&#xA;              `-speed ${videoOptions[2].speed}`,&#xA;              `-y`,&#xA;            ])&#xA;            .pipe(passthroughs, { end: true })&#xA;            .on(&#x27;error&#x27;, (err) => {&#xA;              reject(err);&#xA;              throw new InternalServerErrorException(err);&#xA;            })&#xA;            .on(&#x27;data&#x27;, (data) => {&#xA;              console.log({ data });&#xA;            })&#xA;            .on(&#x27;end&#x27;, async () => {&#xA;              console.log(&#x27;Video conversion complete&#x27;);&#xA;              resolve();&#xA;            });&#xA;        });&#xA;&#xA;        await this.s3BucketService.uploadFile({&#xA;          folder: AwsFolder.VIDEOS,&#xA;          file: passthroughs,&#xA;          fileName: `${nanoid()}_${videoOptions[2].scale}.webm`,&#xA;        });&#xA;&#xA;</void>

    &#xA;

    However i am getting error Error: Output stream closed. I saw on google different variants with Passthrough none of them are working. So how it should be done ? By The Way I am using @aws-sdk/client-s3 and most solutions on google is using aws sdk-2. Maybe streams work different with version 3 ?

    &#xA;

  • Title : Getting "invalid_request_error" when trying to pass converted audio file to OpenAI API

    19 avril 2023, par Dummy Cron

    I am working on a project where I receive a URL from a webhook on my server whenever users share a voice note on my WhatsApp. I am using WATI as my WhatsApp API Provder

    &#xA;

    The file URL received is in the .opus format, which I need to convert to WAV and pass to the OpenAI Whisper API translation task.

    &#xA;

    I am trying convert it to .wav using ffmpeg, and pass it to the OpenAI API for translation processing.&#xA;However, I am getting an "invalid_request_error"

    &#xA;

    import requests&#xA;import io&#xA;import subprocess&#xA;file_url = #.opus file url&#xA;api_key = #WATI API Keu&#xA;&#xA;def transcribe_audio_to_text():&#xA;  # Fetch the audio file and convert to wav format&#xA;&#xA;  headers = {&#x27;Authorization&#x27;: f&#x27;Bearer {api_key}&#x27;}&#xA;  response = requests.get(file_url, headers=headers)&#xA;  audio_bytes = io.BytesIO(response.content)&#xA;&#xA;  process = subprocess.Popen([&#x27;ffmpeg&#x27;, &#x27;-i&#x27;, &#x27;-&#x27;, &#x27;-f&#x27;, &#x27;wav&#x27;, &#x27;-acodec&#x27;, &#x27;libmp3lame&#x27;, &#x27;-&#x27;], stdin=subprocess.PIPE, stdout=subprocess.PIPE)&#xA;  wav_audio, _ = process.communicate(input=audio_bytes.read())&#xA;&#xA;  # Set the Whisper API endpoint and headers&#xA;  WHISPER_API_ENDPOINT = &#x27;https://api.openai.com/v1/audio/translations&#x27;&#xA;  whisper_api_headers = {&#x27;Authorization&#x27;: &#x27;Bearer &#x27; &#x2B; WHISPER_API_KEY,&#xA;                         &#x27;Content-Type&#x27;: &#x27;application/json&#x27;}&#xA;  print(whisper_api_headers)&#xA;  # Send the audio file for transcription&#xA;&#xA;  payload = {&#x27;model&#x27;: &#x27;whisper-1&#x27;}&#xA;  files = {&#x27;file&#x27;: (&#x27;audio.wav&#x27;, io.BytesIO(wav_audio), &#x27;audio/wav&#x27;)}&#xA;&#xA;  # files = {&#x27;file&#x27;: (&#x27;audio.wav&#x27;, io.BytesIO(wav_audio), &#x27;application/octet-stream&#x27;)}&#xA;&#xA;  # files = {&#x27;file&#x27;: (&#x27;audio.mp3&#x27;, io.BytesIO(mp3_audio), &#x27;audio/mp3&#x27;)}&#xA;  response = requests.post(WHISPER_API_ENDPOINT, headers=whisper_api_headers, data=payload)&#xA;  print(response)&#xA;  # Get the transcription text&#xA;  if response.status_code == 200:&#xA;      result = response.json()&#xA;      text = result[&#x27;text&#x27;]&#xA;      print(response, text)&#xA;  else:&#xA;      print(&#x27;Error:&#x27;, response)&#xA;      err = response.json()&#xA;      print(response.status_code)&#xA;      print(err)&#xA;      print(response.headers)&#xA;&#xA;transcribe_audio_to_text()&#xA;

    &#xA;

    Output :

    &#xA;

    Error: <response>&#xA;400&#xA;{&#x27;error&#x27;: {&#x27;message&#x27;: "We could not parse the JSON body of your request. (HINT: This likely means you aren&#x27;t using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please send an email to support@openai.com and include any relevant code you&#x27;d like help with.)", &#x27;type&#x27;: &#x27;invalid_request_error&#x27;, &#x27;param&#x27;: None, &#x27;code&#x27;: None}}&#xA;</response>

    &#xA;