Recherche avancée

Médias (1)

Mot : - Tags -/remix

Autres articles (12)

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

Sur d’autres sites (4083)

  • When recording MP4 using ffmpeg suddenly power off

    2 décembre 2016, par wanglx

    Now I used C language and ffmpeg realize a multiplex real-time audio and video to MP4 files of the program and everything works fine, but when in the process of reuse of sudden power failure, the recording is MP4 file is damaged, VLC can not play this file.
    I think reason is no call to write the trailer function av_write_trailer , causing index and time stamp information lost, I use araxis merge tool compared the successful call av_write_trailer function of file and a no av_write_trailer to call the damaged files and found two different points :
    1. Damaged files in the file header box number value not right
    2. The damaged file no end of file.

    Now I want to repair after power on my program can automatically repair the damaged files, in Google did not find effective methods.
    my train of thought is in the normal recording process saves per second a damaged file is missing two information : box number and end of file, save it to a local file, when writing the MP4 file integrity delete this file after, if power off damaged, then in the next power, read the file and the corresponding information to write the damaged files corresponding position to. But now the problem is that I don’t know how to save the number of box and the end of the file, I this is feasible ? If possible, what should I do ? Looking forward to your reply !

  • Can not add tmcd stream using libavcodec to replicate behavior of ffmpeg -timecode option

    2 août, par Sailor Jerry

    I'm trying to replicate option of command line ffmpeg -timecode in my C/C++ code. For some reasons the tcmd stream is not written to the output file. However the av_dump_format shows it in run time

    


    Here is my minimal test

    


    #include <iostream>&#xA;extern "C" {&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>avutil.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include <libavutil></libavutil>opt.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;#include <libavutil></libavutil>samplefmt.h>&#xA;}&#xA;bool checkProResAvailability() {&#xA;  const AVCodec* codec = avcodec_find_encoder_by_name("prores_ks");&#xA;  if (!codec) {&#xA;    std::cerr &lt;&lt; "ProRes codec not available. Please install FFmpeg with ProRes support." &lt;&lt; std::endl;&#xA;    return false;&#xA;  }&#xA;  return true;&#xA;}&#xA;&#xA;int main(){&#xA;  av_log_set_level(AV_LOG_INFO);&#xA;&#xA;  const char* outputFileName = "test_tmcd.mov";&#xA;  AVFormatContext* formatContext = nullptr;&#xA;  AVCodecContext* videoCodecContext = nullptr;&#xA;&#xA;  if (!checkProResAvailability()) {&#xA;    return -1;&#xA;  }&#xA;&#xA;  std::cout &lt;&lt; "Creating test file with tmcd stream: " &lt;&lt; outputFileName &lt;&lt; std::endl;&#xA;&#xA;  // Allocate the output format context&#xA;  if (avformat_alloc_output_context2(&amp;formatContext, nullptr, "mov", outputFileName) &lt; 0) {&#xA;    std::cerr &lt;&lt; "Failed to allocate output context!" &lt;&lt; std::endl;&#xA;    return -1;&#xA;  }&#xA;&#xA;  if (avio_open(&amp;formatContext->pb, outputFileName, AVIO_FLAG_WRITE) &lt; 0) {&#xA;    std::cerr &lt;&lt; "Failed to open output file!" &lt;&lt; std::endl;&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  // Find ProRes encoder&#xA;  const AVCodec* videoCodec = avcodec_find_encoder_by_name("prores_ks");&#xA;  if (!videoCodec) {&#xA;    std::cerr &lt;&lt; "Failed to find the ProRes encoder!" &lt;&lt; std::endl;&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  // Video stream setup&#xA;  AVStream* videoStream = avformat_new_stream(formatContext, nullptr);&#xA;  if (!videoStream) {&#xA;    std::cerr &lt;&lt; "Failed to create video stream!" &lt;&lt; std::endl;&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  videoCodecContext = avcodec_alloc_context3(videoCodec);&#xA;  if (!videoCodecContext) {&#xA;    std::cerr &lt;&lt; "Failed to allocate video codec context!" &lt;&lt; std::endl;&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  videoCodecContext->width = 1920;&#xA;  videoCodecContext->height = 1080;&#xA;  videoCodecContext->pix_fmt = AV_PIX_FMT_YUV422P10;&#xA;  videoCodecContext->time_base = (AVRational){1, 30}; // Set FPS: 30&#xA;  videoCodecContext->bit_rate = 2000000;&#xA;&#xA;  if (avcodec_open2(videoCodecContext, videoCodec, nullptr) &lt; 0) {&#xA;    std::cerr &lt;&lt; "Failed to open ProRes codec!" &lt;&lt; std::endl;&#xA;    avcodec_free_context(&amp;videoCodecContext);&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  if (avcodec_parameters_from_context(videoStream->codecpar, videoCodecContext) &lt; 0) {&#xA;    std::cerr &lt;&lt; "Failed to copy codec parameters to video stream!" &lt;&lt; std::endl;&#xA;    avcodec_free_context(&amp;videoCodecContext);&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  videoStream->time_base = videoCodecContext->time_base;&#xA;&#xA;  // Timecode stream setup&#xA;  AVStream* timecodeStream = avformat_new_stream(formatContext, nullptr);&#xA;  if (!timecodeStream) {&#xA;    std::cerr &lt;&lt; "Failed to create timecode stream!" &lt;&lt; std::endl;&#xA;    avcodec_free_context(&amp;videoCodecContext);&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  timecodeStream->codecpar->codec_type = AVMEDIA_TYPE_DATA;&#xA;  timecodeStream->codecpar->codec_id = AV_CODEC_ID_TIMED_ID3;&#xA;  timecodeStream->codecpar->codec_tag = MKTAG(&#x27;t&#x27;, &#x27;m&#x27;, &#x27;c&#x27;, &#x27;d&#x27;); // Timecode tag&#xA;  timecodeStream->time_base = (AVRational){1, 30}; // FPS: 30&#xA;&#xA;  if (av_dict_set(&amp;timecodeStream->metadata, "timecode", "00:00:30:00", 0) &lt; 0) {&#xA;    std::cerr &lt;&lt; "Failed to set timecode metadata!" &lt;&lt; std::endl;&#xA;    avcodec_free_context(&amp;videoCodecContext);&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  // Write container header&#xA;  if (avformat_write_header(formatContext, nullptr) &lt; 0) {&#xA;    std::cerr &lt;&lt; "Failed to write file header!" &lt;&lt; std::endl;&#xA;    avcodec_free_context(&amp;videoCodecContext);&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  // Encode a dummy video frame&#xA;  AVFrame* frame = av_frame_alloc();&#xA;  if (!frame) {&#xA;    std::cerr &lt;&lt; "Failed to allocate video frame!" &lt;&lt; std::endl;&#xA;    avcodec_free_context(&amp;videoCodecContext);&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  frame->format = videoCodecContext->pix_fmt;&#xA;  frame->width = videoCodecContext->width;&#xA;  frame->height = videoCodecContext->height;&#xA;&#xA;  if (av_image_alloc(frame->data, frame->linesize, frame->width, frame->height, videoCodecContext->pix_fmt, 32) &lt; 0) {&#xA;    std::cerr &lt;&lt; "Failed to allocate frame buffer!" &lt;&lt; std::endl;&#xA;    av_frame_free(&amp;frame);&#xA;    avcodec_free_context(&amp;videoCodecContext);&#xA;    avio_close(formatContext->pb);&#xA;    avformat_free_context(formatContext);&#xA;    return -1;&#xA;  }&#xA;&#xA;  // Fill frame with black&#xA;  memset(frame->data[0], 0, frame->linesize[0] * frame->height); // Y plane&#xA;  memset(frame->data[1], 128, frame->linesize[1] * frame->height / 2); // U plane&#xA;  memset(frame->data[2], 128, frame->linesize[2] * frame->height / 2); // V plane&#xA;&#xA;  // Encode the frame&#xA;  AVPacket packet;&#xA;  av_init_packet(&amp;packet);&#xA;  packet.data = nullptr;&#xA;  packet.size = 0;&#xA;&#xA;  if (avcodec_send_frame(videoCodecContext, frame) == 0) {&#xA;    if (avcodec_receive_packet(videoCodecContext, &amp;packet) == 0) {&#xA;      packet.stream_index = videoStream->index;&#xA;      av_interleaved_write_frame(formatContext, &amp;packet);&#xA;      av_packet_unref(&amp;packet);&#xA;    }&#xA;  }&#xA;&#xA;  av_frame_free(&amp;frame);&#xA;&#xA;  // Write a dummy packet for the timecode stream&#xA;  AVPacket tmcdPacket;&#xA;  av_init_packet(&amp;tmcdPacket);&#xA;  tmcdPacket.stream_index = timecodeStream->index;&#xA;  tmcdPacket.flags |= AV_PKT_FLAG_KEY;&#xA;  tmcdPacket.data = nullptr; // Empty packet for timecode&#xA;  tmcdPacket.size = 0;&#xA;  tmcdPacket.pts = 0; // Set necessary PTS&#xA;  tmcdPacket.dts = 0;&#xA;  av_interleaved_write_frame(formatContext, &amp;tmcdPacket);&#xA;&#xA;  // Write trailer&#xA;  if (av_write_trailer(formatContext) &lt; 0) {&#xA;    std::cerr &lt;&lt; "Failed to write file trailer!" &lt;&lt; std::endl;&#xA;  }&#xA;&#xA;  av_dump_format(formatContext, 0, "test.mov", 1);&#xA;&#xA;  // Cleanup&#xA;  avcodec_free_context(&amp;videoCodecContext);&#xA;  avio_close(formatContext->pb);&#xA;  avformat_free_context(formatContext);&#xA;&#xA;  std::cout &lt;&lt; "Test file with timecode created successfully: " &lt;&lt; outputFileName &lt;&lt; std::endl;&#xA;&#xA;  return 0;&#xA;}&#xA;</iostream>

    &#xA;

    The code output is :

    &#xA;

    Creating test file with tmcd stream: test_tmcd.mov&#xA;[prores_ks @ 0x11ce05790] Autoselected HQ profile to keep best quality. It can be overridden through -profile option.&#xA;[mov @ 0x11ce04f20] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly&#xA;[mov @ 0x11ce04f20] Encoder did not produce proper pts, making some up.&#xA;Output #0, mov, to &#x27;test.mov&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf61.7.100&#xA;  Stream #0:0: Video: prores (HQ) (apch / 0x68637061), yuv422p10le, 1920x1080, q=2-31, 2000 kb/s, 15360 tbn&#xA;  Stream #0:1: Data: timed_id3 (tmcd / 0x64636D74)&#xA;      Metadata:&#xA;        timecode        : 00:00:30:00&#xA;Test file with timecode created successfully: test_tmcd.mov&#xA;

    &#xA;

    The ffprobe output is :

    &#xA;

    $ ffprobe  test_tmcd.mov&#xA;ffprobe version 7.1.1 Copyright (c) 2007-2025 the FFmpeg developers&#xA;  built with Apple clang version 16.0.0 (clang-1600.0.26.6)&#xA;  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/7.1.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags=&#x27;-Wl,-ld_classic&#x27; --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon&#xA;  libavutil      59. 39.100 / 59. 39.100&#xA;  libavcodec     61. 19.101 / 61. 19.101&#xA;  libavformat    61.  7.100 / 61.  7.100&#xA;  libavdevice    61.  3.100 / 61.  3.100&#xA;  libavfilter    10.  4.100 / 10.  4.100&#xA;  libswscale      8.  3.100 /  8.  3.100&#xA;  libswresample   5.  3.100 /  5.  3.100&#xA;  libpostproc    58.  3.100 / 58.  3.100&#xA;Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;test_tmcd.mov&#x27;:&#xA;  Metadata:&#xA;    major_brand     : qt  &#xA;    minor_version   : 512&#xA;    compatible_brands: qt  &#xA;    encoder         : Lavf61.7.100&#xA;  Duration: N/A, start: 0.000000, bitrate: N/A&#xA;  Stream #0:0[0x1]: Video: prores (HQ) (apch / 0x68637061), yuv422p10le, 1920x1080, 15360 tbn (default)&#xA;      Metadata:&#xA;        handler_name    : VideoHandler&#xA;        vendor_id       : FFMP&#xA;$ &#xA;&#xA;

    &#xA;

    Spent hours with all AI models, no help. Appeal to the human intelligence now

    &#xA;

  • How to fix av_interleaved_write_frame() broken pipe error in php

    31 mars, par Adekunle Adeyeye

    I have an issue using ffmpeg to stream audio and parse to google cloud speech to text in PHP.

    &#xA;

    It returns this output.&#xA;I have tried delaying some part of the script, that did not solve it.&#xA;I have also checked for similar questions. however, they are mostly in python and none of the solutions actually work for this.

    &#xA;

      built with gcc 8 (GCC)&#xA;  cpudetect&#xA;  libavutil      56. 31.100 / 56. 31.100&#xA;  libavcodec     58. 54.100 / 58. 54.100&#xA;  libavformat    58. 29.100 / 58. 29.100&#xA;  libavdevice    58.  8.100 / 58.  8.100&#xA;  libavfilter     7. 57.100 /  7. 57.100&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  5.100 /  5.  5.100&#xA;  libswresample   3.  5.100 /  3.  5.100&#xA;  libpostproc    55.  5.100 / 55.  5.100&#xA;Input #0, mp3, from &#x27;https://npr-ice.streamguys1.com/live.mp3&#x27;:&#xA;  Metadata:&#xA;    icy-br          : 96&#xA;    icy-description : NPR Program Stream&#xA;    icy-genre       : News and Talk&#xA;    icy-name        : NPR Program Stream&#xA;    icy-pub         : 0&#xA;    StreamTitle     :&#xA;  Duration: N/A, start: 0.000000, bitrate: 96 kb/s&#xA;    Stream #0:0: Audio: mp3, 32000 Hz, stereo, fltp, 96 kb/s&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16le (native))&#xA;Press [q] to stop, [?] for help&#xA;Output #0, s16le, to &#x27;pipe:&#x27;:&#xA;  Metadata:&#xA;    icy-br          : 96&#xA;    icy-description : NPR Program Stream&#xA;    icy-genre       : News and Talk&#xA;    icy-name        : NPR Program Stream&#xA;    icy-pub         : 0&#xA;    StreamTitle     :&#xA;    encoder         : Lavf58.29.100&#xA;    Stream #0:0: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s&#xA;    Metadata:&#xA;      encoder         : Lavc58.54.100 pcm_s16le&#xA;**av_interleaved_write_frame(): Broken pipe** 256.0kbits/s speed=1.02x&#xA;**Error writing trailer of pipe:: Broken pipe**&#xA;size=      54kB time=00:00:01.76 bitrate= 250.8kbits/s speed=0.465x&#xA;video:0kB audio:55kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown&#xA;Conversion failed!&#xA;

    &#xA;

    this is my PHP code

    &#xA;

    require_once &#x27;vendor/autoload.php&#x27;;&#xA;    &#xA;    $projectId = "xxx-45512";&#xA;    putenv(&#x27;GOOGLE_APPLICATION_CREDENTIALS=&#x27; . __DIR__ . &#x27;/xxx-45512-be3eb805f1d7.json&#x27;);&#xA;    &#xA;    // Database connection&#xA;    $pdo = new PDO(&#x27;mysql:host=localhost;dbname=&#x27;, &#x27;&#x27;, &#x27;&#x27;);&#xA;    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);&#xA;    &#xA;    $url = "https://npr-ice.streamguys1.com/live.mp3";&#xA;    &#xA;    $ffmpegCmd = "ffmpeg -re -i $url -acodec pcm_s16le -ac 1 -ar 16000 -f s16le -";&#xA;    &#xA;    $fp = popen($ffmpegCmd, "r");&#xA;    if (!$fp) {&#xA;        die("Failed to open FFmpeg stream.");&#xA;    }&#xA;    sleep(5);&#xA;&#xA;    try {&#xA;        $client = new SpeechClient([&#x27;transport&#x27; => &#x27;grpc&#x27;, &#x27;credentials&#x27; => json_decode(file_get_contents(getenv(&#x27;GOOGLE_APPLICATION_CREDENTIALS&#x27;)), true)]);&#xA;    } catch (Exception $e) {&#xA;        echo &#x27;Error: &#x27; . $e->getMessage(); &#xA;        exit;&#xA;    }&#xA;    &#xA;    $recognitionConfig = new RecognitionConfig([&#xA;        &#x27;auto_decoding_config&#x27; => new AutoDetectDecodingConfig(),&#xA;        &#x27;language_codes&#x27; => [&#x27;en-US&#x27;],&#xA;        &#x27;model&#x27; => &#x27;long&#x27;,&#xA;    ]);&#xA;    &#xA;    $streamingConfig = new StreamingRecognitionConfig([&#xA;        &#x27;config&#x27; => $recognitionConfig,&#xA;    ]);&#xA;    &#xA;    $configRequest = new StreamingRecognizeRequest([&#xA;        &#x27;recognizer&#x27; => "projects/$projectId/locations/global/recognizers/_",&#xA;        &#x27;streaming_config&#x27; => $streamingConfig,&#xA;    ]);&#xA;    &#xA;    &#xA;    function streamAudio($fp)&#xA;    {&#xA;        while (!feof($fp)) {&#xA;            yield fread($fp, 4096);&#xA;        }&#xA;    }&#xA;    &#xA;    $responses = $client->streamingRecognize([&#xA;    &#x27;requests&#x27; => (function () use ($configRequest, $fp) {&#xA;            yield $configRequest; // Send initial config&#xA;            foreach (streamAudio($fp) as $audioChunk) {&#xA;                yield new StreamingRecognizeRequest([&#x27;audio&#x27; => $audioChunk]);&#xA;            }&#xA;        })()]&#xA;    );&#xA;    &#xA;    // $responses = $speechClient->streamingRecognize();&#xA;    // $responses->writeAll([$request,]);&#xA;    &#xA;    foreach ($responses as $response) {&#xA;        foreach ($response->getResults() as $result) {&#xA;            $transcript = $result->getAlternatives()[0]->getTranscript();&#xA;            // echo "Transcript: $transcript\n";&#xA;    &#xA;            // Insert into the database&#xA;            $stmt = $pdo->prepare("INSERT INTO transcriptions (transcript) VALUES (:transcript)");&#xA;            $stmt->execute([&#x27;transcript&#x27; => $transcript]);&#xA;        }&#xA;    }&#xA;    &#xA;    &#xA;    pclose($fp);&#xA;    $client->close();&#xA;

    &#xA;

    I'm not sure what the issue is at this time.

    &#xA;

    UPDATE

    &#xA;

    I've done some more debugging and i have gotten the error to clear and to stream actually starts.&#xA;However, I expect the audio to transcribe and update my database but instead I get this error when i close the stream

    &#xA;

    error after closing stream

    &#xA;

    this is my updated code

    &#xA;

        $handle = popen($ffmpegCommand, "r");&#xA;&#xA;    try {&#xA;        $client = new SpeechClient([&#x27;transport&#x27; => &#x27;grpc&#x27;, &#x27;credentials&#x27; => json_decode(file_get_contents(getenv(&#x27;GOOGLE_APPLICATION_CREDENTIALS&#x27;)), true)]);&#xA;    } catch (Exception $e) {&#xA;        echo &#x27;Error: &#x27; . $e->getMessage(); &#xA;        exit;&#xA;    }&#xA;    &#xA;    try {&#xA;    $recognitionConfig = (new RecognitionConfig())&#xA;        ->setAutoDecodingConfig(new AutoDetectDecodingConfig())&#xA;        ->setLanguageCodes([&#x27;en-US&#x27;], [&#x27;en-UK&#x27;])&#xA;        ->setModel(&#x27;long&#x27;);&#xA;    } catch (Exception $e) {&#xA;        echo &#x27;Error: &#x27; . $e->getMessage(); &#xA;        exit;&#xA;    }&#xA;    &#xA;    try {&#xA;        $streamConfig = (new StreamingRecognitionConfig())&#xA;        ->setConfig($recognitionConfig);&#xA;    } catch (Exception $e) {&#xA;        echo &#x27;Error: &#x27; . $e->getMessage();&#xA;        exit;&#xA;    }&#xA;    try {&#xA;        $configRequest = (new StreamingRecognizeRequest())&#xA;        ->setRecognizer("projects/$projectId/locations/global/recognizers/_")&#xA;        ->setStreamingConfig($streamConfig);&#xA;    } catch (Exception $e) {&#xA;        echo &#x27;Error: &#x27; . $e->getMessage(); &#xA;        exit;&#xA;    }&#xA;    &#xA;    $stream = $client->streamingRecognize();&#xA;    $stream->write($configRequest);&#xA;    &#xA;    mysqli_query($conn, "INSERT INTO transcriptions (transcript) VALUES (&#x27;bef&#x27;)");&#xA;    &#xA;    while (!feof($handle)) {&#xA;        $chunk = fread($handle, 25600);&#xA;        // printf(&#x27;chunk: &#x27; . $chunk);&#xA;        if ($chunk !== false) {&#xA;            try {&#xA;                $request = (new StreamingRecognizeRequest())&#xA;                        ->setAudio($chunk);&#xA;                    $stream->write($request);&#xA;            } catch (Exception $e) {&#xA;                printf(&#x27;Errorc: &#x27; . $e->getMessage());&#xA;            }&#xA;        }&#xA;    }&#xA;    &#xA;    &#xA;    $insr = json_encode($stream);&#xA;    mysqli_query($conn, "INSERT INTO transcriptions (transcript) VALUES (&#x27;$insr&#x27;)");&#xA;    &#xA;    foreach ($stream->read() as $response) {&#xA;        mysqli_query($conn, "INSERT INTO transcriptions (transcript) VALUES (&#x27;loop1&#x27;)");&#xA;        foreach ($response->getResults() as $result) {&#xA;            mysqli_query($conn, "INSERT INTO transcriptions (transcript) VALUES (&#x27;loop2&#x27;)");&#xA;            foreach ($result->getAlternatives() as $alternative) {&#xA;                $trans = $alternative->getTranscript();&#xA;                mysqli_query($conn, "INSERT INTO transcriptions (transcript) VALUES (&#x27;$trans&#x27;)");&#xA;            }&#xA;        }&#xA;    }&#xA;    &#xA;    pclose($handle);&#xA;    $stream->close();&#xA;    $client->close();```&#xA;

    &#xA;