Recherche avancée

Médias (91)

Autres articles (5)

  • Le plugin : Podcasts.

    14 juillet 2010, par

    Le problème du podcasting est à nouveau un problème révélateur de la normalisation des transports de données sur Internet.
    Deux formats intéressants existent : Celui développé par Apple, très axé sur l’utilisation d’iTunes dont la SPEC est ici ; Le format "Media RSS Module" qui est plus "libre" notamment soutenu par Yahoo et le logiciel Miro ;
    Types de fichiers supportés dans les flux
    Le format d’Apple n’autorise que les formats suivants dans ses flux : .mp3 audio/mpeg .m4a audio/x-m4a .mp4 (...)

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

  • Automated installation script of MediaSPIP

    25 avril 2011, par

    To overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
    You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
    The documentation of the use of this installation script is available here.
    The code of this (...)

Sur d’autres sites (2052)

  • Convert from oga to mp3 using pydub : ffmpeg returned error code : 1

    29 juin 2023, par Juan David

    I want to take an OGA file within a binary stream and convert it into mp3 using also another stream. I'm getting a permissions error even with running VSCode as administrator. This is my code :

    


    from pydub import AudioSegment
AudioSegment.converter = "C:\\ProgramData\\chocolatey\\lib\\ffmpeg\\tools\\ffmpeg\\bin\\ffmpeg.exe"

input_stream = io.BytesIO()
input_stream.seek(0) 
await new_file.download_to_memory(input_stream)
 
# Create an audio segment from the binary stream
audio = AudioSegment.from_file(input_stream, format='ogg')

# Create an output stream for the MP3 data
output_stream = io.BytesIO()

# Export the audio to MP3 using ffmpeg and write the output to the stream
audio.export(output_stream, format='mp3', codec='libmp3lame')

# Get the MP3 data from the output stream
mp3_data = output_stream.getvalue()


    


    Error message :

    


      File "C:\ProgramData\Anaconda3\envs\chatbot\lib\site-packages\telegram\ext\_application.py", line 1124, in process_update
    await coroutine
  File "C:\ProgramData\Anaconda3\envs\chatbot\lib\site-packages\telegram\ext\_handler.py", line 141, in handle_update
    return await self.callback(update, context)
  File "c:\Users\jdbol\OneDrive\Desktop\testbots\echobot.py", line 80, in voice_to_text
    audio = AudioSegment.from_file(input_stream, format='ogg')
  File "C:\ProgramData\Anaconda3\envs\chatbot\lib\site-packages\pydub\audio_segment.py", line 773, in from_file     
    raise CouldntDecodeError(
pydub.exceptions.CouldntDecodeError: Decoding failed. ffmpeg returned error code: 1

Output from ffmpeg/avlib:

ffmpeg version 6.0-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
fd:: End of file


    


    I ran the command in a terminal and the file converted without an issue :

    


    ffmpeg -i .\file_12.oga output.mp3 


    


      

    1. I'm not sure if the .exe file must be included into the path. When I don't do it, What I get is a permissions error.
    2. 


    3. What other codecs can be used here ?
    4. 


    5. Is it possible to use oga files ? I tried to declare this but I got an 'Unknown input format : 'oga' message (audio = AudioSegment.from_file(input_stream, format='oga'))
    6. 


    


    Thanks !

    


    UPDATE : I created a more simple version that is not using a binary stream and worked like a charm, so we know for sure that something is happening with the BytesIO object

    


    async def voice_to_text(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
    # Get the absolute path of the script
    filename = 'file_9.oga'
    script_dir = os.path.dirname(os.path.abspath(__file__))

    # Construct the file paths for input and output files
    input_file_path = os.path.join(script_dir, filename)
    output_file_path = os.path.join(script_dir, os.path.splitext(filename)[0] + ".mp3")

    # Load the OGA audio file
    audio = AudioSegment.from_file(input_file_path, format='ogg')

    # Export the audio to MP3 format
    audio.export(output_file_path, format='mp3')

    print("Conversion complete. MP3 file saved as:", output_file_path)


    


    UPDATE 2 : It seems like await new_file.download_to_memory(input_stream) is the problematic line. I tried to save the file and its corrupt. Not sure how to use this method then.

    


    https://docs.python-telegram-bot.org/en/stable/telegram.file.html#telegram.File.download_to_memory

    


  • How to resolve "runOnReady command exited with code 0" when restreaming a stream using Mediamtx ?

    2 juillet 2023, par Emad Helmi

    I'm attempting to publish a stream to the RTMP port 1935 using a ffmpeg command with Mediamtx (v0.22.2). Afterward, I want to restream the mainstream to another path using the runOnReady command in the config file. However, I'm encountering an issue where the runOnReady command exits with code 0.

    


    Steps to Replicate :

    


      

    1. Use the provided docker-compose.yml file :
    2. 


    


    version: "3.8"

name: mediamtx
services:
  mediamtx:
    image: aler9/rtsp-simple-server:v0.22.2
    container_name: media_mtx_rtsp_server
    ports:
      - "8554:8554"
      - "1935:1935"
      - "8888:8888"
      - "8889:8889"
      - "9997:9997"
      - "8000:8000"
    volumes:
      - ./configs/mediamtx/config.yml:/mediamtx.yml
      - ../volumes/hls/segments:/hls/segments


    


      

    1. Add the following path to the config.yml file :
    2. 


    


    paths:
  show/test:
    runOnReady: ffmpeg -i rtmp://localhost:1935/show/test -c copy -f flv "rtmp://localhost:1935/compressed/test"
    runOnReadyRestart: yes


    


      

    1. Start the server using docker-compose.
    2. 


    3. Publish an RTMP stream to the server using the following command :
    4. 


    


    ffmpeg -re -stream_loop -1 -i files/sample-30s.mp4 -c copy -f flv "rtmp://localhost:1935/show/test"


    


      

    1. When I check the logs :
    2. 


    


    2023/07/01 15:16:30 INF [RTMP] [conn 172.26.0.1:51044] opened
2023/07/01 15:16:30 INF [path show/test] runOnReady command started
2023/07/01 15:16:30 INF [RTMP] [conn 172.26.0.1:51044] is publishing to path 'show/test', 2 tracks (H264, MPEG4-audio-gen)
2023/07/01 15:16:30 INF [path show/test] runOnReady command exited with code 0


    


    So I can't watch the stream on the new path (/compressed/test)

    


  • problem in making HLS using ffmpeg problem

    24 juin 2023, par AMZ

    I have a function do run in background and create m3u8 for some videos : (I is running in background and updating some fields in django).

    


    def convert_to_hls(episode):
    # Set the output directory for HLS files
output_dir = os.path.join(settings.MEDIA_ROOT, 'hls')
os.makedirs(output_dir, exist_ok=True)

# Set the input video file path
input_file_path = episode.videoFile.path

# Set the output filename and path for the HLS playlist
# filename = os.path.splitext(os.path.basename(input_file_path))[0]
characters = string.ascii_letters + string.digits
filename = ''.join(random.choice(characters) for _ in range(45))
playlist_path = os.path.join(output_dir, f'{filename}.m3u8')

# Set the output path for the HLS segments
segments_path = os.path.join(output_dir, f'{filename}_%05d.ts')

# Construct the ffmpeg command for HLS conversion
command = [
    'ffmpeg',
    '-i', input_file_path,
    '-c:v', 'libx264',
    '-crf', '23',
    '-preset', 'medium',
    '-c:a', 'aac',
    '-b:a', '128k',
    '-f', 'hls',
    '-hls_time', '10',
    '-hls_list_size', '0',
    '-hls_segment_filename', segments_path,
    playlist_path
]
# Execute the ffmpeg command
subprocess.run(command, check=True)

episode.hls_created = True
episode.hls_url = playlist_path.replace("/home/debian/project","")
episode.save()

return True


    


    this code works well for most of my videos but for some .mp4 files gets :

    


    [Fri Jun 23 17:05:47.511095 2023] [wsgi:error] [pid 19975:tid 140289048565504] Exception in thread Thread-1:
[Fri Jun 23 17:05:47.511198 2023] [wsgi:error] [pid 19975:tid 140289048565504] Traceback (most recent call last):
[Fri Jun 23 17:05:47.511244 2023] [wsgi:error] [pid 19975:tid 140289048565504]   File "/opt/bitnami/python/lib/python3.8/threading.py", line 932, in _bootstrap_inner
[Fri Jun 23 17:05:47.512078 2023] [wsgi:error] [pid 19975:tid 140289048565504]     self.run()
[Fri Jun 23 17:05:47.512124 2023] [wsgi:error] [pid 19975:tid 140289048565504]   File "/opt/bitnami/python/lib/python3.8/threading.py", line 870, in run
[Fri Jun 23 17:05:47.512707 2023] [wsgi:error] [pid 19975:tid 140289048565504]     self._target(*self._args, **self._kwargs)
[Fri Jun 23 17:05:47.512748 2023] [wsgi:error] [pid 19975:tid 140289048565504]   File "/home/debian/project/twapp/views/episode_backgrounds.py", line 41, in convert_to_hls
[Fri Jun 23 17:05:47.512950 2023] [wsgi:error] [pid 19975:tid 140289048565504]     subprocess.run(command, check=True)
[Fri Jun 23 17:05:47.512989 2023] [wsgi:error] [pid 19975:tid 140289048565504]   File "/opt/bitnami/python/lib/python3.8/subprocess.py", line 516, in run
[Fri Jun 23 17:05:47.513500 2023] [wsgi:error] [pid 19975:tid 140289048565504]     raise CalledProcessError(retcode, process.args,
[Fri Jun 23 17:05:47.513657 2023] [wsgi:error] [pid 19975:tid 140289048565504] subprocess.CalledProcessError: Command '['ffmpeg', '-i', '/home/debian/project/media/videos/introduction_to_raster_qBhrnAx.mp4', '-c:v', 'libx264', '-crf', '23', '-preset', 'medium', '-c:a', 'aac', '-b:a', '128k', '-f', 'hls', '-hls_time', '10', '-hls_list_size', '0', '-hls_segment_filename', '/home/debian/project/media/hls/ZN3fsJVEfTDEc8MFb5DrP7Y34JFNLj0hfWnGRZAwFdjuG_%05d.ts', '/home/debian/project/media/hls/ZN3fsJVEfTDEc8MFb5DrP7Y34JFNLj0hfWnGRZAwFdjuG.m3u8']' returned non-zero exit status 1.


    


    Also it does not work for .MOV files.