Recherche avancée

Médias (1)

Mot : - Tags -/copyleft

Autres articles (47)

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

  • La sauvegarde automatique de canaux SPIP

    1er avril 2010, par

    Dans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
    Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)

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

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

  • How to convert rtmp hevc video stream to srt av1 endpoint with ffmpeg ?

    20 juin 2024, par Lulík

    i want use ffmpeg to listen rtmp stream and send to srt endpoint.

    &#xA;

    Flow : smartphone (camera) -> laptop (ffmpeg script) -> desktop (obs studio)

    &#xA;

    ffmpeg script show warning message and in obs stuido i can see any video only audio.

    &#xA;

    Thank you in advance.

    &#xA;

    Console output while running script (error in the end is bcs i stoped sending data from phone) :

    &#xA;

    ffmpeg version git-2024-06-20-8d6014d Copyright (c) 2000-2024 the FFmpeg developers&#xA;  built with gcc 12 (Debian 12.2.0-14)&#xA;  configuration: --enable-libsvtav1 --enable-libsrt&#xA;  libavutil      59. 24.100 / 59. 24.100&#xA;  libavcodec     61.  8.100 / 61.  8.100&#xA;  libavformat    61.  3.104 / 61.  3.104&#xA;  libavdevice    61.  2.100 / 61.  2.100&#xA;  libavfilter    10.  2.102 / 10.  2.102&#xA;  libswscale      8.  2.100 /  8.  2.100&#xA;  libswresample   5.  2.100 /  5.  2.100&#xA;Input #0, flv, from &#x27;rtmp://192.168.0.194/s/streamKey&#x27;:&#xA;  Duration: 00:00:00.00, start: 0.000000, bitrate: N/A&#xA;  Stream #0:0: Video: hevc (Main), yuv420p(tv, smpte170m/bt470bg/smpte170m), 1080x1920, 10240 kb/s, 30 fps, 120 tbr, 1k tbn&#xA;  Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp, 131 kb/s&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (hevc (native) -> av1 (libsvtav1))&#xA;  Stream #0:1 -> #0:1 (aac (native) -> mp2 (native))&#xA;Press [q] to stop, [?] for help&#xA;Svt[info]: -------------------------------------------&#xA;Svt[info]: SVT [version]:   SVT-AV1 Encoder Lib 595a874&#xA;Svt[info]: SVT [build]  :   GCC 12.2.0   64 bit&#xA;Svt[info]: LIB Build date: Jun 20 2024 14:25:08&#xA;Svt[info]: -------------------------------------------&#xA;Svt[info]: Number of logical cores available: 12&#xA;Svt[info]: Number of PPCS 76&#xA;Svt[info]: [asm level on system : up to avx2]&#xA;Svt[info]: [asm level selected : up to avx2]&#xA;Svt[info]: -------------------------------------------&#xA;Svt[info]: SVT [config]: main profile   tier (auto) level (auto)&#xA;Svt[info]: SVT [config]: width / height / fps numerator / fps denominator       : 1080 / 1920 / 120 / 1&#xA;Svt[info]: SVT [config]: bit-depth / color format                   : 8 / YUV420&#xA;Svt[info]: SVT [config]: preset / tune / pred struct                    : 10 / PSNR / random access&#xA;Svt[info]: SVT [config]: gop size / mini-gop size / key-frame type          : 641 / 16 / key frame&#xA;Svt[info]: SVT [config]: BRC mode / rate factor                     : CRF / 35 &#xA;Svt[info]: SVT [config]: AQ mode / variance boost                   : 2 / 0&#xA;Svt[info]: -------------------------------------------&#xA;Svt[warn]: Failed to set thread priority: Invalid argument&#xA;Output #0, mpegts, to &#x27;srt://192.168.0.167:9998?mode=caller&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf61.3.104&#xA;  Stream #0:0: Video: av1, yuv420p(tv, smpte170m/bt470bg/smpte170m, progressive), 1080x1920, q=2-31, 120 fps, 90k tbn&#xA;      Metadata:&#xA;        encoder         : Lavc61.8.100 libsvtav1&#xA;  Stream #0:1: Audio: mp2, 44100 Hz, stereo, s16, 384 kb/s&#xA;      Metadata:&#xA;        encoder         : Lavc61.8.100 mp2&#xA;[mpegts @ 0x55ec921d9540] Stream 0, codec av1, is muxed as a private data stream and may not be recognized upon reading.&#xA;[in#0/flv @ 0x55ec9219cc40] Error during demuxing: Input/output error1990.7kbits/s speed=0.967x    &#xA;[out#0/mpegts @ 0x55ec922247c0] video:4431KiB audio:1138KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 6.374870%&#xA;frame=  723 fps= 31 q=35.0 Lsize=    5923KiB time=00:00:24.12 bitrate=2011.3kbits/s speed=1.04x&#xA;

    &#xA;

    I send video stream from mobile app over rtmp encoded with hevc to my laptop where running script ffmpeg -f flv -listen 1 -i rtmp://192.168.0.194/s/streamKey -c:v libsvtav1 -f mpegts srt://192.168.0.167:9998?mode=caller. On the desktop i have obs with media source input srt://192.168.0.167:9998?mode=listener.

    &#xA;

    When i run ffmpeg script without video codec option (-c:v libsvtav1) its working fine and in obs i can see video from my phone camera. With the option i can not see video only audio.&#xA;I clearly dont understand warning message : [mpegts @ 0x55ec921d9540] Stream 0, codec av1, is muxed as a private data stream and may not be recognized upon reading..&#xA;Do I need specify codec (av1) in obs media source or my ffmpeg script is wrong ?

    &#xA;