Recherche avancée

Médias (39)

Mot : - Tags -/audio

Autres articles (112)

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

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

Sur d’autres sites (15305)

  • FFmpeg - invalid argument on a creation of MP4 with .SRT - "Unable to parse option value "Link_to_the.srt" as image size...?

    20 mai 2023, par sKunZel

    I'm stuck for 2 weeks on same problem on developping a command that bring together a .mp4 file consisting on a fixed image & audio from a .mp3 and then burnt-in subtitle from a stylized .srt into a new MP4.

    


    Here is my command :
 command = f"""ffmpeg -report -i "input_video_arg_abs" -vf "subtitles='input_srt_arg_abs':original_size=816x1456:force_style='FontName=Open Sans Italic,FontSize=13,MarginR=10,MarginV=149'" -c:v libx264 -crf 18 -c:a copy -movflags +faststart "output_video" """

    


    And you can see here the main script definitions of variables and call to fonction :

    


    


    input_srt = os.path.normpath(os.path.join(input_directory, srt_file))
print(f"Chemin du fichier SRT : input_srt")
reformat_srt(input_srt)
final_video_output=os.path.normpath(os.path.join(output_directory,
os.path.splitext(mp3_file)[0] + '.mp4'))
time.sleep(0.5)
create_final_video(temp_video_output, input_srt, final_video_output)

    


    


    This code generated an output file correctly named but 0 Ko. Every log i found indicated an error in the way of my .srt but when i print my input_srt it is correct.

    


    Here i add up some logs :

    


    [h264 @ 000002806874c340] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[Parsed_subtitles_0 @ 0000028068d97d00] Setting 'filename' to value 'E'
[Parsed_subtitles_0 @ 0000028068d97d00] Setting 'original_size' to value 'YouTubeMcKennaWe_Plants_Are_Happy_PlantsSRTSans_programmation_paralleleinputTerence_McKenna_The_Good_the_True_and_the_Beautiful.srt'
[subtitles @ 0000028068f0de40] Unable to parse option value "YouTubeMcKennaWe_Plants_Are_Happy_PlantsSRTSans_programmation_paralleleinputTerence_McKenna_The_Good_the_True_and_the_Beautiful.srt" as image size
[Parsed_subtitles_0 @ 0000028068d97d00] Setting 'original_size' to value '816x1456'
[Parsed_subtitles_0 @ 0000028068d97d00] Setting 'force_style' to value 'FontName=Open Sans Italic,FontSize=13,MarginR=10,MarginV=149'
[Parsed_subtitles_0 @ 0000028068d97d00] Raster: FreeType 2.10.2
[Parsed_subtitles_0 @ 0000028068d97d00] Shaper: FriBidi 1.0.9 (SIMPLE)
[Parsed_subtitles_0 @ 0000028068d97d00] Initialized
[NULL @ 0000028068f0f480] Opening 'E' for reading
[file @ 000002806bf2b800] Setting default whitelist 'file,crypto'
[Parsed_subtitles_0 @ 0000028068d97d00] Unable to open E
[AVFilterGraph @ 0000028069044cc0] Error initializing filter 'subtitles' with args 'E:\YouTube\McKenna\We_Plants_Are_Happy_Plants\SRT\Sans_programmation_parallele\input\Terence_McKenna_The_Good_the_True_and_the_Beautiful.srt:original_size=816x1456:force_style=FontName=Open Sans Italic,FontSize=13,MarginR=10,MarginV=149'
Error reinitializing filters!
Failed to inject frame into filter network: No such file or directory
Error while processing the decoded data for stream #0:0
[AVIOContext @ 0000028068bbab80] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0000028068693640] Statistics: 1370703 bytes read, 0 seeks
Conversion failed!


    


    I'm thinking of "E :" as the problem since on Windows it should be correct but with FFMPEG langage, i don't know...

    


    I wish anyone can help me, and will be glad if it is a tricky solution. Else, sorry for my newbism...
Thanks
sKunZel

    


  • "Conversion failed !" when trying to write to frame to a rmtp stream

    8 mai 2023, par Loc Bui Nhien

    I'm trying to write video frames to an RTMP stream using FFMPEG and Python subsystem. The code will try to get videos in a 'ReceivedRecording' then it is stream to a RTMP streaming server using nginx. My method seems to work, but at times, the code will stop running due to

    


    [flv @ 0x55b933694b40] Failed to update header with correct duration.
[flv @ 0x55b933694b40] Failed to update header with correct filesize.


    


    and

    


    Conversion failed

    


    then

    


    BrokenPipeError: [Errno 32] Broken pipe

    


    Here my implementation of the task :

    


    import subprocess
import cv2
rtmp_url = "rtmp://..."

path = 'ReceivedRecording'

received_video_path = 'ReceivedRecording'
while True:
    video_files = [filenames for filenames in sorted(
        os.listdir(received_video_path))]
    # Loop through the videos and concatenate them
    for filename in video_files[:len(video_files)-1]:
        video = cv2.VideoCapture(os.path.join(received_video_path, filename))

        if p is None:
            fps = int(video.get(cv2.CAP_PROP_FPS))
            width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
            height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
            # command and params for ffmpeg
            command = ['ffmpeg',
                        '-y',
                        '-f', 'rawvideo',
                        '-vcodec', 'rawvideo',
                        '-pix_fmt', 'bgr24',
                        '-s', "{}x{}".format(width, height),
                        '-re',
                        '-r', '5',
                        '-i', '-',
                        # '-filter:v', 'setpts=4.0*PTS',
                        '-c:v', 'libx264',
                        '-pix_fmt', 'yuv420p',
                        '-preset', 'ultrafast',
                        '-tune','zerolatency',
                        '-vsync','vfr',
                        # '-crf','23',
                        '-f', 'flv',
                        rtmp_url]
            
            # using subprocess and pipe to fetch frame data
            p = subprocess.Popen(command, stdin=subprocess.PIPE)
        else:

            # Loop through the frames of each video
            while True:
                start_time = time.time()

                ret, frame = video.read()
                if not ret:
                    # End of video, move to next video
                    video.release()
                    break

                p.stdin.write(frame.tobytes())

            os.remove(os.path.join(received_video_path, filename))


    


    Here is my nginx rtmp settings :

    


    rtmp {
    server {
        listen 1935;
        chunk_size 7096;

        application live {
            live on;
            record off;
            push rtmp://...;
        }
    }
}


    


    Here is the log file :

    


    av_interleaved_write_frame(): Connection reset by peer
No more output streams to write to, finishing.
[flv @ 0x5561d1ca9b40] Failed to update header with correct duration.
[flv @ 0x5561d1ca9b40] Failed to update header with correct filesize.
Error writing trailer of rtmp://...: Connection reset by peer
frame=    1 fps=0.0 q=20.0 Lsize=    1024kB time=00:00:00.00 bitrate=8390776.0kbits/s speed=0.00619x
video:1053kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (pipe:):
  Input stream #0:0 (video): 1 packets read (11059200 bytes); 1 frames decoded;
  Total: 1 packets (11059200 bytes) demuxed
Output file #0 (rtmp://...):
  Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (1077799 bytes);
  Total: 1 packets (1077799 bytes) muxed
1 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x5561d1cad380] Statistics: 0 seeks, 35 writeouts
[rtmp @ 0x5561d1cb7b80] Deleting stream...
[libx264 @ 0x5561d1caae40] frame I:1     Avg QP:20.00  size:1077192
[libx264 @ 0x5561d1caae40] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x5561d1caae40] coded y,uvDC,uvAC intra: 92.2% 50.5% 10.2%
[libx264 @ 0x5561d1caae40] i16 v,h,dc,p: 34% 16% 37% 12%
[libx264 @ 0x5561d1caae40] i8c dc,h,v,p: 35% 23% 33%  9%
[libx264 @ 0x5561d1caae40] kb/s:43087.68
[AVIOContext @ 0x5561d1ca6a80] Statistics: 11059200 bytes read, 0 seeks
Conversion failed!


    


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