Recherche avancée

Médias (91)

Autres articles (31)

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

  • Les tâches Cron régulières de la ferme

    1er décembre 2010, par

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

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

  • A ffmpeg comman canwork in cmd but not in Python using subprocess.call() or os.system()

    6 juin 2018, par Starrysky

    I wanna transfer a .mp3 to .wav. This is my command :
    ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav

    It worked well in cmd

    C:\Users\starrysky\Documents\GitHub\bing_pic\html>ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav
    ffmpeg version N-86482-gbc40674 Copyright (c) 2000-2017 the FFmpeg developers
     built with gcc 7.1.0 (GCC)
     configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
     libavutil      55. 66.100 / 55. 66.100
     libavcodec     57. 99.100 / 57. 99.100
     libavformat    57. 73.100 / 57. 73.100
     libavdevice    57.  7.100 / 57.  7.100
     libavfilter     6. 92.100 /  6. 92.100
     libswscale      4.  7.101 /  4.  7.101
     libswresample   2.  8.100 /  2.  8.100
     libpostproc    54.  6.100 / 54.  6.100
    Input #0, mp3, from 'a.mp3':
     Metadata:
       encoder         : Lavf54.6.100
     Duration: 00:00:01.87, start: 0.000000, bitrate: 8 kb/s
       Stream #0:0: Audio: mp3, 8000 Hz, mono, s16p, 8 kb/s
    Stream mapping:
     Stream #0:0 -> #0:0 (mp3 (native) -> pcm_s16le (native))
    Press [q] to stop, [?] for help
    Output #0, wav, to 'a.wav':
     Metadata:
       ISFT            : Lavf57.73.100
       Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
       Metadata:
         encoder         : Lavc57.99.100 pcm_s16le
    size=      59kB time=00:00:01.87 bitrate= 256.3kbits/s speed= 187x
    video:0kB audio:58kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.130208%

    but when I moved it into my python program, something strange happened.

    >>> C:\Users\starrysky\Documents\GitHub\bing_pic\html\
    'ffmpeg' �����ڲ����ⲿ���Ҳ���ǿ����еij���
    ���������ļ���
    1 Command 'ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav' returned non-zero exit status 1.
    文件错误啊,亲
    [WinError 2] 系统找不到指定的文件。: 'a.wav'

    This is part of my python code :

    @bot.register(wife, RECORDING)
    def translate_sound(msg):
       msg.get_file(save_path='a.mp3')
       path = os.path.abspath('.')+'\\'
       print(path)
       try:
           subprocess.check_call('ffmpeg -i a.mp3 -ar 16000 -ac 1 -acodec pcm_s16le a.wav', shell=True)
           # ''
       except Exception as e:
           print(1, e)
       wav_to_text('a.wav')
       try:
           os.remove('a.wav')
       except Exception as e:
           print(e)

    # 调用百度语音识别API
    def get_token():
       URL = 'http://openapi.baidu.com/oauth/2.0/token'
       _params = urllib.parse.urlencode({'grant_type': b'client_credentials',
                                         'client_id': b''
                                         'client_secret': b''})
       _res = urllib.request.Request(URL, _params.encode())
       _response = urllib.request.urlopen(_res)
       _data = _response.read()
       _data = json.loads(_data)
       return _data['access_token']


    def wav_to_text(wav_file):
       try:
           wav_file = open(wav_file, 'rb')
       except IOError:
           print('文件错误啊,亲')
           return
       wav_file = wave.open(wav_file)
       n_frames = wav_file.getnframes()
       print('n_frames ', n_frames)
       frame_rate = wav_file.getframerate()
       print("frame_rate ", frame_rate)
       if n_frames == 1 or frame_rate not in (8000, 16000):
           print('不符合格式')
           return
       audio = wav_file.readframes(n_frames)
       seconds = n_frames/frame_rate+1
       minute = int(seconds/60 + 1)
       for i in range(0, minute):
           sub_audio = audio[i*60*frame_rate:(i+1)*60*frame_rate]
           base_data = base64.b64encode(sub_audio)
           data = {"format": "wav",
                   "token": get_token(),
                   "len": len(sub_audio),
                   "rate": frame_rate,
                   "speech": base_data.decode(),
                   "cuid": "B8-AC-6F-2D-7A-94",
                   "channel": 1}
           data = json.dumps(data)
           res = urllib.request.Request('http://vop.baidu.com/server_api',
                                 data.encode(),
                                 {'content-type': 'application/json'})
           response = urllib.request.urlopen(res)
           res_data = json.loads(response.read())
           try:
               print(res_data['result'][0])
           except Exception as e:
               print(e)

    What happened ?

  • Google’s YouTube Uses FFmpeg

    9 février 2011, par Multimedia Mike — General

    Controversy arose last week when Google accused Microsoft of stealing search engine results for their Bing search engine. It was a pretty novel sting operation and Google did a good job of visually illustrating their side of the story on their official blog.

    This reminds me of the fact that Google’s YouTube video hosting site uses FFmpeg for converting videos. Not that this is in the same league as the search engine shenanigans (it’s perfectly legit to use FFmpeg in this capacity, but to my knowledge, Google/YouTube has never confirmed FFmpeg usage), but I thought I would revisit this item and illustrate it with screenshots. This is not new information— I first empirically tested this fact 4 years ago. However, a lot of people wonder how exactly I can identify FFmpeg on the backend when I claim that I’ve written code that helps power YouTube.

    Short Answer
    How do I know YouTube uses FFmpeg to convert multimedia ? Because :

    1. FFmpeg can decode a number of impossibly obscure multimedia formats using code I wrote
    2. YouTube can transcode many of the same formats
    3. I screwed up when I wrote the code to support some of these weird formats
    4. My mistakes are still present when YouTube transcodes certain fringe formats

    Longer Answer (With Pictures !)
    Let’s take a video format named RoQ, developed by noted game designer Graeme Devine. Originated for use in the FMV-heavy game The 11th Hour, the format eventually found its way into the Quake 3 engine as well as many games derived from the same technology.

    Dr. Tim Ferguson reverse engineered the format (though it would later be open sourced along with the rest of the Q3 engine). I wrote a RoQ playback system for FFmpeg, and I messed up in doing so. I believe my coding error helps demonstrate the case I’m trying to make here.

    Observe what happened when I pushed the jk02.roq sample through YouTube in my original experiment 4 years ago :



    Do you see how the canyon walls bleed into the sky ? That’s not supposed to happen. FFmpeg doesn’t do that anymore but I was able to go back into the source code history to find when it did do that :



    Academic Answer
    FFmpeg fixed this bug in June of 2007 (thanks to Eric Lasota). The problem had to do with premature colorspace conversion in my original decoder.

    Leftovers
    I tried uploading the video again to see if the problem persists in YouTube’s transcoder. First bit of trivia : YouTube detects when you have uploaded the same video twice and rejects the subsequent attempts. So I created a double concatenation of the video and uploaded it. The problem is gone, illustrating that the backend is actually using a newer version of FFmpeg. This surprises me for somewhat esoteric reasons.

    Here’s another interesting bit of trivia for those who don’t do a lot of YouTube uploading— YouTube reports format details when you upload a video :



    So, yep, RoQ format. And you can wager that this will prompt me to go back through the litany of unusual formats that FFmpeg supports to see how YouTube responds.

  • Permissions issue with Python and ffmpeg on a Mac

    13 avril 2020, par EventHorizon

    I am fairly new to Python ( 4 weeks), and I have been struggling with this all day.

    



    I am using MacOS 10.13, Python 3.7 via Anaconda Navigator 1.9.12 and Spyder 4.0.1.

    



    Somehow (only a noob, remember) I had 2 Anaconda environments. I don't do production code, just research, so I figured I would make life simple and just use the base environment. I deleted the other environment.

    



    I had previously got FFmpeg working and was able to do frame grabs, build mpeg animations, and convert them to gifs for blog posts and such. I had FFmpeg installed in the directories associated with the deleted environment, so it went away.

    



    No worries, I got the git URL, used Terminal to install it in /opt/anaconda3/bin. It's all there and I can run FFmpeg from the Terminal.

    



    My problem : When I attempt to run a module that previously worked fine, I get the following message :

    



    [Errno 13] Permission denied : '/opt/anaconda3/bin/ffmpeg'

    



    In my module I set the default location of FFmpeg : plt.rcParams['animation.ffmpeg_path'] = '/opt/anaconda3/bin/ffmpeg'

    



    In my module I have the following lines :

    



    writer = animation.FFMpegWriter(fps=frameRate, metadata=metadata)
writer.setup(fig, "animation.mp4", 100)


    



    This calls matplotlib's 'animation.py', which runs the following :

    



    def setup(self, fig, outfile, dpi=None):
    '''
    Perform setup for writing the movie file.

    Parameters
    ----------
    fig : `~matplotlib.figure.Figure`
        The figure object that contains the information for frames
    outfile : str
        The filename of the resulting movie file
    dpi : int, optional
        The DPI (or resolution) for the file.  This controls the size
        in pixels of the resulting movie file. Default is fig.dpi.
    '''
    self.outfile = outfile
    self.fig = fig
    if dpi is None:
        dpi = self.fig.dpi
    self.dpi = dpi
    self._w, self._h = self._adjust_frame_size()

    # Run here so that grab_frame() can write the data to a pipe. This
    # eliminates the need for temp files.
    self._run()

def _run(self):
    # Uses subprocess to call the program for assembling frames into a
    # movie file.  *args* returns the sequence of command line arguments
    # from a few configuration options.
    command = self._args()
    _log.info('MovieWriter.run: running command: %s', command)
    PIPE = subprocess.PIPE
    self._proc = subprocess.Popen(
        command, stdin=PIPE, stdout=PIPE, stderr=PIPE,
        creationflags=subprocess_creation_flags)


    



    Everything works fine up to the last line (i.e. 'command' looks like a well-formatted FFmpeg command line, PIPE returns -1) but subprocess.Popen() bombs out with the error message above.

    



    I have tried changing file permissions - taking a sledgehammer approach and setting everything in /opt/anaconda3/bin/ffmpeg to 777, read, write, and execute. But that doesn't seem to make any difference. I really am clueless when it comes to Apple's OS, file permissions, etc. Any suggestions ?