Recherche avancée

Médias (91)

Autres articles (28)

  • Participer à sa documentation

    10 avril 2011

    La documentation est un des travaux les plus importants et les plus contraignants lors de la réalisation d’un outil technique.
    Tout apport extérieur à ce sujet est primordial : la critique de l’existant ; la participation à la rédaction d’articles orientés : utilisateur (administrateur de MediaSPIP ou simplement producteur de contenu) ; développeur ; la création de screencasts d’explication ; la traduction de la documentation dans une nouvelle langue ;
    Pour ce faire, vous pouvez vous inscrire sur (...)

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

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

Sur d’autres sites (4338)

  • ffmpeg "End mismatch 1" warning, jpeg2000 to avi

    11 avril 2023, par jklebes

    Trying to convert a directory of jpeg2000 grayscale images to a video with ffmpeg, I get warnings

    


    [0;36m[jpeg2000 @ 0x55d8fa1b68c0] [0m[0;33mEnd mismatch 1


    


    (and lots of

    


    Last message repeated <n> times&#xA;</n>

    &#xA;

    )

    &#xA;

    The command was

    &#xA;

    ffmpeg -y -r 10 -start_number 1 -i <path>/surface_30///img_000%01d.jp2 -vcodec msmpeg4 -vf scale=1920:-1 -q:v 8 <path>//surface_30///surface_30.avi&#xA;</path></path>

    &#xA;

    The output is

    &#xA;

    ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers&#xA;  built with gcc 7.3.0 (crosstool-NG 1.23.0.449-a04d0)&#xA;  configuration: --prefix=/home/jklebes001/miniconda3 --cc=/tmp/build/80754af9/ffmpeg_1587154242452/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --enable-avresample --enable-gmp --enable-hardcoded-tables --enable-libfreetype --enable-libvpx --enable-pthreads --enable-libopus --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame --disable-nonfree --enable-gpl --enable-gnutls --disable-openssl --enable-libopenh264 --enable-libx264&#xA;  libavutil      56. 31.100 / 56. 31.100&#xA;  libavcodec     58. 54.100 / 58. 54.100&#xA;  libavformat    58. 29.100 / 58. 29.100&#xA;  libavdevice    58.  8.100 / 58.  8.100&#xA;  libavfilter     7. 57.100 /  7. 57.100&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  5.100 /  5.  5.100&#xA;  libswresample   3.  5.100 /  3.  5.100&#xA;  libpostproc    55.  5.100 / 55.  5.100&#xA;[0;36m[jpeg2000 @ 0x55cb44144480] [0m[0;33mEnd mismatch 1&#xA;&#xA;[0m    Last message repeated 1 times&#xA;    Last message repeated 2 times&#xA;    Last message repeated 3 times&#xA;

    &#xA;

    ...

    &#xA;

    Last message repeated 73 times&#xA;&#xA;Input #0, image2, from &#x27;<path>//surface_30///img_000%01d.jp2&#x27;:&#xA;&#xA;  Duration: 00:00:00.20, start: 0.000000, bitrate: N/A&#xA;&#xA;    Stream #0:0: Video: jpeg2000, gray, 6737x4869, 25 tbr, 25 tbn, 25 tbc&#xA;&#xA;Stream mapping:&#xA;&#xA;  Stream #0:0 -> #0:0 (jpeg2000 (native) -> msmpeg4v3 (msmpeg4))&#xA;&#xA;Press [q] to stop, [?] for help&#xA;&#xA;[0;36m[jpeg2000 @ 0x55cb4418e200] [0m[0;33mEnd mismatch 1&#xA;&#xA;[0m[0;36m[jpeg2000 @ 0x55cb441900c0] [0m[0;33mEnd mismatch 1&#xA;</path>

    &#xA;

    ...

    &#xA;

    (about 600 lines of "end mismatch" and "last message repeated" cut)

    &#xA;

    ...

    &#xA;

    [0m[0;36m[jpeg2000 @ 0x55cb4418e8c0] [0m[0;33mEnd mismatch 1&#xA;&#xA;[0mOutput #0, avi, to &#x27;<path>/surface_30///surface_30.avi&#x27;:&#xA;&#xA;  Metadata:&#xA;&#xA;    ISFT            : Lavf58.29.100&#xA;&#xA;    Stream #0:0: Video: msmpeg4v3 (msmpeg4) (MP43 / 0x3334504D), yuv420p, 1920x1388, q=2-31, 200 kb/s, 10 fps, 10 tbn, 10 tbc&#xA;&#xA;    Metadata:&#xA;&#xA;      encoder         : Lavc58.54.100 msmpeg4&#xA;&#xA;    Side data:&#xA;&#xA;      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1&#xA;&#xA;frame=    2 fps=0.8 q=8.0 size=       6kB time=00:00:00.20 bitrate= 227.1kbits/s speed=0.0844x    &#xA;frame=    5 fps=1.7 q=8.0 size=       6kB time=00:00:00.50 bitrate=  90.8kbits/s speed=0.172x    &#xA;frame=    5 fps=1.7 q=8.0 Lsize=     213kB time=00:00:00.50 bitrate=3494.7kbits/s speed=0.172x    &#xA;video:208kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.732246%&#xA;</path>

    &#xA;

    What is the meaning of characters like [0 ;33m here ?

    &#xA;

    I thought it might have something to do with bit depth and color format. Setting -pix_fmt gray had no effect, and indeed the format of the jp2 images is already detected as 8-bit gray.

    &#xA;

    The output .avi exists and seems fine.

    &#xA;

    The line was previously used on jpeg files and works fine on jpeg. With jpeg, the output has the line

    &#xA;

    Input #0, image2, from &#x27;<path>/surface_30///img_000%01d.jpeg&#x27;:&#xA;&#xA;  Duration: 00:00:00.16, start: 0.000000, bitrate: N/A&#xA;&#xA;    Stream #0:0: Video: mjpeg (Baseline), gray(bt470bg/unknown/unknown), 6737x4869 [SAR 1:1 DAR 6737:4869], 25 tbr, 25 tbn, 25 tbc&#xA;&#xA;Stream mapping:&#xA;&#xA;  Stream #0:0 -> #0:0 (mjpeg (native) -> msmpeg4v3 (msmpeg4))&#xA;&#xA;Press [q] to stop, [?] for help&#xA;&#xA;Output #0, avi, to &#x27;<path>/surface_30///surface_30.avi&#x27;:&#xA;&#xA;  Metadata:&#xA;&#xA;    ISFT            : Lavf58.29.100&#xA;&#xA;    Stream #0:0: Video: msmpeg4v3 (msmpeg4) (MP43 / 0x3334504D), yuv420p, 6737x4869 [SAR 1:1 DAR 6737:4869], q=2-31, 200 kb/s, 10 fps, 10 tbn, 10 tbc&#xA;&#xA;    Metadata:&#xA;&#xA;      encoder         : Lavc58.54.100 msmpeg4&#xA;&#xA;    Side data:&#xA;&#xA;      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1&#xA;&#xA;frame=    2 fps=0.0 q=8.0 size=    6662kB time=00:00:00.20 bitrate=272859.9kbits/s speed=0.334x    &#xA;frame=    3 fps=2.2 q=10.0 size=   10502kB time=00:00:00.30 bitrate=286764.2kbits/s speed=0.22x    &#xA;frame=    4 fps=1.9 q=12.3 size=   13574kB time=00:00:00.40 bitrate=277987.7kbits/s speed=0.19x    &#xA;frame=    4 fps=1.4 q=12.3 size=   13574kB time=00:00:00.40 bitrate=277987.7kbits/s speed=0.145x    &#xA;frame=    4 fps=1.4 q=12.3 Lsize=   13657kB time=00:00:00.40 bitrate=279702.3kbits/s speed=0.145x    &#xA;video:13652kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.041926%&#xA;</path></path>

    &#xA;

    detecting mjpeg format and similar, but more detailed format gray(bt470bg/unknown/unknown), 6737x4869 [SAR 1:1 DAR 6737:4869].

    &#xA;

    What is the difference when switching input to jp2 ?

    &#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;

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

    &#xA;

    [flv @ 0x55b933694b40] Failed to update header with correct duration.&#xA;[flv @ 0x55b933694b40] Failed to update header with correct filesize.&#xA;

    &#xA;

    and

    &#xA;

    Conversion failed

    &#xA;

    then

    &#xA;

    BrokenPipeError: [Errno 32] Broken pipe

    &#xA;

    Here my implementation of the task :

    &#xA;

    import subprocess&#xA;import cv2&#xA;rtmp_url = "rtmp://..."&#xA;&#xA;path = &#x27;ReceivedRecording&#x27;&#xA;&#xA;received_video_path = &#x27;ReceivedRecording&#x27;&#xA;while True:&#xA;    video_files = [filenames for filenames in sorted(&#xA;        os.listdir(received_video_path))]&#xA;    # Loop through the videos and concatenate them&#xA;    for filename in video_files[:len(video_files)-1]:&#xA;        video = cv2.VideoCapture(os.path.join(received_video_path, filename))&#xA;&#xA;        if p is None:&#xA;            fps = int(video.get(cv2.CAP_PROP_FPS))&#xA;            width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))&#xA;            height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))&#xA;            # command and params for ffmpeg&#xA;            command = [&#x27;ffmpeg&#x27;,&#xA;                        &#x27;-y&#x27;,&#xA;                        &#x27;-f&#x27;, &#x27;rawvideo&#x27;,&#xA;                        &#x27;-vcodec&#x27;, &#x27;rawvideo&#x27;,&#xA;                        &#x27;-pix_fmt&#x27;, &#x27;bgr24&#x27;,&#xA;                        &#x27;-s&#x27;, "{}x{}".format(width, height),&#xA;                        &#x27;-re&#x27;,&#xA;                        &#x27;-r&#x27;, &#x27;5&#x27;,&#xA;                        &#x27;-i&#x27;, &#x27;-&#x27;,&#xA;                        # &#x27;-filter:v&#x27;, &#x27;setpts=4.0*PTS&#x27;,&#xA;                        &#x27;-c:v&#x27;, &#x27;libx264&#x27;,&#xA;                        &#x27;-pix_fmt&#x27;, &#x27;yuv420p&#x27;,&#xA;                        &#x27;-preset&#x27;, &#x27;ultrafast&#x27;,&#xA;                        &#x27;-tune&#x27;,&#x27;zerolatency&#x27;,&#xA;                        &#x27;-vsync&#x27;,&#x27;vfr&#x27;,&#xA;                        # &#x27;-crf&#x27;,&#x27;23&#x27;,&#xA;                        &#x27;-f&#x27;, &#x27;flv&#x27;,&#xA;                        rtmp_url]&#xA;            &#xA;            # using subprocess and pipe to fetch frame data&#xA;            p = subprocess.Popen(command, stdin=subprocess.PIPE)&#xA;        else:&#xA;&#xA;            # Loop through the frames of each video&#xA;            while True:&#xA;                start_time = time.time()&#xA;&#xA;                ret, frame = video.read()&#xA;                if not ret:&#xA;                    # End of video, move to next video&#xA;                    video.release()&#xA;                    break&#xA;&#xA;                p.stdin.write(frame.tobytes())&#xA;&#xA;            os.remove(os.path.join(received_video_path, filename))&#xA;

    &#xA;

    Here is my nginx rtmp settings :

    &#xA;

    rtmp {&#xA;    server {&#xA;        listen 1935;&#xA;        chunk_size 7096;&#xA;&#xA;        application live {&#xA;            live on;&#xA;            record off;&#xA;            push rtmp://...;&#xA;        }&#xA;    }&#xA;}&#xA;

    &#xA;

    Here is the log file :

    &#xA;

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

    &#xA;