Recherche avancée

Médias (1)

Mot : - Tags -/musée

Autres articles (44)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

  • Contribute to translation

    13 avril 2011

    You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
    To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
    MediaSPIP is currently available in French and English (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

Sur d’autres sites (3686)

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

  • Can't write packet with unknown timestamp av_interleaved_write_frame() : Invalid argument

    28 mai 2024, par jagvetinte

    I'm trying to convert a .ts file with this output to mkv :

    &#xA;

    ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers&#xA;  built with Apple clang version 12.0.0 (clang-1200.0.32.27)&#xA;  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_4 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --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-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack&#xA;  libavutil      56. 51.100 / 56. 51.100&#xA;  libavcodec     58. 91.100 / 58. 91.100&#xA;  libavformat    58. 45.100 / 58. 45.100&#xA;  libavdevice    58. 10.100 / 58. 10.100&#xA;  libavfilter     7. 85.100 /  7. 85.100&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  7.100 /  5.  7.100&#xA;  libswresample   3.  7.100 /  3.  7.100&#xA;  libpostproc    55.  7.100 / 55.  7.100&#xA;[mp3float @ 0x7fbd6282b200] Header missing&#xA;[mpegts @ 0x7fbd62809000] PES packet size mismatch&#xA;[mpegts @ 0x7fbd62809000] Packet corrupt (stream = 2, dts = 7125804577).&#xA;[mpegts @ 0x7fbd62809000] PES packet size mismatch&#xA;[mpegts @ 0x7fbd62809000] Packet corrupt (stream = 2, dts = 7125804577).&#xA;[mpegts @ 0x7fbd62809000] PES packet size mismatch&#xA;[mpegts @ 0x7fbd62809000] Packet corrupt (stream = 1, dts = 7125790091).&#xA;Input #0, mpegts, from &#x27;/Users/"User"/Downloads/input.ts&#x27;:&#xA;  Duration: 02:11:32.82, start: 71283.837456, bitrate: 17149 kb/s&#xA;  Program 1 &#xA;    Stream #0:0[0x1004]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuvj420p(pc, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 2.08 tbr, 90k tbn, 100 tbc&#xA;    Stream #0:1[0x1104](swe): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 256 kb/s&#xA;    Stream #0:2[0x704](swe): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 640 kb/s&#xA;

    &#xA;

    To do that I'm using this command :

    &#xA;

    ffmpeg -i input.ts -c copy output.mkv&#xA;

    &#xA;

    But the conversion fails with this error :

    &#xA;

    Stream mapping:&#xA;  Stream #0:0 -> #0:0 (copy)&#xA;  Stream #0:2 -> #0:1 (copy)&#xA;Press [q] to stop, [?] for help&#xA;[matroska @ 0x7fb8c1808200] 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;[matroska @ 0x7fb8c1808200] Can&#x27;t write packet with unknown timestamp&#xA;av_interleaved_write_frame(): Invalid argument&#xA;[matroska @ 0x7fb8c1808200] Can&#x27;t write packet with unknown timestamp&#xA;Error writing trailer of output.mkv: Invalid argument&#xA;frame=   27 fps=0.0 q=-1.0 Lsize=      74kB time=00:00:00.85 bitrate= 705.5kbits/s speed=  99x    &#xA;video:1092kB audio:35kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown&#xA;Conversion failed!&#xA;

    &#xA;

    What should I do in order to fix this ? I've already tried to add -fflags &#x2B;genpts in the beginning but it fails anyway.

    &#xA;

    EDIT : I did solve it by using MKVToolNix instead.

    &#xA;

  • FFMPEG keeping quality when reducing FPS and streaming over RTSP with rtsp-simple-server

    25 janvier 2021, par Jens Schneider

    I'm using the rtsp-simple-server (https://github.com/aler9/rtsp-simple-server) and feed the RTSP Server with a FFMPEG stream.

    &#xA;

    I use a docker compose file to start the stream :

    &#xA;

    version: "3.8"&#xA;&#xA;services:&#xA;&#xA;  ffmpeg:&#xA;    container_name: ffmpeg-base&#xA;    restart: always&#xA;    image: "jenssgb/rtspffmpeg:base"&#xA;    depends_on:&#xA;      - rtsp-server&#xA;    volumes:&#xA;      - $PWD/:/video&#xA;    network_mode: "host"&#xA;    command: "ffmpeg -re -stream_loop -1 -i /video/footage-1-b.mp4 -c copy -f rtsp rtsp://localhost:8554/compose-rtsp"&#xA;  &#xA;  rtsp-server:&#xA;    container_name: rtsp-server-base&#xA;    restart: always&#xA;    image: "aler9/rtsp-simple-server"&#xA;    network_mode: "host"&#xA;

    &#xA;

    Now I'm trying to reduce the FPS of my video with transcoding it :

    &#xA;

    command: -re -stream_loop -1 -i ${VIDEO_FILE} -vf "fps=${FPS_COMPOSE}" -f rtsp rtsp://localhost:8554/compose-rtsp&#xA;

    &#xA;

    This is basically working, but the quality of the output video becomes pretty bad. I tried a lot of things like -c:v libx264 which did help for a minute but let ffmpeg crash then.

    &#xA;

    av_interleaved_write_frame(): Broken pipe0:00:09.99 bitrate=N/A speed=0.985x    &#xA;[rtsp @ 0x5563b1755640] Packets poorly interleaved, failed to avoid negative timestamp -33660 in stream 0.&#xA;Try -max_interleave_delta 0 as a possible workaround.&#xA;av_interleaved_write_frame(): Broken pipe&#xA;Error writing trailer of rtsp://localhost:8554/compose-rtsp: Broken pipe&#xA;

    &#xA;

    Any idea how I can reduce the FPS send the stream to the server but keep the video quality ? Later I'm going to reduce the resolution as well - but for now I want to keep resolution and quality but only reduce the FPS.

    &#xA;

    Full logs from my test with -c:v libx264 :

    &#xA;

        ffmpeg -re -stream_loop -1 -i footage-1-b.mp4 -vf "fps=5" -c:v libx264 -f rtsp rtsp://localhost:8554/compose-rtsp&#xA;ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers&#xA;  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)&#xA;  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --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-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared&#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, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;footage-1-b.mp4&#x27;:&#xA;  Metadata:&#xA;    major_brand     : isom&#xA;    minor_version   : 512&#xA;    compatible_brands: isomiso2avc1mp41&#xA;    title           : Session streamed by "nessyMediaServer"&#xA;    encoder         : Lavf58.29.100&#xA;    comment         : h264_3&#xA;  Duration: 00:59:59.63, start: 0.000000, bitrate: 2099 kb/s&#xA;    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], 2061 kb/s, 24.96 fps, 25 tbr, 12800 tbn, 25 tbc (default)&#xA;    Metadata:&#xA;      handler_name    : VideoHandler&#xA;    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 35 kb/s (default)&#xA;    Metadata:&#xA;      handler_name    : SoundHandler&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))&#xA;  Stream #0:1 -> #0:1 (aac (native) -> aac (native))&#xA;Press [q] to stop, [?] for help&#xA;[aac @ 0x56277bc7f840] Too many bits 8832.000000 > 6144 per frame requested, clamping to max&#xA;[libx264 @ 0x56277bbc33c0] using SAR=1/1&#xA;[libx264 @ 0x56277bbc33c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2&#xA;[libx264 @ 0x56277bbc33c0] profile High, level 3.1&#xA;[libx264 @ 0x56277bbc33c0] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=5 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00&#xA;Output #0, rtsp, to &#x27;rtsp://localhost:8554/compose-rtsp&#x27;:&#xA;  Metadata:&#xA;    major_brand     : isom&#xA;    minor_version   : 512&#xA;    compatible_brands: isomiso2avc1mp41&#xA;    title           : Session streamed by "nessyMediaServer"&#xA;    comment         : h264_3&#xA;    encoder         : Lavf58.29.100&#xA;    Stream #0:0(und): Video: h264 (libx264), yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 5 fps, 90k tbn, 5 tbc (default)&#xA;    Metadata:&#xA;      handler_name    : VideoHandler&#xA;      encoder         : Lavc58.54.100 libx264&#xA;    Side data:&#xA;      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1&#xA;    Stream #0:1(und): Audio: aac (LC), 8000 Hz, mono, fltp, 48 kb/s (default)&#xA;    Metadata:&#xA;      handler_name    : SoundHandler&#xA;      encoder         : Lavc58.54.100 aac&#xA;av_interleaved_write_frame(): Broken pipe0:00:09.87 bitrate=N/A speed=0.978x    &#xA;[rtsp @ 0x56277bba0640] Packets poorly interleaved, failed to avoid negative timestamp -33660 in stream 0.&#xA;Try -max_interleave_delta 0 as a possible workaround.&#xA;av_interleaved_write_frame(): Broken pipe&#xA;Error writing trailer of rtsp://localhost:8554/compose-rtsp: Broken pipe&#xA;frame=   50 fps=4.6 q=23.0 Lsize=N/A time=00:00:10.21 bitrate=N/A speed=0.947x    &#xA;video:162kB audio:8kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown&#xA;[libx264 @ 0x56277bbc33c0] frame I:1     Avg QP:19.85  size:165667&#xA;[libx264 @ 0x56277bbc33c0] frame P:13    Avg QP:20.88  size:140481&#xA;[libx264 @ 0x56277bbc33c0] frame B:36    Avg QP:24.58  size: 55445&#xA;[libx264 @ 0x56277bbc33c0] consecutive B-frames:  4.0%  0.0%  0.0% 96.0%&#xA;[libx264 @ 0x56277bbc33c0] mb I  I16..4:  4.4% 30.8% 64.8%&#xA;[libx264 @ 0x56277bbc33c0] mb P  I16..4:  4.1% 10.6% 20.0%  P16..4: 24.4% 24.8% 13.3%  0.0%  0.0%    skip: 2.6%&#xA;[libx264 @ 0x56277bbc33c0] mb B  I16..4:  0.8%  2.0%  4.0%  B16..8: 40.3% 14.5%  5.2%  direct:11.8%  skip:21.4%  L0:77.1% L1: 7.9% BI:14.9%&#xA;[libx264 @ 0x56277bbc33c0] 8x8 transform intra:30.1% inter:11.9%&#xA;[libx264 @ 0x56277bbc33c0] coded y,uvDC,uvAC intra: 82.5% 60.9% 26.6% inter: 55.0% 42.4% 2.7%&#xA;[libx264 @ 0x56277bbc33c0] i16 v,h,dc,p: 17% 26% 34% 23%&#xA;[libx264 @ 0x56277bbc33c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 33% 15%  3%  4%  5%  4%  3%  9%&#xA;[libx264 @ 0x56277bbc33c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 22% 13%  3% 17% 11%  5%  3%  6%&#xA;[libx264 @ 0x56277bbc33c0] i8c dc,h,v,p: 54% 25% 16%  5%&#xA;[libx264 @ 0x56277bbc33c0] Weighted P-Frames: Y:7.7% UV:7.7%&#xA;[libx264 @ 0x56277bbc33c0] ref P L0: 33.2% 11.6% 29.0% 23.9%  2.4%&#xA;[libx264 @ 0x56277bbc33c0] ref B L0: 79.6% 11.9%  8.5%&#xA;[libx264 @ 0x56277bbc33c0] ref B L1: 95.9%  4.1%&#xA;[libx264 @ 0x56277bbc33c0] kb/s:3190.34&#xA;[aac @ 0x56277bc7f840] Qavg: 65536.000&#xA;Conversion failed!&#xA;

    &#xA;

    Thank you,&#xA;J

    &#xA;