Recherche avancée

Médias (0)

Mot : - Tags -/tags

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

Autres articles (66)

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

  • MediaSPIP : Modification des droits de création d’objets et de publication définitive

    11 novembre 2010, par

    Par défaut, MediaSPIP permet de créer 5 types d’objets.
    Toujours par défaut les droits de création et de publication définitive de ces objets sont réservés aux administrateurs, mais ils sont bien entendu configurables par les webmestres.
    Ces droits sont ainsi bloqués pour plusieurs raisons : parce que le fait d’autoriser à publier doit être la volonté du webmestre pas de l’ensemble de la plateforme et donc ne pas être un choix par défaut ; parce qu’avoir un compte peut servir à autre choses également, (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (11226)

  • Can't initialize "h264_mediacodec" for hw accelerated decoding, FFMPEG, Android

    27 mars 2024, par Ramil Galin

    I am trying to create hw accelerated decoding on Android through JNI and following this example but, unfortunately, avcodec_get_hw_config returns nullptr.

    


    I have also tried using avcodec_find_decoder_by_name("h264_mediacodec"), also returns nullptr.

    


    I built ffmpeg (version 4.4) using this script with the flags :

    


    --enable-jni \
--enable-mediacodec \
--enable-decoder=h264_mediacodec \
--enable-hwaccel=h264_mediacodec \


    


    When configuring build I saw in logs WARNING: Option --enable-hwaccel=h264_mediacodec did not match anything, which is actually strange. FFMPEG 4.4 should support hw accelerated decoding using mediacodec.

    


    Edit : (providing minimal reproducible example)

    


    In the JNI method I init input context of decoder and init decoder :

    


        void Decoder::initInputContext(&#xA;        const std::string&amp; source,&#xA;        AVDictionary* options&#xA;    ) { // open input, and allocate format context&#xA;        if (&#xA;            avformat_open_input(&#xA;                &amp;m_inputFormatContext,&#xA;                source.c_str(),&#xA;                NULL,&#xA;                options ? &amp;options : nullptr&#xA;            ) &lt; 0&#xA;        ) {&#xA;            throw FFmpegException(&#xA;                fmt::format("Decoder: Could not open source {}", source)&#xA;            );&#xA;        }&#xA; &#xA;        // retrieve stream information&#xA;        if (avformat_find_stream_info(m_inputFormatContext, NULL) &lt; 0) {&#xA;            throw FFmpegException(&#xA;                "Decoder: Could not find stream information"&#xA;            );&#xA;        }&#xA;&#xA;        // get audio and video streams&#xA;        for (size_t i = 0; i &lt; m_inputFormatContext->nb_streams; i&#x2B;&#x2B;) {&#xA;            AVStream* inStream = m_inputFormatContext->streams[i];&#xA;            AVCodecParameters* inCodecpar = inStream->codecpar;&#xA;            if (&#xA;                inCodecpar->codec_type != AVMEDIA_TYPE_AUDIO &amp;&amp;&#xA;                inCodecpar->codec_type != AVMEDIA_TYPE_VIDEO&#xA;            ) {&#xA;                continue;&#xA;            }&#xA;&#xA;            if (inCodecpar->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;                m_videoStreamIdx = i;&#xA;                m_videoStream = inStream;&#xA;&#xA;                m_codecParams.videoCodecId = m_videoStream->codecpar->codec_id;&#xA;                m_codecParams.fps = static_cast<int>(av_q2d(m_videoStream->r_frame_rate) &#x2B; 0.5);&#xA;                m_codecParams.clockrate = m_videoStream->time_base.den;&#xA;&#xA;                spdlog::debug(&#xA;                    "Decoder: fps: {}, clockrate: {}",&#xA;                    m_codecParams.fps,&#xA;                    m_codecParams.clockrate&#xA;                )&#xA;                ;&#xA;            }&#xA;&#xA;            if (inCodecpar->codec_type == AVMEDIA_TYPE_AUDIO) {&#xA;                m_audioStreamIdx = i;&#xA;                m_audioStream = inStream;&#xA;&#xA;                m_codecParams.audioCodecId = m_audioStream->codecpar->codec_id;&#xA;                m_codecParams.audioSamplerate = m_audioStream->codecpar->sample_rate;&#xA;                m_codecParams.audioChannels = m_audioStream->codecpar->channels;&#xA;                m_codecParams.audioProfile = m_audioStream->codecpar->profile;&#xA;&#xA;                spdlog::debug(&#xA;                    "Decoder: audio samplerate: {}, audio channels: {}, x: {}",&#xA;                    m_codecParams.audioSamplerate,&#xA;                    m_codecParams.audioChannels,&#xA;                    m_audioStream->codecpar->channels&#xA;                )&#xA;                ;&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    void Decoder::initDecoder() {&#xA;        AVCodecParameters* videoStreamCodecParams = m_videoStream->codecpar;&#xA;&#xA;        m_swsContext = sws_getContext(&#xA;                videoStreamCodecParams->width, videoStreamCodecParams->height, m_pixFormat,&#xA;                videoStreamCodecParams->width, videoStreamCodecParams->height, m_targetPixFormat,&#xA;                SWS_BICUBIC, nullptr, nullptr, nullptr);&#xA;&#xA;        // find best video stream info and decoder&#xA;        int ret = av_find_best_stream(m_inputFormatContext, AVMEDIA_TYPE_VIDEO, -1, -1, &amp;m_decoder, 0);&#xA;        if (ret &lt; 0) {&#xA;            throw FFmpegException(&#xA;                    "Decoder: Cannot find a video stream in the input file"&#xA;            );&#xA;        }&#xA;&#xA;        if (!m_decoder) {&#xA;            throw FFmpegException(&#xA;                    "Decoder: Can&#x27;t find decoder"&#xA;            );&#xA;        }&#xA;&#xA;        // search for supported HW decoder configuration&#xA;        for (size_t i = 0;; i&#x2B;&#x2B;) {&#xA;            const AVCodecHWConfig* config = avcodec_get_hw_config(m_decoder, i);&#xA;            if (!config) {&#xA;                spdlog::error(&#xA;                    "Decoder {} does not support device type {}. "&#xA;                    "Will use SW decoder...",&#xA;                    m_decoder->name,&#xA;                    av_hwdevice_get_type_name(m_deviceType)&#xA;                );&#xA;                break;&#xA;            }&#xA;&#xA;            if (&#xA;                config->methods &amp; AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX &amp;&amp;&#xA;                config->device_type == m_deviceType&#xA;            ) {&#xA;                // set up pixel format for HW decoder&#xA;                g_hwPixFmt = config->pix_fmt;&#xA;                m_hwDecoderSupported = true;&#xA;                break;&#xA;            }&#xA;        }&#xA;    }&#xA;</int>

    &#xA;

    And I have AVHWDeviceType m_deviceType{AV_HWDEVICE_TYPE_MEDIACODEC};

    &#xA;

    avcodec_get_hw_config returns nullptr.

    &#xA;

    Any help is appreciated.

    &#xA;

  • How to transcribe the recording for speech recognization

    29 mai 2021, par DLim

    After downloading and uploading files related to the mozilla deeepspeech, I started using google colab. I am using mozilla/deepspeech for speech recognization. The code shown below is for recording my audio. After recording the audio, I want to use a function/method to transcribe the recording into text. Everything compiles, but the text does not come out correctly. Any thoughts in my code ?

    &#xA;

    """&#xA;To write this piece of code I took inspiration/code from a lot of places.&#xA;It was late night, so I&#x27;m not sure how much I created or just copied o.O&#xA;Here are some of the possible references:&#xA;https://blog.addpipe.com/recording-audio-in-the-browser-using-pure-html5-and-minimal-javascript/&#xA;https://stackoverflow.com/a/18650249&#xA;https://hacks.mozilla.org/2014/06/easy-audio-capture-with-the-mediarecorder-api/&#xA;https://air.ghost.io/recording-to-an-audio-file-using-html5-and-js/&#xA;https://stackoverflow.com/a/49019356&#xA;"""&#xA;from google.colab.output import eval_js&#xA;from base64 import b64decode&#xA;from scipy.io.wavfile import read as wav_read&#xA;import io&#xA;import ffmpeg&#xA;&#xA;AUDIO_HTML = """&#xA;<code class="echappe-js">&lt;script&gt;&amp;#xA;var my_div = document.createElement(&quot;DIV&quot;);&amp;#xA;var my_p = document.createElement(&quot;P&quot;);&amp;#xA;var my_btn = document.createElement(&quot;BUTTON&quot;);&amp;#xA;var t = document.createTextNode(&quot;Press to start recording&quot;);&amp;#xA;&amp;#xA;my_btn.appendChild(t);&amp;#xA;//my_p.appendChild(my_btn);&amp;#xA;my_div.appendChild(my_btn);&amp;#xA;document.body.appendChild(my_div);&amp;#xA;&amp;#xA;var base64data = 0;&amp;#xA;var reader;&amp;#xA;var recorder, gumStream;&amp;#xA;var recordButton = my_btn;&amp;#xA;&amp;#xA;var handleSuccess = function(stream) {&amp;#xA;  gumStream = stream;&amp;#xA;  var options = {&amp;#xA;    //bitsPerSecond: 8000, //chrome seems to ignore, always 48k&amp;#xA;    mimeType : &amp;#x27;audio/webm;codecs=opus&amp;#x27;&amp;#xA;    //mimeType : &amp;#x27;audio/webm;codecs=pcm&amp;#x27;&amp;#xA;  };            &amp;#xA;  //recorder = new MediaRecorder(stream, options);&amp;#xA;  recorder = new MediaRecorder(stream);&amp;#xA;  recorder.ondataavailable = function(e) {            &amp;#xA;    var url = URL.createObjectURL(e.data);&amp;#xA;    var preview = document.createElement(&amp;#x27;audio&amp;#x27;);&amp;#xA;    preview.controls = true;&amp;#xA;    preview.src = url;&amp;#xA;    document.body.appendChild(preview);&amp;#xA;&amp;#xA;    reader = new FileReader();&amp;#xA;    reader.readAsDataURL(e.data); &amp;#xA;    reader.onloadend = function() {&amp;#xA;      base64data = reader.result;&amp;#xA;      //console.log(&quot;Inside FileReader:&quot; &amp;#x2B; base64data);&amp;#xA;    }&amp;#xA;  };&amp;#xA;  recorder.start();&amp;#xA;  };&amp;#xA;&amp;#xA;recordButton.innerText = &quot;Recording... press to stop&quot;;&amp;#xA;&amp;#xA;navigator.mediaDevices.getUserMedia({audio: true}).then(handleSuccess);&amp;#xA;&amp;#xA;&amp;#xA;function toggleRecording() {&amp;#xA;  if (recorder &amp;amp;&amp;amp; recorder.state == &quot;recording&quot;) {&amp;#xA;      recorder.stop();&amp;#xA;      gumStream.getAudioTracks()[0].stop();&amp;#xA;      recordButton.innerText = &quot;Saving the recording... pls wait!&quot;&amp;#xA;  }&amp;#xA;}&amp;#xA;&amp;#xA;// https://stackoverflow.com/a/951057&amp;#xA;function sleep(ms) {&amp;#xA;  return new Promise(resolve =&gt; setTimeout(resolve, ms));&amp;#xA;}&amp;#xA;&amp;#xA;var data = new Promise(resolve=&gt;{&amp;#xA;//recordButton.addEventListener(&quot;click&quot;, toggleRecording);&amp;#xA;recordButton.onclick = ()=&gt;{&amp;#xA;toggleRecording()&amp;#xA;&amp;#xA;sleep(2000).then(() =&gt; {&amp;#xA;  // wait 2000ms for the data to be available...&amp;#xA;  // ideally this should use something like await...&amp;#xA;  //console.log(&quot;Inside data:&quot; &amp;#x2B; base64data)&amp;#xA;  resolve(base64data.toString())&amp;#xA;&amp;#xA;});&amp;#xA;&amp;#xA;}&amp;#xA;});&amp;#xA;      &amp;#xA;&lt;/script&gt;&#xA;"""&#xA;&#xA;def get_audio() :&#xA;  display(HTML(AUDIO_HTML))&#xA;  data = eval_js("data")&#xA;  binary = b64decode(data.split(',')[1])&#xA;  &#xA;  process = (ffmpeg&#xA;    .input('pipe:0')&#xA;    .output('pipe:1', format='wav')&#xA;    .run_async(pipe_stdin=True, pipe_stdout=True, pipe_stderr=True, quiet=True, overwrite_output=True)&#xA;  )&#xA;  output, err = process.communicate(input=binary)&#xA;  &#xA;  riff_chunk_size = len(output) - 8&#xA;  # Break up the chunk size into four bytes, held in b.&#xA;  q = riff_chunk_size&#xA;  b = []&#xA;  for i in range(4) :&#xA;      q, r = divmod(q, 256)&#xA;      b.append(r)&#xA;&#xA;  # Replace bytes 4:8 in proc.stdout with the actual size of the RIFF chunk.&#xA;  riff = output[:4] + bytes(b) + output[8 :]&#xA;&#xA;  sr, audio = wav_read(io.BytesIO(riff))&#xA;&#xA;  return audio, sr&#xA;&#xA;audio, sr = get_audio()&#xA;

    &#xA;

    def recordingTranscribe(audio):&#xA;  data16 = np.frombuffer(audio)&#xA;  return model.stt(data16)&#xA;

    &#xA;

    recordingTranscribe(audio)&#xA;

    &#xA;

  • ffmpeg not recording frames

    28 mai 2024, par RCam

    I am using Python to record 5 second videos from 3 webcams at once using ffmpeg. The recordings repeat at intervals of 25 seconds. The code seems to work except intermittently a recording from one of the cameras will be 0 seconds long. There don't seem to be any obvious errors, and the file is created it just doesn't contain any frames. The key components of the code are :

    &#xA;

    def take_vid1(path1, video_length, sampleN):  &#xA;    dt = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")&#xA;    save1 = os.path.join(path1, dt&#x2B;&#x27;_1&#x27;&#x2B;sampleN&#x2B;&#x27;.mp4&#x27;)&#xA;    command = [ffmpeg_path, &#x27;-hide_banner&#x27;, &#x27;-y&#x27;, &#x27;-f&#x27;, &#x27;dshow&#x27;, &#x27;-thread_queue_size&#x27;, &#x27;4096&#x27;, &#x27;-rtbufsize&#x27;, &#x27;500M&#x27;, &#x27;-c:v&#x27;, &#x27;mjpeg&#x27;, &#x27;-video_size&#x27;, &#x27;1600x896&#x27;, &#x27;-framerate&#x27;, &#x27;30&#x27;, &#x27;-i&#x27;, &#x27;video=&#x27;&#x2B;dev1, &#x27;-map&#x27;, &#x27;0&#x27;, &#x27;-t&#x27;, video_length, save1]&#xA;    sp = subprocess.run(command, capture_output=True, text=True) &#xA;    print(dt &#x2B; &#x27; vid1 returncode: &#x27; &#x2B; str(sp.returncode)) &#xA;def take_vid2(path2, video_length, sampleN):  &#xA;    dt = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")&#xA;    save2 = os.path.join(path2, dt&#x2B;&#x27;_2&#x27;&#x2B;sampleN&#x2B;&#x27;.mp4&#x27;)&#xA;    command = [ffmpeg_path, &#x27;-hide_banner&#x27;, &#x27;-y&#x27;, &#x27;-f&#x27;, &#x27;dshow&#x27;, &#x27;-thread_queue_size&#x27;, &#x27;4096&#x27;, &#x27;-rtbufsize&#x27;, &#x27;500M&#x27;, &#x27;-c:v&#x27;, &#x27;mjpeg&#x27;, &#x27;-video_size&#x27;, &#x27;1600x896&#x27;, &#x27;-framerate&#x27;, &#x27;30&#x27;, &#x27;-i&#x27;, &#x27;video=&#x27;&#x2B;dev2, &#x27;-map&#x27;, &#x27;0&#x27;, &#x27;-t&#x27;, video_length, save2]&#xA;    sp = subprocess.run(command, capture_output=True, text=True) &#xA;    print(dt &#x2B; &#x27; vid2 returncode: &#x27; &#x2B; str(sp.returncode))  &#xA;def take_vid3(path3, video_length, sampleN):  &#xA;    dt = datetime.now().strftime("%Y_%m_%d_%H_%M_%S")&#xA;    save3 = os.path.join(path3, dt&#x2B;&#x27;_3&#x27;&#x2B;sampleN&#x2B;&#x27;.mp4&#x27;)&#xA;    command = [ffmpeg_path, &#x27;-hide_banner&#x27;, &#x27;-y&#x27;, &#x27;-f&#x27;, &#x27;dshow&#x27;, &#x27;-thread_queue_size&#x27;, &#x27;4096&#x27;, &#x27;-rtbufsize&#x27;, &#x27;500M&#x27;, &#x27;-c:v&#x27;, &#x27;mjpeg&#x27;, &#x27;-video_size&#x27;, &#x27;1600x896&#x27;, &#x27;-framerate&#x27;, &#x27;30&#x27;, &#x27;-i&#x27;, &#x27;video=&#x27;&#x2B;dev3, &#x27;-report&#x27;, &#x27;-map&#x27;, &#x27;0&#x27;, &#x27;-t&#x27;, video_length, save3]&#xA;    sp = subprocess.run(command, capture_output=True, text=True) &#xA;    print(dt &#x2B; &#x27; vid3 returncode: &#x27; &#x2B; str(sp.returncode))  &#xA;&#xA;t1 = Thread(target=take_vid1, args=[cam1Path, video_length,sampleN])&#xA;t2 = Thread(target=take_vid2, args=[cam2Path, video_length,sampleN])&#xA;t3 = Thread(target=take_vid3, args=[cam3Path, video_length,sampleN])&#xA;threads = [t1,t2,t3]&#xA;if __name__ == &#x27;__main__&#x27;:&#xA;    for t in threads:&#xA;        t.start()&#xA;    for t in threads:&#xA;        t.join()&#xA;

    &#xA;

    I'm not sure if this is a coincidence but this issue only affects recordings from camera 3. It doesn't seem to be hardware related because I have switched camera 3 with another camera and it still happens. I've tried calling the threads in different orders, no change. I've updated ffmpeg to the most recent static build. CPU usage and memory are reasonable when the recordings are taking place. At this point I don't know what could be causing ffmpeg to fail to write frames. The link to the log file from a failed recording is below, I'm hoping someone might see something to indicate what is going on or at least have suggestions as to what to try next ?

    &#xA;

    https://drive.google.com/file/d/1VKBBsf8pZbqNyYLE6o2C0kFHeBAh2kZ1/view?usp=sharing

    &#xA;