Recherche avancée

Médias (1)

Mot : - Tags -/illustrator

Autres articles (48)

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

  • 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

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

Sur d’autres sites (5694)

  • FFMPEG Inverts colors when converting tiff pictures to png

    1er juin 2021, par Mounia Jaiti

    We need to convert thousands of tiff pictures to png. To accomplish that we are using FFMPEG. We've noticed recently that for very few of the converted files (in png), the colors are inverted : the input tiff file is all black and white (a technical drawing in black with a white background), and the output png file is white and black (the drawing becomes white and the background becomes black). Of course we don't want that, we need the colors to stay the same.

    


    Here is the command we are using :

    


    ffmpeg -y -v warning -i in_file.tif out_file.png


    


    We've tested the 'negate' parameter on those files, and the pictures are correctly converted. But we can't apply this parameter to all of the input tiff files.
Here is the command with the negate parameter :

    


    ffmpeg -y -v verbose -i input.tif -vf negate output.png


    


    The Code Java we're using :

    


                String ffmpegPath="/Users/user11/ffmpeg//ffmpeg";&#xA;            List<string> commandArgs = new ArrayList<string>();&#xA;            commandArgs.add(ffmpegPath);&#xA;            //overwrite output file if it exists&#xA;            commandArgs.add("-y");      &#xA;            commandArgs.add("-v");&#xA;            commandArgs.add("verbose");&#xA;            //set input file &#xA;            commandArgs.add("-i"); &#xA;            commandArgs.add(picture.getAbsolutePath());&#xA;            commandArgs.add(dest.getAbsolutePath());&#xA;            &#xA;            String cmd = "";&#xA;            for(String cmdArg : commandArgs) {&#xA;                cmd &#x2B;= cmdArg &#x2B; " ";&#xA;            }&#xA;&#xA;&#xA;</string></string>

    &#xA;

    Logs for tif having the bug :

    &#xA;

    &#xA;31, 2021 2:15:51 PM &#xA;INFO: Executing : /Users/user11/ffmpeg/ffmpeg -y -v verbose -i /Users/user11/ffmpeg/input.tif /Users/user11/ffmpeg/output.png &#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: ffmpeg version 4.4-tessus  https://evermeet.cx/ffmpeg/  Copyright (c) 2000-2021 the FFmpeg developers&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   built with Apple clang version 11.0.0 (clang-1100.0.33.17)&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   libavutil      56. 70.100 / 56. 70.100&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   libavcodec     58.134.100 / 58.134.100&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   libavformat    58. 76.100 / 58. 76.100&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   libavdevice    58. 13.100 / 58. 13.100&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   libavfilter     7.110.100 /  7.110.100&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   libswscale      5.  9.100 /  5.  9.100&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   libswresample   3.  9.100 /  3.  9.100&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   libpostproc    55.  9.100 / 55.  9.100&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: [tiff_pipe @ 0x7fa7f6008200] parser not found for codec tiff, packets or times may be invalid.&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:     Last message repeated 1 times&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: Input #0, tiff_pipe, from &#x27;/Users/user11/ffmpeg/input.tif&#x27;:&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   Duration: N/A, bitrate: N/A&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   Stream #0:0: Video: tiff, 1 reference frame, monob, 2008x2481 [SAR 1:1 DAR 2008:2481], 25 fps, 25 tbr, 25 tbn, 25 tbc&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: Stream mapping:&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   Stream #0:0 -> #0:0 (tiff (native) -> png (native))&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: Press [q] to stop, [?] for help&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: [graph 0 input from stream 0:0 @ 0x7fa7f4c08300] w:2008 h:2481 pixfmt:monob tb:1/25 fr:25/1 sar:1/1&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: Output #0, image2, to &#x27;/Users/user11/ffmpeg/output.png&#x27;:&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   Metadata:&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:     encoder         : Lavf58.76.100&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   Stream #0:0: Video: png, 1 reference frame, monob(progressive), 2008x2481 (0x0) [SAR 1:1 DAR 2008:2481], q=2-31, 200 kb/s, 25 fps, 25 tbn&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:     Metadata:&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:       encoder         : Lavc58.134.100 png&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: frame=    1 fps=0.0 q=0.0 size=N/A time=00:00:00.00 bitrate=N/A speed=   0x    &#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: No more output streams to write to, finishing.&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: [AVIOContext @ 0x7fa7f4c14180] Statistics: 0 seeks, 1 writeouts&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=1.31x    &#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: video:37kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: Input file #0 (/Users/user11/ffmpeg/input.tif):&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   Input stream #0:0 (video): 1 packets read (18100 bytes); 1 frames decoded; &#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   Total: 1 packets (18100 bytes) demuxed&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: Output file #0 (/Users/user11/ffmpeg/output.png):&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (38013 bytes); &#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output:   Total: 1 packets (38013 bytes) muxed&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: ReencodePicture output: [AVIOContext @ 0x7fa7f4f041c0] Statistics: 18100 bytes read, 0 seeks&#xA;May 31, 2021 2:15:51 PM &#xA;INFO: BinaryRepositoryHelper.convertPixTo ffmpeg Process returned : java.lang.UNIXProcess@27ddd392, ended with code 0, and returned in 160 ms, out=/Users/user11/ffmpeg/output.png exists=true&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;

    &#xA;

    So our questions are :

    &#xA;

      &#xA;
    1. Is there a way to identify the tiff files that will be converted to png with inverted colors ? So that we can know to which files the 'negate' parameter must be applied.
    2. &#xA;

    3. Are there any other FFMPEG parameter that we can use.
    4. &#xA;

    &#xA;

    This issue has been driving us mad for the last couple of days. Any help would be highly appreciated.&#xA;Thanks.

    &#xA;

    Example of Tif picture

    &#xA;

    https://drive.google.com/file/d/1U1a91gTk1gaJb-XAPavNq6UhmjWXZjbM/view?usp=sharing

    &#xA;

  • ffmpeg converting .vob to .mp4 --- colors are washed out

    28 mai 2021, par Blattla

    I am very new to ffmpeg. Currently I am trying to convert old family movies from vob to mp4.&#xA;After getting some help I used this command :

    &#xA;

    ffmpeg -i 1998.vob -codec:v libx264 -crf 17 -pix_fmt yuv420p -codec:a aac -movflags &#x2B;faststart 1998.mp4&#xA;

    &#xA;

    Two things that still bug me. The output is almost 20% larger than the input and the colors are washed out. Although the movies are old and of low quality (grainy, rather flat colors, ...) the colors in the output movie are less intense than in the original one. Larger file size would be ok for me but do you have any idea which part of my command might cause the color issue ?

    &#xA;

    ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers&#xA;  built with Apple clang version 12.0.0 (clang-1200.0.32.29)&#xA;  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_1 --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-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox&#xA;  libavutil      56. 70.100 / 56. 70.100&#xA;  libavcodec     58.134.100 / 58.134.100&#xA;  libavformat    58. 76.100 / 58. 76.100&#xA;  libavdevice    58. 13.100 / 58. 13.100&#xA;  libavfilter     7.110.100 /  7.110.100&#xA;  libavresample   4.  0.  0 /  4.  0.  0&#xA;  libswscale      5.  9.100 /  5.  9.100&#xA;  libswresample   3.  9.100 /  3.  9.100&#xA;  libpostproc    55.  9.100 / 55.  9.100&#xA;Input #0, mpeg, from &#x27;1995.vob&#x27;:&#xA;  Duration: 00:00:14.64, start: 0.232178, bitrate: 1676252 kb/s&#xA;  Stream #0:0[0x1bf]: Data: dvd_nav_packet&#xA;  Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 704x576 [SAR 12:11 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc&#xA;    Side data:&#xA;      cpb: bitrate max/min/avg: 9548800/0/0 buffer size: 1835008 vbv_delay: N/A&#xA;  Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 256 kb/s&#xA;File &#x27;999.mp4&#x27; already exists. Overwrite? [y/N] y&#xA;Stream mapping:&#xA;  Stream #0:1 -> #0:0 (mpeg2video (native) -> h264 (libx264))&#xA;  Stream #0:2 -> #0:1 (ac3 (native) -> aac (native))&#xA;Press [q] to stop, [?] for help&#xA;[libx264 @ 0x7ff666814400] using SAR=12/11&#xA;[libx264 @ 0x7ff666814400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2&#xA;[libx264 @ 0x7ff666814400] profile High, level 3.0, 4:2:0, 8-bit&#xA;[libx264 @ 0x7ff666814400] 264 - core 161 r3049 55d517b - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - 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=6 lookahead_threads=1 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=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=17.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00&#xA;Output #0, mp4, to &#x27;999.mp4&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf58.76.100&#xA;  Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt470bg, top coded first (swapped)), 704x576 [SAR 12:11 DAR 4:3], q=2-31, 25 fps, 12800 tbn&#xA;    Metadata:&#xA;      encoder         : Lavc58.134.100 libx264&#xA;    Side data:&#xA;      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A&#xA;  Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s&#xA;    Metadata:&#xA;      encoder         : Lavc58.134.100 aac&#xA;frame=    1 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   frame=   59 fps=0.0 q=22.0 size=     256kB time=00:00:02.04 bitrate=1024.2kbits/frame=   75 fps= 72 q=22.0 size=    1024kB time=00:00:02.68 bitrate=3120.9kbits/frame=   95 fps= 61 q=22.0 size=    2048kB time=00:00:03.45 bitrate=4854.6kbits/frame=  112 fps= 54 q=22.0 size=    2816kB time=00:00:04.18 bitrate=5517.2kbits/frame=  131 fps= 51 q=22.0 size=    4096kB time=00:00:04.92 bitrate=6809.0kbits/frame=  149 fps= 48 q=22.0 size=    4864kB time=00:00:05.65 bitrate=7048.3kbits/frame=  169 fps= 47 q=22.0 size=    6144kB time=00:00:06.42 bitrate=7838.3kbits/frame=  183 fps= 44 q=22.0 size=    6912kB time=00:00:07.04 bitrate=8043.1kbits/frame=  203 fps= 43 q=22.0 size=    7936kB time=00:00:07.80 bitrate=8326.3kbits/frame=  221 fps= 42 q=22.0 size=    8960kB time=00:00:08.51 bitrate=8623.2kbits/frame=  240 fps= 42 q=22.0 size=    9984kB time=00:00:09.28 bitrate=8813.5kbits/frame=  261 fps= 41 q=22.0 size=   11264kB time=00:00:10.06 bitrate=9164.0kbits/frame=  278 fps= 40 q=22.0 size=   12288kB time=00:00:10.81 bitrate=9306.9kbits/frame=  294 fps= 40 q=22.0 size=   13568kB time=00:00:11.45 bitrate=9702.3kbits/frame=  311 fps= 39 q=22.0 size=   14592kB time=00:00:12.09 bitrate=9882.4kbits/frame=  329 fps= 39 q=22.0 size=   15616kB time=00:00:12.86 bitrate=9944.5kbits/frame=  347 fps= 39 q=22.0 size=   16640kB time=00:00:13.56 bitrate=10046.8kbitsframe=  366 fps= 38 q=22.0 size=   17920kB time=00:00:14.33 bitrate=10240.0kbitsframe=  385 fps= 38 q=22.0 size=   19200kB time=00:00:15.12 bitrate=10398.9kbitsframe=  400 fps= 38 q=22.0 size=   20224kB time=00:00:15.63 bitrate=10594.9kbitsframe=  418 fps= 38 q=22.0 size=   21504kB time=00:00:16.34 bitrate=10780.1kbitsframe=  431 fps= 37 q=22.0 size=   22528kB time=00:00:16.89 bitrate=10922.7kbitsframe=  447 fps= 37 q=22.0 size=   23808kB time=00:00:17.53 bitrate=11122.0kbitsframe=  466 fps= 37 q=22.0 size=   25088kB time=00:00:18.26 bitrate=11254.5kbitsframe=  479 fps= 36 q=22.0 size=   25856kB time=00:00:18.81 bitrate=11257.1kbitsframe=  497 fps= 36 q=22.0 size=   27136kB time=00:00:19.54 bitrate=11375.8kbitsframe=  513 fps= 36 q=22.0 size=   28416kB time=00:00:20.16 bitrate=11546.8kbitsframe=  530 fps= 36 q=22.0 size=   29440kB time=00:00:20.92 bitrate=11523.9kbitsframe=  546 fps= 36 q=22.0 size=   30464kB time=00:00:21.56 bitrate=11570.9kbitsframe=  564 fps= 36 q=22.0 size=   31744kB time=00:00:22.10 bitrate=11766.1kbitsframe=  580 fps= 36 q=19.0 size=   32512kB time=00:00:22.80 bitrate=11678.8kbitsframe=  598 fps= 36 q=22.0 size=   33792kB time=00:00:23.57 bitrate=11743.1kbitsframe=  614 fps= 35 q=22.0 size=   34560kB time=00:00:24.25 bitrate=11672.0kbitsframe=  630 fps= 35 q=22.0 size=   35328kB time=00:00:24.85 bitrate=11644.6kbitsframe=  646 fps= 35 q=22.0 size=   36096kB time=00:00:25.42 bitrate=11628.3kbitsframe=  662 fps= 35 q=22.0 size=   37376kB time=00:00:26.17 bitrate=11697.1kbitsframe=  682 fps= 35 q=22.0 size=   38400kB time=00:00:26.90 bitrate=11693.6kbitsframe=  699 fps= 35 q=22.0 size=   39424kB time=00:00:27.66 bitrate=11672.2kbitsframe=  719 fps= 35 q=22.0 size=   40704kB time=00:00:28.41 bitrate=11734.5kbitsframe=  736 fps= 35 q=22.0 size=   41728kB time=00:00:29.14 bitrate=11730.3kbitsframe=  753 fps= 35 q=22.0 size=   42752kB time=00:00:29.71 bitrate=11785.2kbitsframe=  764 fps= 35 q=22.0 size=   43520kB time=00:00:30.20 bitrate=11802.0kbitsframe=  776 fps= 35 q=22.0 size=   44544kB time=00:00:30.72 bitrate=11878.4kbitsframe=  786 fps= 34 q=22.0 size=   45312kB time=00:00:31.06 bitrate=11950.4kbitsframe=  799 fps= 34 q=22.0 size=   46080kB time=00:00:31.57 bitrate=11955.9kbitsframe=  815 fps= 34 q=22.0 size=   47104kB time=00:00:32.14 bitrate=12002.6kbitsframe=  830 fps= 34 q=22.0 size=   48128kB time=00:00:32.78 bitrate=12024.2kbitsframe=  839 fps= 33 q=22.0 size=   48640kB time=00:00:33.15 bitrate=12019.2kbitsframe=  847 fps= 33 q=22.0 size=   49152kB time=00:00:33.49 bitrate=12021.9kbitsframe=  858 fps= 33 q=22.0 size=   49920kB time=00:00:33.98 bitrate=12033.5kbitsframe=  867 fps= 32 q=22.0 size=   50688kB time=00:00:34.30 bitrate=12104.6kbitsframe=  880 fps= 32 q=22.0 size=   51456kB time=00:00:34.88 bitrate=12085.1kbitsframe=  898 fps= 32 q=22.0 size=   52480kB time=00:00:35.54 bitrate=12096.2kbitsframe=  913 fps= 32 q=22.0 size=   53504kB time=00:00:36.18 bitrate=12114.1kbitsframe=  923 fps= 32 q=22.0 size=   54016kB time=00:00:36.54 bitrate=12108.7kbitsframe=  940 fps= 32 q=22.0 size=   55040kB time=00:00:37.20 bitrate=12118.9kbitsframe=  958 fps= 32 q=22.0 size=   55808kB time=00:00:37.90 bitrate=12059.8kbitsframe=  975 fps= 32 q=22.0 size=   56832kB time=00:00:38.61 bitrate=12057.2kbitsframe=  994 fps= 32 q=22.0 size=   58112kB time=00:00:39.38 bitrate=12088.3kbitsframe= 1012 fps= 32 q=22.0 size=   59136kB time=00:00:40.02 bitrate=12104.6kbitsframe= 1026 fps= 32 q=22.0 size=   59904kB time=00:00:40.64 bitrate=12075.1kbitsframe= 1038 fps= 31 q=22.0 size=   60928kB time=00:00:41.21 bitrate=12109.9kbitsframe= 1046 fps= 31 q=22.0 size=   61440kB time=00:00:41.53 bitrate=12117.6kbitsframe= 1057 fps= 31 q=22.0 size=   61952kB time=00:00:41.87 bitrate=12119.0kbitsframe= 1071 fps= 31 q=22.0 size=   62976kB time=00:00:42.45 bitrate=12152.2kbitsframe= 1083 fps= 31 q=22.0 size=   63488kB time=00:00:42.90 bitrate=12123.0kbitsframe= 1096 fps= 31 q=22.0 size=   64256kB time=00:00:43.41 bitrate=12125.0kbitsframe= 1110 fps= 31 q=22.0 size=   65280kB time=00:00:44.09 bitrate=12127.5kbitsframe= 1126 fps= 31 q=22.0 size=   66048kB time=00:00:44.62 bitrate=12123.5kbitsframe= 1131 fps= 30 q=19.0 size=   66560kB time=00:00:44.86 bitrate=12153.6kbitsframe= 1147 fps= 30 q=22.0 size=   67584kB time=00:00:45.46 bitrate=12178.4kbitsframe= 1155 fps= 30 q=22.0 size=   68096kB time=00:00:45.88 bitrate=12156.6kbitsframe= 1167 fps= 30 q=22.0 size=   68864kB time=00:00:46.33 bitrate=12174.9kbitsframe= 1175 fps= 30 q=22.0 size=   69376kB time=00:00:46.59 bitrate=12198.0kbitsframe= 1184 fps= 30 q=22.0 size=   70144kB time=00:00:46.93 bitrate=12243.3kbitsframe= 1196 fps= 30 q=22.0 size=   70912kB time=00:00:47.44 bitrate=12243.8kbitsframe= 1211 fps= 30 q=22.0 size=   71936kB time=00:00:48.06 bitrate=12260.7kbitsframe= 1226 fps= 30 q=22.0 size=   73216kB time=00:00:48.66 bitrate=12325.7kbitsframe= 1240 fps= 29 q=22.0 size=   73984kB time=00:00:49.17 bitrate=12325.3kbitsframe= 1256 fps= 29 q=22.0 size=   75264kB time=00:00:49.85 bitrate=12366.9kbitsframe= 1271 fps= 29 q=22.0 size=   76032kB time=00:00:50.43 bitrate=12350.4kbitsframe= 1280 fps= 29 q=22.0 size=   76800kB time=00:00:50.81 bitrate=12380.9kbitsframe= 1288 fps= 29 q=22.0 size=   77312kB time=00:00:51.13 bitrate=12385.4kbitsframe= 1295 fps= 29 q=22.0 size=   77824kB time=00:00:51.39 bitrate=12405.3kbitsframe= 1303 fps= 29 q=22.0 size=   78080kB time=00:00:51.73 bitrate=12364.0kbitsframe= 1316 fps= 29 q=22.0 size=   78848kB time=00:00:52.28 bitrate=12353.2kbitsframe= 1331 fps= 29 q=22.0 size=   79872kB time=00:00:52.86 bitrate=12377.3kbitsframe= 1349 fps= 29 q=22.0 size=   80896kB time=00:00:53.56 bitrate=12371.2kbitsframe= 1364 fps= 29 q=22.0 size=   81920kB time=00:00:54.14 bitrate=12394.5kbitsframe= 1379 fps= 29 q=22.0 size=   82944kB time=00:00:54.74 bitrate=12412.5kbitsframe= 1396 fps= 29 q=22.0 size=   83968kB time=00:00:55.38 bitrate=12420.5kbitsframe= 1417 fps= 29 q=22.0 size=   84992kB time=00:00:56.27 bitrate=12371.9kbitsframe= 1438 fps= 29 q=22.0 size=   86016kB time=00:00:57.10 bitrate=12338.5kbitsframe= 1458 fps= 29 q=22.0 size=   87040kB time=00:00:57.92 bitrate=12310.6kbitsframe= 1478 fps= 29 q=22.0 size=   88064kB time=00:00:58.64 bitrate=12301.4kbitsframe= 1498 fps= 29 q=22.0 size=   89088kB time=00:00:59.47 bitrate=12270.4kbits[mp4 @ 0x7ff666813200] Starting second pass: moving the moov atom to the beginning of the file&#xA;frame= 1500 fps= 28 q=-1.0 Lsize=   91853kB time=00:00:59.98 bitrate=12543.2kbits/s speed=1.13x    &#xA;video:90866kB audio:941kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.049858%&#xA;[libx264 @ 0x7ff666814400] frame I:12    Avg QP:18.57  size:116766&#xA;[libx264 @ 0x7ff666814400] frame P:426   Avg QP:20.52  size: 87768&#xA;[libx264 @ 0x7ff666814400] frame B:1062  Avg QP:23.56  size: 51088&#xA;[libx264 @ 0x7ff666814400] consecutive B-frames:  2.5%  6.4%  9.0% 82.1%&#xA;[libx264 @ 0x7ff666814400] mb I  I16..4:  1.0% 87.7% 11.3%&#xA;[libx264 @ 0x7ff666814400] mb P  I16..4:  0.5% 23.0%  4.2%  P16..4: 25.2% 30.8% 16.1%  0.0%  0.0%    skip: 0.1%&#xA;[libx264 @ 0x7ff666814400] mb B  I16..4:  0.1%  1.3%  0.6%  B16..8: 37.5% 21.2%  9.4%  direct:28.6%  skip: 1.4%  L0:31.5% L1:22.8% BI:45.8%&#xA;[libx264 @ 0x7ff666814400] 8x8 transform intra:80.8% inter:75.0%&#xA;[libx264 @ 0x7ff666814400] coded y,uvDC,uvAC intra: 97.5% 95.0% 63.3% inter: 90.0% 62.4% 12.3%&#xA;[libx264 @ 0x7ff666814400] i16 v,h,dc,p: 36% 46%  6% 12%&#xA;[libx264 @ 0x7ff666814400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 16% 25%  5%  6%  7%  7%  8% 12%&#xA;[libx264 @ 0x7ff666814400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 29% 12%  6%  7%  6% 10%  7% 13%&#xA;[libx264 @ 0x7ff666814400] i8c dc,h,v,p: 36% 30% 20% 14%&#xA;[libx264 @ 0x7ff666814400] Weighted P-Frames: Y:29.3% UV:14.1%&#xA;[libx264 @ 0x7ff666814400] ref P L0: 39.8% 15.4% 21.2% 19.9%  3.8%&#xA;[libx264 @ 0x7ff666814400] ref B L0: 76.4% 19.1%  4.5%&#xA;[libx264 @ 0x7ff666814400] ref B L1: 90.7%  9.3%&#xA;[libx264 @ 0x7ff666814400] kb/s:12406.19&#xA;[aac @ 0x7ff666815c00] Qavg: 181.322&#xA;

    &#xA;

  • FFMPEG Issue : Video breaks a lot hence the real time video gets distorted and gets a little delayed while streaming on a webpage from drone

    26 mars 2022, par ashiyaa nunhuck

    ****I am trying to detect a face from my drone camera in real time.The video streams successfully but it is delayed and breaks a lot. Is there any solution to this problem ? How can i have a smooth video streaming with little delay and no video breaking in order to succeed in detecting a face ? Your help will be much appreciated.&#xA;Also, this is printed while my code is running: :

    &#xA;

    &#xA;

    INFO:werkzeug:127.0.0.1 - - [27/May/2021 15:16:14] "GET&#xA;/video/streaming HTTP/1.1" 200 -&#xA;INFO:drone_face_recognition_and_tracking.controllers.server :'action' :&#xA;'command', 'cmd' : 'takeOff'&#xA;INFO:drone_face_recognition_and_tracking.models.manage_drone :'action' :&#xA;'send_command', 'command' : 'takeoff' [h264 @ 0x55aa924a2e40] error&#xA;while decoding MB 45 38, bytestream -6 [h264 @ 0x55aa924a2e40]&#xA;concealing 424 DC, 424 AC, 424 MV errors in I frame [h264 @&#xA;0x55aa922a9a00] concealing 687 DC, 687 AC, 687 MV errors in P frame&#xA;[h264 @ 0x55aa923f79c0] left block unavailable for requested intra&#xA;mode [h264 @ 0x55aa923f79c0] error while decoding MB 0 34, bytestream&#xA;1347 [h264 @ 0x55aa923f79c0] concealing 709 DC, 709 AC, 709 MV errors&#xA;in P frame INFO:werkzeug:127.0.0.1 - - [27/May/2021 15:16:17] "POST&#xA;/api/command/ HTTP/1.1" 200 - pipe:0 : corrupt decoded frame in stream&#xA;0&#xA;Last message repeated 2 times [h264 @ 0x55aa922a9a00] error while decoding MB 49 30, bytestream -6 [h264 @ 0x55aa922a9a00] concealing&#xA;900 DC, 900 AC, 900 MV errors in P frame pipe:0 : corrupt decoded frame&#xA;in stream 0&#xA;INFO:drone_face_recognition_and_tracking.models.manage_drone :'action' :&#xA;'receive_response', 'response' : b'ok'&#xA;INFO:drone_face_recognition_and_tracking.controllers.server :'action' :&#xA;'command', 'cmd' : 'faceDetectAndTrack' INFO:werkzeug:127.0.0.1 - -&#xA;[27/May/2021 15:16:21] "POST /api/command/ HTTP/1.1" 200 - [h264 @&#xA;0x55aa924a2e40] left block unavailable for requested intra4x4 mode -1&#xA;[h264 @ 0x55aa924a2e40] error while decoding MB 0 30, bytestream 1624&#xA;[h264 @ 0x55aa924a2e40] concealing 949 DC, 949 AC, 949 MV errors in I&#xA;frame pipe:0 : corrupt decoded frame in stream 0 [h264 @&#xA;0x55aa9244d400] left block unavailable for requested intra mode [h264&#xA;@ 0x55aa9244d400] error while decoding MB 0 12, bytestream 2936 [h264&#xA;@ 0x55aa9244d400] concealing 2029 DC, 2029 AC, 2029 MV errors in I&#xA;frame pipe:0 : corrupt decoded frame in stream 0 [h264 @&#xA;0x55aa924bf700] concealing 1632 DC, 1632 AC, 1632 MV errors in P frame&#xA;pipe:0 : corrupt decoded frame in stream 0 [h264 @ 0x55aa92414280]&#xA;concealing 1571 DC, 1571 AC, 1571 MV errors in P frame

    &#xA;

    &#xA;

    Here is my code :****

    &#xA;

    import logging&#xA;import contextlib&#xA;import os&#xA;import socket&#xA;import subprocess&#xA;import threading&#xA;import time&#xA;import cv2 as cv&#xA;import numpy as np&#xA;&#xA;from drone_face_recognition_and_tracking.models.base import Singleton&#xA;&#xA;logger = logging.getLogger(__name__)&#xA;&#xA;DEFAULT_DISTANCE = 0.30&#xA;DEFAULT_SPEED = 10&#xA;DEFAULT_DEGREE = 10&#xA;&#xA;FRAME_X = int(320)  # try 640&#xA;FRAME_Y = int(240)  # try 480&#xA;FRAME_AREA = FRAME_X * FRAME_Y&#xA;&#xA;FRAME_SIZE = FRAME_AREA * 3&#xA;FRAME_CENTER_X = FRAME_X / 2&#xA;FRAME_CENTER_Y = FRAME_Y / 2&#xA;&#xA;CMD_FFMPEG = (f&#x27;ffmpeg -probesize 32 -hwaccel auto -hwaccel_device opencl -i pipe:0 &#x27;&#xA;              f&#x27;-pix_fmt bgr24 -s {FRAME_X}x{FRAME_Y} -f rawvideo pipe:1&#x27;)&#xA;&#xA;FACE_DETECT_XML_FILE = &#x27;./drone_face_recognition_and_tracking/models/haarcascade_frontalface_default.xml&#x27;&#xA;&#xA;&#xA;def receive_video(stop_event, pipe_in, host_ip, video_port):&#xA;    with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock_video:&#xA;        sock_video.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)&#xA;        sock_video.settimeout(.5)&#xA;        sock_video.bind((host_ip, video_port))&#xA;        data = bytearray(2048)&#xA;        while not stop_event.is_set():&#xA;            try:&#xA;                size, addr = sock_video.recvfrom_into(data)&#xA;                # logger.info({&#x27;action&#x27;: &#x27;receive_video&#x27;, &#x27;data&#x27;: data})&#xA;            except socket.timeout as ex:&#xA;                logger.warning({&#x27;action&#x27;: &#x27;receive_video&#x27;, &#x27;ex&#x27;: ex})&#xA;                time.sleep(0.5)&#xA;                continue&#xA;            except socket.error as ex:&#xA;                logger.error({&#x27;action&#x27;: &#x27;receive_video&#x27;, &#x27;ex&#x27;: ex})&#xA;                break&#xA;&#xA;            try:&#xA;                pipe_in.write(data[:size])&#xA;                pipe_in.flush()&#xA;            except Exception as ex:&#xA;                logger.error({&#x27;action&#x27;: &#x27;receive_video&#x27;, &#x27;ex&#x27;: ex})&#xA;                break&#xA;&#xA;&#xA;class Tello_Drone(metaclass=Singleton):&#xA;    def __init__(self, host_ip=&#x27;192.168.10.2&#x27;, host_port=8889,&#xA;                 drone_ip=&#x27;192.168.10.1&#x27;, drone_port=8889,&#xA;                 is_imperial=False, speed=DEFAULT_SPEED):&#xA;        self.host_ip = host_ip&#xA;        self.host_port = host_port&#xA;        self.drone_ip = drone_ip&#xA;        self.drone_port = drone_port&#xA;        self.drone_address = (drone_ip, drone_port)&#xA;        self.is_imperial = is_imperial&#xA;        self.speed = speed&#xA;        self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)&#xA;        self.socket.bind((self.host_ip, self.host_port))&#xA;&#xA;        self.response = None&#xA;        self.stop_event = threading.Event()&#xA;        self._response_thread = threading.Thread(target=self.receive_response, args=(self.stop_event, ))&#xA;        self._response_thread.start()&#xA;&#xA;        self.proc = subprocess.Popen(CMD_FFMPEG.split(&#x27; &#x27;),&#xA;                                     stdin=subprocess.PIPE,&#xA;                                     stdout=subprocess.PIPE)&#xA;        self.proc_stdin = self.proc.stdin&#xA;        self.proc_stdout = self.proc.stdout&#xA;&#xA;        self.video_port = 11111&#xA;&#xA;        self._receive_video_thread = threading.Thread(&#xA;            target=receive_video,&#xA;            args=(self.stop_event, self.proc_stdin,&#xA;                  self.host_ip, self.video_port,))&#xA;        self._receive_video_thread.start()&#xA;&#xA;        self.face_cascade = cv.CascadeClassifier(FACE_DETECT_XML_FILE)&#xA;        self._is_enable_face_detect = False&#xA;&#xA;        self.send_command(&#x27;command&#x27;)&#xA;        self.send_command(&#x27;streamon&#x27;)&#xA;        self.set_speed(self.speed)&#xA;&#xA;    def receive_response(self, stop_event):&#xA;        while not stop_event.is_set():&#xA;            try:&#xA;                self.response, ip = self.socket.recvfrom(3000)&#xA;                logger.info({&#x27;action&#x27;: &#x27;receive_response&#x27;,&#xA;                             &#x27;response&#x27;: self.response})&#xA;            except socket.error as ex:&#xA;                logger.error({&#x27;action&#x27;: &#x27;receive_response&#x27;,&#xA;                             &#x27;ex&#x27;: ex})&#xA;                break&#xA;&#xA;    def __dell__(self):&#xA;        self.stop()&#xA;&#xA;    def stop(self):&#xA;        self.stop_event.set()&#xA;        retry = 0&#xA;        while self._response_thread.is_alive():&#xA;            time.sleep(0.3)&#xA;            if retry > 30:&#xA;                break&#xA;            retry &#x2B;= 1&#xA;        self.socket.close()&#xA;        os.kill(self.proc.pid, 9)&#xA;&#xA;    def send_command(self, command):&#xA;        logger.info({&#x27;action&#x27;: &#x27;send_command&#x27;, &#x27;command&#x27;: command})&#xA;        self.socket.sendto(command.encode(&#x27;utf-8&#x27;), self.drone_address)&#xA;&#xA;        retry = 0&#xA;        while self.response is None:&#xA;            time.sleep(0.3)&#xA;            if retry > 3:&#xA;                break&#xA;            retry &#x2B;= 1&#xA;&#xA;        if self.response is None:&#xA;            response = None&#xA;        else:&#xA;            response = self.response.decode(&#x27;utf-8&#x27;)&#xA;        self.response = None&#xA;        return response&#xA;&#xA;    def takeoff(self):&#xA;        return self.send_command(&#x27;takeoff&#x27;)&#xA;&#xA;    def land(self):&#xA;        return self.send_command(&#x27;land&#x27;)&#xA;&#xA;    def move(self, direction, distance):&#xA;        distance = float(distance)&#xA;        if self.is_imperial:&#xA;            distance = int(round(distance * 30.48))&#xA;        else:&#xA;            distance = int(round(distance * 100))&#xA;        return self.send_command(f&#x27;{direction} {distance}&#x27;)&#xA;&#xA;    def up(self, distance=DEFAULT_DISTANCE):&#xA;        return self.move(&#x27;up&#x27;, distance)&#xA;&#xA;    def down(self, distance=DEFAULT_DISTANCE):&#xA;        return self.move(&#x27;down&#x27;, distance)&#xA;&#xA;    def left(self, distance=DEFAULT_DISTANCE):&#xA;        return self.move(&#x27;left&#x27;, distance)&#xA;&#xA;    def right(self, distance=DEFAULT_DISTANCE):&#xA;        return self.move(&#x27;right&#x27;, distance)&#xA;&#xA;    def forward(self, distance=DEFAULT_DISTANCE):&#xA;        return self.move(&#x27;forward&#x27;, distance)&#xA;&#xA;    def back(self, distance=DEFAULT_DISTANCE):&#xA;        return self.move(&#x27;back&#x27;, distance)&#xA;&#xA;    def set_speed(self, speed):&#xA;        return self.send_command(f&#x27;speed {speed}&#x27;)&#xA;&#xA;    def clockwise(self, degree=DEFAULT_DEGREE):&#xA;        return self.send_command(f&#x27;cw {degree}&#x27;)&#xA;&#xA;    def counter_clockwise(self, degree=DEFAULT_DEGREE):&#xA;        return self.send_command(f&#x27;ccw {degree}&#x27;)&#xA;&#xA;    def video_binary_generator(self):&#xA;        while True:&#xA;            try:&#xA;                frame = self.proc_stdout.read(FRAME_SIZE)&#xA;            except Exception as ex:&#xA;                logger.error({&#x27;action&#x27;: &#x27;video_binary_generator&#x27;, &#x27;ex&#x27;: ex})&#xA;                continue&#xA;&#xA;            if not frame:&#xA;                continue&#xA;&#xA;            frame = np.fromstring(frame, np.uint8).reshape(FRAME_Y, FRAME_X, 3)&#xA;            yield frame&#xA;&#xA;    def enable_face_detect(self):&#xA;        self._is_enable_face_detect = True&#xA;&#xA;    def disable_face_detect(self):&#xA;        self._is_enable_face_detect = False&#xA;&#xA;    def video_jpeg_generator(self):&#xA;        for frame in self.video_binary_generator():&#xA;            if self._is_enable_face_detect:&#xA;                gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)&#xA;                faces = self.face_cascade.detectMultiScale(gray, 1.2, 4)&#xA;                for (x, y, w, h) in faces:&#xA;                    cv.rectangle(frame, (x, y), (x&#x2B;w, y&#x2B;h), (0, 0, 255), 2)&#xA;                    break&#xA;&#xA;            _, jpeg = cv.imencode(&#x27;.jpg&#x27;, frame)&#xA;            jpeg_binary = jpeg.tobytes()&#xA;            yield jpeg_binary&#xA;

    &#xA;