Recherche avancée

Médias (1)

Mot : - Tags -/karaoke

Autres articles (53)

  • Other interesting software

    13 avril 2011, par

    We don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
    The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
    We don’t know them, we didn’t try them, but you can take a peek.
    Videopress
    Website : http://videopress.com/
    License : GNU/GPL v2
    Source code : (...)

  • Déploiements possibles

    31 janvier 2010, par

    Deux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
    L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
    Version mono serveur
    La version mono serveur consiste à n’utiliser qu’une (...)

  • Configuration spécifique d’Apache

    4 février 2011, par

    Modules spécifiques
    Pour la configuration d’Apache, il est conseillé d’activer certains modules non spécifiques à MediaSPIP, mais permettant d’améliorer les performances : mod_deflate et mod_headers pour compresser automatiquement via Apache les pages. Cf ce tutoriel ; mode_expires pour gérer correctement l’expiration des hits. Cf ce tutoriel ;
    Il est également conseillé d’ajouter la prise en charge par apache du mime-type pour les fichiers WebM comme indiqué dans ce tutoriel.
    Création d’un (...)

Sur d’autres sites (8230)

  • How to modify the bit_rate of AVFormatContext ?

    27 mars 2023, par Zion Liu

    Hello,I would like to know how to modify the bit_rate of AVFormatContext.

    


    Here is the minimal reproducible example.This is a simple process for pushing rtmp video streams.Now I want to control the bitrate of the video it pushes.

    


    I tried modifying the bitrate like this, but it didn't work.

    


    AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
int64_t bit_rate = 400*1000;
....
ofmt_ctx->bit_rate = bit_rate;


    


    Can be compiled by g++ -Wall -o -g -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include -L/usr/local/lib  simplt_push_streaming.cpp -o test.out -lavformat -lavcodec -lavutil -lgobject-2.0 -lglib-2.0 -lpthread

    


    And my ffmpeg version : ffmpeg version 4.4.2-0ubuntu0.22.04.1

    


    #include &#xA;extern "C"&#xA;{&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>mathematics.h>&#xA;#include <libavutil></libavutil>time.h>&#xA;};&#xA;&#xA;int main(int argc, char* argv[])&#xA;{&#xA;    AVOutputFormat *ofmt = NULL;&#xA;    //Input AVFormatContext and Output AVFormatContext&#xA;    AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;&#xA;    AVPacket pkt;&#xA;    const char *in_filename, *out_filename;&#xA;    int ret, i;&#xA;    int videoindex=-1;&#xA;    int frame_index=0;&#xA;    int64_t start_time=0;&#xA;    int64_t bit_rate = 400*1000;&#xA;    in_filename  = "/home/zion/video/mecha.flv";// Input file URL&#xA;    out_filename = "rtmp://localhost:1935/live/test";//Output URL [RTMP]&#xA;    av_register_all();&#xA;    avformat_network_init();&#xA;    avformat_open_input(&amp;ifmt_ctx, in_filename, 0, 0);&#xA;    avformat_find_stream_info(ifmt_ctx, 0);&#xA;    for(i=0; inb_streams; i&#x2B;&#x2B;) &#xA;        if(ifmt_ctx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO){&#xA;            videoindex=i;&#xA;            break;&#xA;        }&#xA;    //Output&#xA;    avformat_alloc_output_context2(&amp;ofmt_ctx, NULL, "flv", out_filename); //RTMP&#xA;    ofmt = ofmt_ctx->oformat;&#xA;    for (i = 0; i &lt; ifmt_ctx->nb_streams; i&#x2B;&#x2B;) {&#xA;        //Create output AVStream according to input AVStream&#xA;        AVStream *in_stream = ifmt_ctx->streams[i];&#xA;        AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);&#xA;        //Copy the settings of AVCodecContext&#xA;        ret = avcodec_copy_context(out_stream->codec, in_stream->codec);&#xA;        out_stream->codec->codec_tag = 0;&#xA;        if (ofmt_ctx->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;            out_stream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;    }&#xA;    //Open output URL&#xA;    if (!(ofmt->flags &amp; AVFMT_NOFILE)) {&#xA;        ret = avio_open(&amp;ofmt_ctx->pb, out_filename, AVIO_FLAG_WRITE);&#xA;    }&#xA;    //Write file header&#xA;    avformat_write_header(ofmt_ctx, NULL);&#xA;    start_time=av_gettime();&#xA;    while (1) {&#xA;        AVStream *in_stream, *out_stream;&#xA;        //Get an AVPacket&#xA;        ret = av_read_frame(ifmt_ctx, &amp;pkt);&#xA;        if (ret &lt; 0)&#xA;            break;&#xA;        //Important:Delay&#xA;        if(pkt.stream_index==videoindex){&#xA;            AVRational time_base=ifmt_ctx->streams[videoindex]->time_base;&#xA;            AVRational time_base_q={1,AV_TIME_BASE};&#xA;            int64_t pts_time = av_rescale_q(pkt.dts, time_base, time_base_q);&#xA;            int64_t now_time = av_gettime() - start_time;&#xA;            if (pts_time > now_time)&#xA;                av_usleep(pts_time - now_time);&#xA;        }&#xA;        in_stream  = ifmt_ctx->streams[pkt.stream_index];&#xA;        out_stream = ofmt_ctx->streams[pkt.stream_index];&#xA;        if(pkt.stream_index==videoindex){&#xA;            printf("Send %8d video frames to output URL\n",frame_index);&#xA;            frame_index&#x2B;&#x2B;;&#xA;        }&#xA;/*I tried modifying the bitrate here and I&#x27;m not sure if this is the correct usage.*/&#xA;        ofmt_ctx->bit_rate = bit_rate;&#xA;        av_interleaved_write_frame(ofmt_ctx, &amp;pkt);&#xA;        av_free_packet(&amp;pkt);&#xA;    }&#xA;    //Write file trailer&#xA;    av_write_trailer(ofmt_ctx);&#xA;end:&#xA;    avformat_close_input(&amp;ifmt_ctx);&#xA;    /* close output */&#xA;    if (ofmt_ctx &amp;&amp; !(ofmt->flags &amp; AVFMT_NOFILE))&#xA;        avio_close(ofmt_ctx->pb);&#xA;    avformat_free_context(ofmt_ctx);&#xA;    return 0;&#xA;}&#xA;

    &#xA;

  • Puzzled with file descriptor in Bash (ffmpeg video capture)

    3 mai 2020, par ChrisAga

    I am trying to use file descriptors in Bash and found a problem I cannot solve.&#xA;I have to read a video stream coming from the standard output of a command executed in a coproc. This piece of code works as expected :

    &#xA;&#xA;

    ffmpeg \&#xA;    -i &lt;(exec cat &lt;&amp;${COPROC[0]}) \&#xA;    -c:v $ENCODE_VIDEO_FORMAT_LOSSLESS $ENCODE_VIDEO_OPTIONS_LOSSLESS \&#xA;    -c:a copy \&#xA;    -progress /dev/fd/1 \&#xA;    "${capfile}"&#xA;

    &#xA;&#xA;

    But the cat process is not really useful since ffmpeg -i pipe:<file descriptor="descriptor"></file> seems to do the same. So I tried the following code which fails with pipe:63: Bad file descriptor&#xA; error.

    &#xA;&#xA;

    ffmpeg \&#xA;    -i pipe:"${COPROC[0]}" \&#xA;    -c:v $ENCODE_VIDEO_FORMAT_LOSSLESS $ENCODE_VIDEO_OPTIONS_LOSSLESS \&#xA;    -c:a copy \&#xA;    -progress /dev/fd/1 \&#xA;    "${capfile}"&#xA;

    &#xA;&#xA;

    The actual script is something a bit complicated but here is a minimal testing code for this issue :

    &#xA;&#xA;

    #!/bin/bash&#xA;#&#xA;&#xA;ENCODE_VIDEO_FORMAT_LOSSLESS=ffv1&#xA;ENCODE_VIDEO_OPTIONS_LOSSLESS="-level 3 -threads 7 -coder 1 -context 1 -g 1 -slices 30 -slicecrc 1"&#xA;&#xA;capfile=capure.mkv&#xA;&#xA;coproc ffmpeg  -i file:&#x27;Camomille.mkv&#x27; -c:v copy -c:a copy -f matroska pipe:1&#xA;&#xA;capture_fd=${COPROC[0]}&#xA;echo "hk_capture_pid=${COPROC_PID}"&#xA;&#xA;ffmpeg \&#xA;    -i pipe:${COPROC[0]} \&#xA;    -c:v $ENCODE_VIDEO_FORMAT_LOSSLESS $ENCODE_VIDEO_OPTIONS_LOSSLESS \&#xA;    -c:a copy \&#xA;    -progress /dev/fd/1 \&#xA;    "${capfile}"&#xA;

    &#xA;&#xA;

    This is the output of the second ffmpeg command :

    &#xA;&#xA;

    ffmpeg version 4.1.4-1build2 Copyright (c) 2000-2019 the FFmpeg developers&#xA;  built with gcc 9 (Ubuntu 9.2.1-4ubuntu1)&#xA;  configuration: --prefix=/usr --extra-version=1build2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared&#xA;  libavutil      56. 22.100 / 56. 22.100&#xA;  libavcodec     58. 35.100 / 58. 35.100&#xA;  libavformat    58. 20.100 / 58. 20.100&#xA;  libavdevice    58.  5.100 / 58.  5.100&#xA;  libavfilter     7. 40.101 /  7. 40.101&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  3.100 /  5.  3.100&#xA;  libswresample   3.  3.100 /  3.  3.100&#xA;  libpostproc    55.  3.100 / 55.  3.100&#xA;pipe:63: Bad file descriptor&#xA;av_interleaved_write_frame(): Broken pipe                                                                                       &#xA;Error writing trailer of pipe:1: Broken pipe                                                                                    &#xA;frame=    4 fps=0.0 q=-1.0 Lsize=      48kB time=00:00:00.03 bitrate=10051.1kbits/s speed=3.44x    &#xA;video:86kB audio:1kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: unknown&#xA;Conversion failed!&#xA;

    &#xA;&#xA;

    This one fails and if you replace -i pipe:${COPROC[0]} by -i &lt;(exec cat &lt;&amp;${COPROC[0]}) a capture.mkv file is created.

    &#xA;&#xA;

    I run ubuntu eoan and bash version is : GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu). I upgraded several times since I started with this issue, so it wouldn't be related too much to bash and ffmpeg versions.

    &#xA;&#xA;

    If someone can point me to what I do wrong with bash file descriptors I would be grateful.

    &#xA;

  • fileapi::WriteFile() doesn't send an input, if processthreadsapi::STARTUPINFO::hStdError is set (ffmpeg)

    23 avril 2021, par Lidekys

    I'm trying to capture my screen using ffmpeg in a different thread (which I create using processthreadsapi::CreateProcess()) so I'd be able to do something else in the main thread, and redirect ffmpeg output, so it wouldn't pop up in the console for the user to see. To stop filming, I send a 'q' input using WriteFile(), and after that I want to save ffmpeg accumulated output using ReadFile().

    &#xA;

    However, if I set STARTUPINFO::hStdError (note, that ffmpeg output goes to stderr) to a pipe, from which I could read the accumulated data, the inputs I send using WriteFile() are no longer registered and ffmpeg.exe keeps running.

    &#xA;

    I've tried redirecting ffmpeg output in a simple command line, but I can still stop the process by pressing the q button.

    &#xA;

    Also, if I record for less than 8 seconds, the input is registered and ffmpeg.exe closes.

    &#xA;

    Is there something wrong with my code, or is it processthreadsapi issue, any hints will be kindly appreciared !

    &#xA;

    Here's a minimal code of how I am trying to do it :

    &#xA;

    &#xA;#include <iostream>&#xA;&#xA;#include &#xA;#include &#xA;&#xA;using namespace std;&#xA;&#xA;HANDLE g_hChildStd_IN_Rd = NULL;&#xA;HANDLE g_hChildStd_IN_Wr = NULL;&#xA;HANDLE g_hChildStd_OUT_Rd = NULL;&#xA;HANDLE g_hChildStd_OUT_Wr = NULL;&#xA;&#xA;int main()&#xA;{&#xA;    //Create IN and OUT pipes&#xA;    SECURITY_ATTRIBUTES saAttr;&#xA;    saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);&#xA;    saAttr.lpSecurityDescriptor = NULL;&#xA;&#xA;&#xA;    if (! CreatePipe(&amp;g_hChildStd_OUT_Rd, &amp;g_hChildStd_OUT_Wr, &amp;saAttr, 0) )&#xA;        cout&lt;&lt;"StdoutRd CreatePipe error"&lt;/Start recording&#xA;   if(!CreateProcess(NULL,&#xA;      "ffmpeg -y -f gdigrab -framerate 2 -i desktop record.avi",     // command line&#xA;      NULL,          // process security attributes&#xA;      NULL,          // primary thread security attributes&#xA;      TRUE,          // handles are inherited&#xA;      0,             // creation flags&#xA;      NULL,          // use parent&#x27;s environment&#xA;      NULL,          // use parent&#x27;s current directory&#xA;      &amp;siStartInfo,  // STARTUPINFO pointer&#xA;      &amp;piProcInfo))  // receives PROCESS_INFORMATION&#xA;   {&#xA;    cout&lt;&lt;"Error create process"&lt;/Record for a while&#xA;    while(getch() != &#x27;k&#x27;){&#xA;        cout&lt;&lt;"While press k"&lt;/Stop recording by emulating a Q button push&#xA;    DWORD dwWritten;&#xA;    CHAR chBufW[1] = {&#x27;q&#x27;};&#xA;&#xA;    if ( ! WriteFile(g_hChildStd_IN_Wr, chBufW, 1, &amp;dwWritten, NULL) )&#xA;        cout&lt;&lt;"Error write file"&lt;/Save stdError (ffmpeg) data&#xA;    DWORD dwRead;&#xA;    char stdErrorData[4096];&#xA;    bool bSuccess;&#xA;&#xA;    bSuccess = ReadFile( g_hChildStd_OUT_Wr, stdErrorData, 4096, &amp;dwRead, NULL);&#xA;&#xA;    if(!bSuccess || dwRead == 0)&#xA;        cout&lt;&lt;"Read failed"&lt;code></iostream>

    &#xA;