Recherche avancée

Médias (0)

Mot : - Tags -/utilisateurs

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

Autres articles (105)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

Sur d’autres sites (16908)

  • 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

    


    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.

    


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

    


    import requests
import io
import subprocess
file_url = #.opus file url
api_key = #WATI API Keu

def transcribe_audio_to_text():
  # Fetch the audio file and convert to wav format

  headers = {'Authorization': f'Bearer {api_key}'}
  response = requests.get(file_url, headers=headers)
  audio_bytes = io.BytesIO(response.content)

  process = subprocess.Popen(['ffmpeg', '-i', '-', '-f', 'wav', '-acodec', 'libmp3lame', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
  wav_audio, _ = process.communicate(input=audio_bytes.read())

  # Set the Whisper API endpoint and headers
  WHISPER_API_ENDPOINT = 'https://api.openai.com/v1/audio/translations'
  whisper_api_headers = {'Authorization': 'Bearer ' + WHISPER_API_KEY,
                         'Content-Type': 'application/json'}
  print(whisper_api_headers)
  # Send the audio file for transcription

  payload = {'model': 'whisper-1'}
  files = {'file': ('audio.wav', io.BytesIO(wav_audio), 'audio/wav')}

  # files = {'file': ('audio.wav', io.BytesIO(wav_audio), 'application/octet-stream')}

  # files = {'file': ('audio.mp3', io.BytesIO(mp3_audio), 'audio/mp3')}
  response = requests.post(WHISPER_API_ENDPOINT, headers=whisper_api_headers, data=payload)
  print(response)
  # Get the transcription text
  if response.status_code == 200:
      result = response.json()
      text = result['text']
      print(response, text)
  else:
      print('Error:', response)
      err = response.json()
      print(response.status_code)
      print(err)
      print(response.headers)

transcribe_audio_to_text()


    


    Output :

    


    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;

  • How to keep video quality same as it is after merge intro image beggining to video using ffmpeg

    13 juin 2021, par Manoj Kag

    I have selected high resolution video but once i run command the video resolution quality was changed and too poor quality's video i get as output video, but i don't would like to loose my video quality. let me share full command and complete log below :

    &#xA;

    Note : libx264 encoder is not supporting iOS, I'm getting failure error so i use h264_videotoolbox so i would like to get supported command with h264_videotoolbox encoder

    &#xA;

    Command :

    &#xA;

    &#xA;

    ffmpeg -i test.MOV -loop 1 -t 5 -i 2.jpg -f lavfi -t 5 -i anullsrc&#xA;-filter_complex "[0:v]trim=0:5,drawbox=t=fill[base] ;[1][base]scale2ref=iw:ih:force_original_aspect_ratio=decrease:flags=spline[2nd][base2] ;[base2][2nd]overlay='(W-w)/2' :'(H-h)/2'[padded] ;[padded][2:a][0:v][0:a]concat=n=2:v=1:a=1[v][a]"&#xA;-c:v h264_videotoolbox -c:a aac -map "[v]" -map "[a]" output.mp4

    &#xA;

    &#xA;

    Complete log

    &#xA;

    ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers&#xA;  built with Apple clang version 12.0.0 (clang-1200.0.32.29)&#xA;  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox&#xA;  libavutil      56. 70.100 / 56. 70.100&#xA;  libavcodec     58.134.100 / 58.134.100&#xA;  libavformat    58. 76.100 / 58. 76.100&#xA;  libavdevice    58. 13.100 / 58. 13.100&#xA;  libavfilter     7.110.100 /  7.110.100&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  9.100 /  5.  9.100&#xA;  libswresample   3.  9.100 /  3.  9.100&#xA;  libpostproc    55.  9.100 / 55.  9.100&#xA;Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;test.MOV&#x27;:&#xA;  Metadata:&#xA;    major_brand     : qt  &#xA;    minor_version   : 0&#xA;    compatible_brands: qt  &#xA;    creation_time   : 2021-03-07T06:36:17.000000Z&#xA;    com.apple.quicktime.location.accuracy.horizontal: 30.000000&#xA;    com.apple.quicktime.location.ISO6709: &#x2B;23.1141&#x2B;072.5768&#x2B;061.729/&#xA;    com.apple.quicktime.make: Apple&#xA;    com.apple.quicktime.model: iPhone 6s&#xA;    com.apple.quicktime.software: 14.3&#xA;    com.apple.quicktime.creationdate: 2021-03-07T12:06:17&#x2B;0530&#xA;  Duration: 00:00:29.79, start: 0.000000, bitrate: 15778 kb/s&#xA;  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 15643 kb/s, 29.98 fps, 29.97 tbr, 600 tbn, 1200 tbc (default)&#xA;    Metadata:&#xA;      creation_time   : 2021-03-07T06:36:17.000000Z&#xA;      handler_name    : Core Media Video&#xA;      vendor_id       : [0][0][0][0]&#xA;      encoder         : H.264&#xA;  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 89 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2021-03-07T06:36:17.000000Z&#xA;      handler_name    : Core Media Audio&#xA;      vendor_id       : [0][0][0][0]&#xA;  Stream #0:2(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2021-03-07T06:36:17.000000Z&#xA;      handler_name    : Core Media Metadata&#xA;  Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2021-03-07T06:36:17.000000Z&#xA;      handler_name    : Core Media Metadata&#xA;  Stream #0:4(und): Data: none (mebx / 0x7862656D), 34 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2021-03-07T06:36:17.000000Z&#xA;      handler_name    : Core Media Metadata&#xA;Input #1, image2, from &#x27;2.jpg&#x27;:&#xA;  Duration: 00:00:00.04, start: 0.000000, bitrate: 17347 kb/s&#xA;  Stream #1:0: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 360x360 [SAR 72:72 DAR 1:1], 25 fps, 25 tbr, 25 tbn, 25 tbc&#xA;Input #2, lavfi, from &#x27;anullsrc&#x27;:&#xA;  Duration: N/A, start: 0.000000, bitrate: 705 kb/s&#xA;  Stream #2:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s&#xA;Stream mapping:&#xA;  Stream #0:0 (h264) -> trim&#xA;  Stream #0:0 (h264) -> concat:in1:v0&#xA;  Stream #0:1 (aac) -> concat:in1:a0&#xA;  Stream #1:0 (mjpeg) -> scale2ref:default&#xA;  Stream #2:0 (pcm_u8) -> concat:in0:a0&#xA;  concat:out:v0 -> Stream #0:0 (h264_videotoolbox)&#xA;  concat:out:a0 -> Stream #0:1 (aac)&#xA;Press [q] to stop, [?] for help&#xA;[swscaler @ 0x7f976242b000] deprecated pixel format used, make sure you did set range correctly&#xA;Output #0, mp4, to &#x27;output.mp4&#x27;:&#xA;  Metadata:&#xA;    major_brand     : qt  &#xA;    minor_version   : 0&#xA;    compatible_brands: qt  &#xA;    com.apple.quicktime.creationdate: 2021-03-07T12:06:17&#x2B;0530&#xA;    com.apple.quicktime.location.accuracy.horizontal: 30.000000&#xA;    com.apple.quicktime.location.ISO6709: &#x2B;23.1141&#x2B;072.5768&#x2B;061.729/&#xA;    com.apple.quicktime.make: Apple&#xA;    com.apple.quicktime.model: iPhone 6s&#xA;    com.apple.quicktime.software: 14.3&#xA;    encoder         : Lavf58.76.100&#xA;  Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, q=2-31, 200 kb/s, 29.97 fps, 30k tbn (default)&#xA;    Metadata:&#xA;      encoder         : Lavc58.134.100 h264_videotoolbox&#xA;  Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)&#xA;    Metadata:&#xA;      encoder         : Lavc58.134.100 aac&#xA;frame=    1 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   frame=   12 fps=0.0 q=-0.0 size=     256kB time=00:00:00.32 bitrate=6452.4kbits/frame=   34 fps= 32 q=-0.0 size=     256kB time=00:00:01.02 bitrate=2053.0kbits/frame=   55 fps= 35 q=-0.0 size=     256kB time=00:00:01.74 bitrate=1204.4kbits/frame=   76 fps= 37 q=-0.0 size=     256kB time=00:00:02.46 bitrate= 852.2kbits/frame=   98 fps= 38 q=-0.0 size=     256kB time=00:00:03.18 bitrate= 659.4kbits/frame=  120 fps= 39 q=-0.0 size=     256kB time=00:00:03.90 bitrate= 537.7kbits/frame=  141 fps= 39 q=-0.0 size=     512kB time=00:00:04.62 bitrate= 907.8kbits/[out_0_0 @ 0x7f975de0ae80] 100 buffers queued in out_0_0, something may be wrong.&#xA;[out_0_1 @ 0x7f975de0a5c0] 100 buffers queued in out_0_1, something may be wrong.&#xA;frame=  301 fps= 67 q=-0.0 size=     768kB time=00:00:11.09 bitrate= 566.9kbits/frame=  406 fps= 81 q=-0.0 size=    1024kB time=00:00:14.60 bitrate= 574.4kbits/frame=  509 fps= 92 q=-0.0 size=    1280kB time=00:00:18.04 bitrate= 581.2kbits/frame=  604 fps=100 q=-0.0 size=    1792kB time=00:00:21.19 bitrate= 692.5kbits/frame=  705 fps=108 q=-0.0 size=    2048kB time=00:00:24.56 bitrate= 682.9kbits/frame=  809 fps=115 q=-0.0 size=    2304kB time=00:00:28.04 bitrate= 672.9kbits/frame=  909 fps=121 q=-0.0 size=    2816kB time=00:00:31.37 bitrate= 735.4kbits/frame= 1012 fps=126 q=-0.0 size=    3072kB time=00:00:34.71 bitrate= 725.0kbits/frame= 1043 fps=127 q=-0.0 Lsize=    3288kB time=00:00:34.78 bitrate= 774.3kbits/s speed=4.23x    &#xA;video:2995kB audio:255kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.168448%&#xA;[aac @ 0x7f9760024200] Qavg: 9569.656&#xA;

    &#xA;

  • No such file or directory Error with FFMPEG + CarrierWave screenshot method

    10 juillet 2013, par dodgerogers747

    I am using AWS CORS to upload videos to my site, all of which works as planned.

    I have the following model method which runs as an after_create callback (for speed) to take a screenshot from the video file on AWS. I plan to move this out into a delayed job but I don't think this will solve this particular issue. Please advise if mistaken.

    I use FFMPEG to take a screenshot from the AWS self.file location, I then send the file to CarrierWave by saving the file to self.screenshot where it is uploaded to AWS.

    Approx. 50% of the time it errors out with Errno::ENOENT - No such file or directory for the location of the screenshot image.

    How can I rectify my code to remove this error and how come it only occurs around 50% of the time ? If anyone needs more code just shout.

    video.rb

    after_create :take_screenshot

    mount_uploader :screenshot, ImageUploader

     def take_screenshot
       location = "#{Rails.root}/public/uploads/tmp/screenshots/#{unique}_#{File.basename(file)}.jpg"
       system `ffmpeg #{log_level} -i #{self.file} -ss 00:00:0#{time_frame} -vframes 1 #{location}`
       logger.debug "Trying to take screenshot from #{self.file}"
       #pass the actual file to CarrierWave to handle the image upload
       self.screenshot = File.open(location)
       self.save
       logger.debug "Deleting tmp file: #{location}: #{File.delete(location)}" if self.screenshot.present?
     end

    def unique
       (0..6).map{(65+rand(26)).chr}.join
     end

    def log_level
       "-loglevel panic"
     end

     def time_frame
       rand(0..3)
     end

    Stack trace :

    Started POST "/videos" for 127.0.0.1 at 2013-07-10 03:58:49 +0800
    Processing by VideosController#create as JS
     Parameters: {"utf8"=>"✓", "authenticity_token"=>"6M1Ia+Ag2E3HVKH2PO/p7jewxSpMPdWeVHGA933Bzjw=", "video"=>{"file"=>"http://bucketname.s3.amazonaws.com/uploads/video/file/671a87fb-91de-4eaf-a38a-1b25c51798e5/Good_7iron.m4v"}}
     User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 9 LIMIT 1
      (0.1ms)  BEGIN
     SQL (0.2ms)  INSERT INTO `videos` (`created_at`, `file`, `question_id`, `screenshot`, `updated_at`, `user_id`) VALUES (&#39;2013-07-09 19:58:49&#39;, &#39;http://bucketname.s3.amazonaws.com/uploads/video/file/671a87fb-91de-4eaf-a38a-1b25c51798e5/Good_7iron.m4v&#39;, NULL, NULL, &#39;2013-07-09 19:58:49&#39;, 9)
    Trying to take screenshot from http://bucketname.s3.amazonaws.com/uploads/video/file/671a87fb-91de-4eaf-a38a-1b25c51798e5/Good_7iron.m4v
      (0.8ms)  ROLLBACK
    Completed 500 Internal Server Error in 3550ms

    Errno::ENOENT - No such file or directory - /Users/me/rails/project/public/uploads/tmp/screenshots/WCACLIC_Good_7iron.m4v.jpg:
     app/models/video.rb:24:in `initialize&#39;
     app/models/video.rb:24:in `open&#39;
     app/models/video.rb:24:in `take_screenshot&#39;