Recherche avancée

Médias (0)

Mot : - Tags -/organisation

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

Autres articles (36)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (5737)

  • Python : mp3 to alsaaudio through ffmpeg pipe and wave.open(f,'r')

    3 juillet 2017, par user2754098

    I’m trying to decode mp3 to wav using ffmpeg :

    import alsaaudio
    import wave
    from subprocess import Popen, PIPE

    with open('filename.mp3', 'rb') as infile:
       p=Popen(['ffmpeg', '-i', '-', '-f', 'wav', '-'], stdin=infile, stdout=PIPE)
       ...

    Next i want redirect data from p.stdout.read() to wave.open(file, r) to use readframes(n) and other methods. But i cannot because ’file’ in wave.open(file,’r’) can be only name of file or an open file pointer.

       ...
       file = wave.open(p.stdout.read(),'r')
       card='default'
       device=alsaaudio.PCM(card=card)
       device.setchannels(file.getnchannels())
       device.setrate(file.getframerate())
       device.setformat(alsaaudio.PCM_FORMAT_S16_LE)
       device.setsetperiodsize(320)
       data = file.readframes(320)
       while data:
           device.write(data)
           data = file.readframes(320)

    I got :

    TypeError: file() argument 1 must be encoded string without NULL bytes, not str

    So is it possible to handle data from p.stdout.read() by wave.open() ?
    Making temporary .wav file isn’t solution.

    Sorry for my english.
    Thanks.

    UPDATE

    Thanks to PM 2Ring for hit about io.BytesIO.

    However resulting code does not work.

    import alsaaudio
    import wave
    from subprocess import Popen, PIPE

    with open('sometrack.mp3', 'rb') as infile:
           p=Popen(['ffmpeg', '-i', '-', '-f','wav', '-'], stdin=infile , stdout=PIPE , stderr=PIPE)
           fobj = io.BytesIO(p.stdout.read())
    fwave = wave.open(fobj, 'rb')

    Trace :

    File "./script.py", line x, in <module>
     fwave = wave.open(fobj, 'rb')
    File "/usr/lib/python2.7/wave.py", line x, in open
     return Wave_read(f)
    File "/usr/lib/python2.7/wave.py", line x, in __init__
     self.initfp(f)
    File "/usr/lib/python2.7/wave.py", line x, in initfp
     raise Error, 'not a WAVE file'
    wave.Error: not a WAVE file
    </module>

    From /usr/lib/python2.7/wave.py :

    ...
    self._file = Chunk(file, bigendian = 0)
    if self._file.getname() != 'RIFF':
       raise Error, 'file does not start with RIFF id'
    if self._file.read(4) != 'WAVE':
       raise Error, 'not a WAVE file'
    ...

    Checking has been failed due to ’bad’ self._file object.

    Inside /usr/lib/python2.7/chunk.py i have found a source of problem :

    ...
    try:
       self.chunksize = struct.unpack(strflag+'L', file.read(4))[0]
    except struct.error:
       raise EOFError
    ...

    Because struct.unpack(strflag+’L’, file.read(4))[0] returns 0.
    But this function works correct.

    As specified here :

    "5-8 bytes - File size(integer)
    Size of the overall file - 8 bytes, in bytes (32-bit integer). Typically, you’d fill this in after creation."
    That’s why my script doesn’t work. wave.open and other functions cannot handle my file object because self.chunksize = 0. Looks like ffmpeg cannot insert File size when using PIPE.

    SOLUTION

    It’s simple.
    I’ve changed init function of Chunk class :

    After :

    ...
    try:
       self.chunksize = struct.unpack(strflag+'L', file.read(4))[0]
    except struct.error:
       raise EOFError
    ...

    Before :

    ...
    try:
       self.chunksize = struct.unpack(strflag+'L', file.read(4))[0]
       currtell = file.tell()
       if self.chunksize == 0:
           file.seek(0)
           file.read(currtell)
           self.chunksize = len(file.read())-4
           file.seek(0)
           file.read(currtell)
    except struct.error:
       raise EOFError
    ...

    Of course editing of original module is bad idia. So I’ve create custom forks for 2 classes Chunk and Wave_read.

    Working but unstable full code you can find here.

    Sorry for my awful english.

    Thanks.

  • Python : mp3 to alsaaudio through ffmpeg pipe and wave.open(f,'r')

    16 avril 2015, par user2754098

    I’m trying to decode mp3 to wav using ffmpeg :

    import alsaaudio
    import wave
    from subprocess import Popen, PIPE

    with open('filename.mp3', 'rb') as infile:
       p=Popen(['ffmpeg', '-i', '-', '-f', 'wav', '-'], stdin=infile, stdout=PIPE)
       ...

    Next i want redirect data from p.stdout.read() to wave.open(file, r) to use readframes(n) and other methods. But i cannot because ’file’ in wave.open(file,’r’) can be only name of file or an open file pointer.

       ...
       file = wave.open(p.stdout.read(),'r')
       card='default'
       device=alsaaudio.PCM(card=card)
       device.setchannels(file.getnchannels())
       device.setrate(file.getframerate())
       device.setformat(alsaaudio.PCM_FORMAT_S16_LE)
       device.setsetperiodsize(320)
       data = file.readframes(320)
       while data:
           device.write(data)
           data = file.readframes(320)

    I got :

    TypeError: file() argument 1 must be encoded string without NULL bytes, not str

    So is it possible to handle data from p.stdout.read() by wave.open() ?
    Making temporary .wav file isn’t solution.

    Sorry for my english.
    Thanks.

    UPDATE

    Thanks to PM 2Ring for hit about io.BytesIO.

    However resulting code does not work.

    import alsaaudio
    import wave
    from subprocess import Popen, PIPE

    with open('sometrack.mp3', 'rb') as infile:
           p=Popen(['ffmpeg', '-i', '-', '-f','wav', '-'], stdin=infile , stdout=PIPE , stderr=PIPE)
           fobj = io.BytesIO(p.stdout.read())
    fwave = wave.open(fobj, 'rb')

    Trace :

    File "./script.py", line x, in <module>
     fwave = wave.open(fobj, 'rb')
    File "/usr/lib/python2.7/wave.py", line x, in open
     return Wave_read(f)
    File "/usr/lib/python2.7/wave.py", line x, in __init__
     self.initfp(f)
    File "/usr/lib/python2.7/wave.py", line x, in initfp
     raise Error, 'not a WAVE file'
    wave.Error: not a WAVE file
    </module>

    From /usr/lib/python2.7/wave.py :

    ...
    self._file = Chunk(file, bigendian = 0)
    if self._file.getname() != 'RIFF':
       raise Error, 'file does not start with RIFF id'
    if self._file.read(4) != 'WAVE':
       raise Error, 'not a WAVE file'
    ...

    Checking has been failed due to ’bad’ self._file object.

    Inside /usr/lib/python2.7/chunk.py i have found a source of problem :

    ...
    try:
       self.chunksize = struct.unpack(strflag+'L', file.read(4))[0]
    except struct.error:
       raise EOFError
    ...

    Because struct.unpack(strflag+’L’, file.read(4))[0] returns 0.
    But this function works correct.

    As specified here :

    "5-8 bytes - File size(integer)
    Size of the overall file - 8 bytes, in bytes (32-bit integer). Typically, you’d fill this in after creation."
    That’s why my script doesn’t work. wave.open and other functions cannot handle my file object because self.chunksize = 0. Looks like ffmpeg cannot insert File size when using PIPE.

    SOLUTION

    It’s simple.
    I’ve changed init function of Chunk class :

    After :

    ...
    try:
       self.chunksize = struct.unpack(strflag+'L', file.read(4))[0]
    except struct.error:
       raise EOFError
    ...

    Before :

    ...
    try:
       self.chunksize = struct.unpack(strflag+'L', file.read(4))[0]
       currtell = file.tell()
       if self.chunksize == 0:
           file.seek(0)
           file.read(currtell)
           self.chunksize = len(file.read())-4
           file.seek(0)
           file.read(currtell)
    except struct.error:
       raise EOFError
    ...

    Of course editing of original module is bad idia. So I’ve create custom forks for 2 classes Chunk and Wave_read.

    Working but unstable full code you can find here.

    Sorry for my awful english.

    Thanks.

  • DXVA2/D3D11 encoders not available in FFmpeg for no apparent reason

    3 juillet 2020, par user1134621

    this is a weird one. I am trying to set up FFmpeg for hardware encoding of a live input into h264. I got it working fine on Linux with VAAPI. On Windows I was probably successful as well with NVENC but I do not have a NVENC capable card to check. What has been giving me a headache is encoding through DXVA2 or D3D11VA. FFmpeg picks up available hardware but it will not give me any suitable encoders. I even built FFmpeg myself to make sure that all the CONFIG_DXVA_HWACCEL switches are enabled, I can grep the binary for h264_dxva2 etc. and see that they are there. However, calling avcodec_find_encoder_by_name always returns NULL. h264_vaapi or h264_nvenc work fine though. I am obviously missing something stupid. Do you have any suggestions where to look ? Thanks.

    &#xA;