Recherche avancée

Médias (0)

Mot : - Tags -/interaction

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (33)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Le plugin : Podcasts.

    14 juillet 2010, par

    Le problème du podcasting est à nouveau un problème révélateur de la normalisation des transports de données sur Internet.
    Deux formats intéressants existent : Celui développé par Apple, très axé sur l’utilisation d’iTunes dont la SPEC est ici ; Le format "Media RSS Module" qui est plus "libre" notamment soutenu par Yahoo et le logiciel Miro ;
    Types de fichiers supportés dans les flux
    Le format d’Apple n’autorise que les formats suivants dans ses flux : .mp3 audio/mpeg .m4a audio/x-m4a .mp4 (...)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

Sur d’autres sites (7299)

  • How do I properly reduce the resolution of a 360 video using ffmpeg ?

    10 avril 2017, par user3799235

    I have tried reduction with the following technique from a scale of 2048:1024 with something like : ffmpeg -i eagle360half.mp4 -vf scale=1024:512 video360_1024.mp4 however the playback then becomes warped and warbly (visually similar to a bad vhs tape). I can only speculate that this has something to do with the meridians and equirectangular projections. How would I properly scale/ reduce resolution of a 360 video using ffmpeg, or is this possible with some other cli tool ?

    Here is the output of mediainfo, ffmpeg, and then mediainfo again :

    #######################MEDIAINFO OUTPUT PRE-ENCODING#################
    $ mediainfo 360timessquare.mp4
    General
    Complete name                            : 360timessquare.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media / Version 2
    Codec ID                                 : mp42
    File size                                : 235 MiB
    Duration                                 : 14mn 18s
    Overall bit rate mode                    : Variable
    Overall bit rate                         : 2 297 Kbps
    Encoded date                             : UTC 2016-10-21 19:11:41
    Tagged date                              : UTC 2016-10-21 19:11:41
    gsst                                     : 0
    gstd                                     : 858209

    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : Main@L3.1
    Format settings, CABAC                   : Yes
    Format settings, ReFrames                : 3 frames
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 14mn 18s
    Bit rate                                 : 2 168 Kbps
    Width                                    : 1 280 pixels
    Height                                   : 720 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Constant
    Frame rate                               : 25.000 fps
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.094
    Stream size                              : 222 MiB (94%)
    Title                                    : ISO Media file produced by Google Inc.
    Encoded date                             : UTC 2016-10-21 19:11:41
    Tagged date                              : UTC 2016-10-21 19:11:41
    Color range                              : Limited
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709

    Audio
    ID                                       : 2
    Format                                   : AAC
    Format/Info                              : Advanced Audio Codec
    Format profile                           : LC
    Codec ID                                 : 40
    Duration                                 : 14mn 18s
    Bit rate mode                            : Variable
    Bit rate                                 : 126 Kbps
    Channel(s)                               : 2 channels
    Channel positions                        : Front: L R
    Sampling rate                            : 44.1 KHz
    Compression mode                         : Lossy
    Stream size                              : 12.8 MiB (5%)
    Title                                    : ISO Media file produced by Google Inc.
    Encoded date                             : UTC 2016-10-21 19:11:41
    Tagged date                              : UTC 2016-10-21 19:11:41



    ########################FFMPEG   LOG:#############################
    $ffmpeg -i 360timessquare.mp4 -s 542x320 -o 360timessquare542x320.mp4
    ffmpeg version 2.4 Copyright (c) 2000-2014 the FFmpeg developers
    built on Sep 26 2015 22:27:26 with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
    configuration: --prefix=/usr --bindir=/usr/bin --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libfreetype --enable-fontconfig --enable-libspeex --enable-libtheora --enable-frei0r --enable-libopencv --enable-zlib --enable-shared --disable-htmlpages --disable-podpages --disable-txtpages
    libavutil      54.  7.100 / 54.  7.100
    libavcodec     56.  1.100 / 56.  1.100
    libavformat    56.  4.101 / 56.  4.101
    libavdevice    56.  0.100 / 56.  0.100
    libavfilter     5.  1.100 /  5.  1.100
    libswscale      3.  0.100 /  3.  0.100
    libswresample   1.  1.100 /  1.  1.100
    libpostproc    53.  0.100 / 53.  0.100
    Unrecognized option 'o'.
    Error splitting the argument list: Option not found
    [kevin@clipcentric 360Video]$ ffmpeg -i 360timessquare.mp4 -vf -s 542x320 360timessquare542x320.mp4
    ffmpeg version 2.4 Copyright (c) 2000-2014 the FFmpeg developers
    built on Sep 26 2015 22:27:26 with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
    configuration: --prefix=/usr --bindir=/usr/bin --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libfreetype --enable-fontconfig --enable-libspeex --enable-libtheora --enable-frei0r --enable-libopencv --enable-zlib --enable-shared --disable-htmlpages --disable-podpages --disable-txtpages
    libavutil      54.  7.100 / 54.  7.100
    libavcodec     56.  1.100 / 56.  1.100
    libavformat    56.  4.101 / 56.  4.101
    libavdevice    56.  0.100 / 56.  0.100
    libavfilter     5.  1.100 /  5.  1.100
    libswscale      3.  0.100 /  3.  0.100
    libswresample   1.  1.100 /  1.  1.100
    libpostproc    53.  0.100 / 53.  0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '360timessquare.mp4':
    Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2016-10-21 19:11:41
    Duration: 00:14:18.09, start: 0.000000, bitrate: 2296 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 2168 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
    Metadata:
    creation_time   : 2016-10-21 19:11:41
    handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
    creation_time   : 2016-10-21 19:11:41
    handler_name    : ISO Media file produced by Google Inc.
    [NULL @ 0x14a0120] Unable to find a suitable output format for '542x320'
    542x320: Invalid argument
    [kevin@clipcentric 360Video]$ ffmpeg -i 360timessquare.mp4 -s 542x320 360timessquare542x320.mp4
    ffmpeg version 2.4 Copyright (c) 2000-2014 the FFmpeg developers
    built on Sep 26 2015 22:27:26 with gcc 4.8.3 (GCC) 20140911 (Red Hat 4.8.3-9)
    configuration: --prefix=/usr --bindir=/usr/bin --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libfreetype --enable-fontconfig --enable-libspeex --enable-libtheora --enable-frei0r --enable-libopencv --enable-zlib --enable-shared --disable-htmlpages --disable-podpages --disable-txtpages
    libavutil      54.  7.100 / 54.  7.100
    libavcodec     56.  1.100 / 56.  1.100
    libavformat    56.  4.101 / 56.  4.101
    libavdevice    56.  0.100 / 56.  0.100
    libavfilter     5.  1.100 /  5.  1.100
    libswscale      3.  0.100 /  3.  0.100
    libswresample   1.  1.100 /  1.  1.100
    libpostproc    53.  0.100 / 53.  0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '360timessquare.mp4':
    Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2016-10-21 19:11:41
    Duration: 00:14:18.09, start: 0.000000, bitrate: 2296 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 2168 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
    Metadata:
    creation_time   : 2016-10-21 19:11:41
    handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
    creation_time   : 2016-10-21 19:11:41
    handler_name    : ISO Media file produced by Google Inc.
    [libx264 @ 0x25f7a60] using SAR=2560/2439
    [libx264 @ 0x25f7a60] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
    [libx264 @ 0x25f7a60] profile High, level 2.1
    [libx264 @ 0x25f7a60] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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=3 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=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to '360timessquare542x320.mp4':
    Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    encoder         : Lavf56.4.101
    Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 542x320 [SAR 2560:2439 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
    creation_time   : 2016-10-21 19:11:41
    handler_name    : ISO Media file produced by Google Inc.
    encoder         : Lavc56.1.100 libx264
    Stream #0:1(und): Audio: aac (libfdk_aac) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s (default)
    Metadata:
    creation_time   : 2016-10-21 19:11:41
    handler_name    : ISO Media file produced by Google Inc.
    encoder         : Lavc56.1.100 libfdk_aac
    Stream mapping:
    Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
    Stream #0:1 -> #0:1 (aac (native) -> aac (libfdk_aac))
    Press [q] to stop, [?] for help
    frame=21452 fps= 66 q=-1.0 Lsize=   64454kB time=00:14:18.09 bitrate= 615.3kbits/s
    video:50428kB audio:13439kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.918954%
    [libx264 @ 0x25f7a60] frame I:86    Avg QP:19.09  size: 45669
    [libx264 @ 0x25f7a60] frame P:18026 Avg QP:22.11  size:  2541
    [libx264 @ 0x25f7a60] frame B:3340  Avg QP:29.11  size:   572
    [libx264 @ 0x25f7a60] consecutive B-frames: 75.9%  6.9%  9.6%  7.6%
    [libx264 @ 0x25f7a60] mb I  I16..4:  3.4% 30.9% 65.7%
    [libx264 @ 0x25f7a60] mb P  I16..4:  0.1%  0.3%  0.3%  P16..4: 25.1%  6.6%  7.4%  0.0%  0.0%    skip:60.2%
    [libx264 @ 0x25f7a60] mb B  I16..4:  0.0%  0.1%  0.1%  B16..8: 13.3%  2.4%  1.3%  direct: 1.9%  skip:81.0%  L0:25.9% L1:66.1% BI: 8.0%
    [libx264 @ 0x25f7a60] 8x8 transform intra:38.5% inter:48.3%
    [libx264 @ 0x25f7a60] coded y,uvDC,uvAC intra: 81.5% 84.3% 58.6% inter: 14.3% 14.5% 2.8%
    [libx264 @ 0x25f7a60] i16 v,h,dc,p:  7% 49%  7% 37%
    [libx264 @ 0x25f7a60] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 25% 17%  5%  7%  7% 11%  8%  9%
    [libx264 @ 0x25f7a60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 18% 14%  7%  8% 10% 11%  9%  7%
    [libx264 @ 0x25f7a60] i8c dc,h,v,p: 51% 25% 15%  9%
    [libx264 @ 0x25f7a60] Weighted P-Frames: Y:1.5% UV:0.3%
    [libx264 @ 0x25f7a60] ref P L0: 77.6% 15.9%  5.2%  1.3%  0.0%
    [libx264 @ 0x25f7a60] ref B L0: 94.0%  5.1%  0.9%
    [libx264 @ 0x25f7a60] ref B L1: 96.1%  3.9%
    [libx264 @ 0x25f7a60] kb/s:481.43

    #################POST ENCODING #####################
    $ mediainfo 360timessquare542x320.mp4
    General
    Complete name                            : 360timessquare542x320.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media
    Codec ID                                 : isom
    File size                                : 62.9 MiB
    Duration                                 : 14mn 18s
    Overall bit rate                         : 615 Kbps
    Encoded date                             : UTC 1904-01-01 00:00:00
    Tagged date                              : UTC 1904-01-01 00:00:00
    Writing application                      : Lavf56.4.101

    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L2.1
    Format settings, CABAC                   : Yes
    Format settings, ReFrames                : 4 frames
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 14mn 18s
    Bit rate                                 : 481 Kbps
    Width                                    : 542 pixels
    Height                                   : 320 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Constant
    Frame rate                               : 25.000 fps
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.111
    Stream size                              : 49.2 MiB (78%)
    Writing library                          : x264 core 142
    Encoding settings                        : 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=3 / 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=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Encoded date                             : UTC 1904-01-01 00:00:00
    Tagged date                              : UTC 1904-01-01 00:00:00

    Audio
    ID                                       : 2
    Format                                   : AAC
    Format/Info                              : Advanced Audio Codec
    Format profile                           : LC
    Codec ID                                 : 40
    Duration                                 : 14mn 18s
    Bit rate mode                            : Constant
    Bit rate                                 : 128 Kbps
    Channel(s)                               : 2 channels
    Channel positions                        : Front: L R
    Sampling rate                            : 44.1 KHz
    Compression mode                         : Lossy
    Stream size                              : 13.1 MiB (21%)
    Encoded date                             : UTC 1904-01-01 00:00:00
    Tagged date                              : UTC 1904-01-01 00:00:00
  • lavc : Drop deprecated options moved to private contexts

    16 mars 2017, par Vittorio Giovara
    lavc : Drop deprecated options moved to private contexts
    

    Deprecated in 10/2014 and 07/2015.

    • [DBH] libavcodec/avcodec.h
    • [DBH] libavcodec/dnxhdenc.c
    • [DBH] libavcodec/internal.h
    • [DBH] libavcodec/libvpxenc.c
    • [DBH] libavcodec/libx264.c
    • [DBH] libavcodec/libxavs.c
    • [DBH] libavcodec/libxvid.c
    • [DBH] libavcodec/motion_est.c
    • [DBH] libavcodec/mpegvideo.h
    • [DBH] libavcodec/mpegvideo_enc.c
    • [DBH] libavcodec/options.c
    • [DBH] libavcodec/options_table.h
    • [DBH] libavcodec/svq1enc.c
    • [DBH] libavcodec/version.h
  • RTP packets detected as UDP

    28 février 2017, par user3172852

    Here is what I am trying to do :

    WebRTC endpoint > RTP Endpoint > ffmpeg > RTMP server.

    This is what my SDP file looks like.

    var cm_offer = "v=0\n" +
                 "o=- 3641290734 3641290734 IN IP4 127.0.0.1\n" +
                 "s=nginx\n" +
                 "c=IN IP4 127.0.0.1\n" +
                 "t=0 0\n" +
                 "m=audio 60820 RTP/AVP 0\n" +
                 "a=rtpmap:0 PCMU/8000\n" +
                 "a=recvonly\n" +
                 "m=video 59618 RTP/AVP 101\n" +
                 "a=rtpmap:101 H264/90000\n" +
                 "a=recvonly\n";

    What’s happening is that wireshark can detect the incoming packets at port 59618, but not as RTP packets but UDP packets. I am trying to capture the packets using ffmpeg with the following command :

    ubuntu@ip-132-31-40-100:~$ ffmpeg -i udp://127.0.0.1:59618 -vcodec copy stream.mp4
    ffmpeg version git-2017-01-22-f1214ad Copyright (c) 2000-2017 the FFmpeg developers
     built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
     configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc
     libavutil      55. 44.100 / 55. 44.100
     libavcodec     57. 75.100 / 57. 75.100
     libavformat    57. 63.100 / 57. 63.100
     libavdevice    57.  2.100 / 57.  2.100
     libavfilter     6. 69.100 /  6. 69.100
     libavresample   3.  2.  0 /  3.  2.  0
     libswscale      4.  3.101 /  4.  3.101
     libswresample   2.  4.100 /  2.  4.100
     libpostproc    54.  2.100 / 54.  2.100

    All I get is a blinking cursor and The stream.mp4 file is not written to disk after I exit (ctrl+c).

    So can you help me figure out :

    1. why wireshark cannot detect the packets as RTP (I suspect it has something to do with SDP)
    2. How to handle SDP answer when the RTP endpoint is pushing to ffmpeg which doesn’t send an answer back.

    Here is the entire code (hello world tutorial modified)

    /*
        * (C) Copyright 2014-2015 Kurento (http://kurento.org/)
        *
        * Licensed under the Apache License, Version 2.0 (the "License");
        * you may not use this file except in compliance with the License.
        * You may obtain a copy of the License at
        *
        *   http://www.apache.org/licenses/LICENSE-2.0
        *
        * Unless required by applicable law or agreed to in writing, software
        * distributed under the License is distributed on an "AS IS" BASIS,
        * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        * See the License for the specific language governing permissions and
        * limitations under the License.
        */

       function getopts(args, opts)
       {
         var result = opts.default || {};
         args.replace(
             new RegExp("([^?=&]+)(=([^&]*))?", "g"),
             function($0, $1, $2, $3) { result[$1] = decodeURI($3); });

         return result;
       };

       var args = getopts(location.search,
       {
         default:
         {
           ws_uri: 'wss://' + location.hostname + ':8433/kurento',
           ice_servers: undefined
         }
       });

       function setIceCandidateCallbacks(webRtcPeer, webRtcEp, onerror)
       {
         webRtcPeer.on('icecandidate', function(candidate) {
           console.log("Local candidate:",candidate);

           candidate = kurentoClient.getComplexType('IceCandidate')(candidate);

           webRtcEp.addIceCandidate(candidate, onerror)
         });

         webRtcEp.on('OnIceCandidate', function(event) {
           var candidate = event.candidate;

           console.log("Remote candidate:",candidate);

           webRtcPeer.addIceCandidate(candidate, onerror);
         });
       }


       function setIceCandidateCallbacks2(webRtcPeer, rtpEp, onerror)
       {
         webRtcPeer.on('icecandidate', function(candidate) {
           console.log("Localr candidate:",candidate);

           candidate = kurentoClient.getComplexType('IceCandidate')(candidate);

           rtpEp.addIceCandidate(candidate, onerror)
         });
       }


       window.addEventListener('load', function()
       {
         console = new Console();

         var webRtcPeer;
         var pipeline;
         var webRtcEpt;

         var videoInput = document.getElementById('videoInput');
         var videoOutput = document.getElementById('videoOutput');

         var startButton = document.getElementById("start");
         var stopButton = document.getElementById("stop");

         startButton.addEventListener("click", function()
         {
           showSpinner(videoInput, videoOutput);

           var options = {
             localVideo: videoInput,
             remoteVideo: videoOutput
           };


           if (args.ice_servers) {
            console.log("Use ICE servers: " + args.ice_servers);
            options.configuration = {
              iceServers : JSON.parse(args.ice_servers)
            };
           } else {
            console.log("Use freeice")
           }

           webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function(error)
           {
             if(error) return onError(error)

             this.generateOffer(onOffer)
           });

           function onOffer(error, sdpOffer)
           {
             if(error) return onError(error)

             kurentoClient(args.ws_uri, function(error, client)
             {
               if(error) return onError(error);

               client.create("MediaPipeline", function(error, _pipeline)
               {
                 if(error) return onError(error);

                 pipeline = _pipeline;

                 pipeline.create("WebRtcEndpoint", function(error, webRtc){
                   if(error) return onError(error);

                   webRtcEpt = webRtc;

                   setIceCandidateCallbacks(webRtcPeer, webRtc, onError)

                   webRtc.processOffer(sdpOffer, function(error, sdpAnswer){
                     if(error) return onError(error);

                     webRtcPeer.processAnswer(sdpAnswer, onError);
                   });
                   webRtc.gatherCandidates(onError);

                   webRtc.connect(webRtc, function(error){
                     if(error) return onError(error);

                     console.log("Loopback established");
                   });
                 });



               pipeline.create("RtpEndpoint", function(error, rtp){
                   if(error) return onError(error);

                   //setIceCandidateCallbacks2(webRtcPeer, rtp, onError)


                   var cm_offer = "v=0\n" +
                         "o=- 3641290734 3641290734 IN IP4 127.0.0.1\n" +
                         "s=nginx\n" +
                         "c=IN IP4 127.0.0.1\n" +
                         "t=0 0\n" +
                         "m=audio 60820 RTP/AVP 0\n" +
                         "a=rtpmap:0 PCMU/8000\n" +
                         "a=recvonly\n" +
                         "m=video 59618 RTP/AVP 101\n" +
                         "a=rtpmap:101 H264/90000\n" +
                         "a=recvonly\n";



                   rtp.processOffer(cm_offer, function(error, cm_sdpAnswer){
                     if(error) return onError(error);

                     //webRtcPeer.processAnswer(cm_sdpAnswer, onError);
                   });
                   //rtp.gatherCandidates(onError);

                   webRtcEpt.connect(rtp, function(error){
                     if(error) return onError(error);

                     console.log("RTP endpoint connected to webRTC");
                   });
                 });









               });
             });
           }
         });
         stopButton.addEventListener("click", stop);


         function stop() {
           if (webRtcPeer) {
             webRtcPeer.dispose();
             webRtcPeer = null;
           }

           if(pipeline){
             pipeline.release();
             pipeline = null;
           }

           hideSpinner(videoInput, videoOutput);
         }

         function onError(error) {
           if(error)
           {
             console.error(error);
             stop();
           }
         }
       })


       function showSpinner() {
         for (var i = 0; i < arguments.length; i++) {
           arguments[i].poster = 'img/transparent-1px.png';
           arguments[i].style.background = "center transparent url('img/spinner.gif') no-repeat";
         }
       }

       function hideSpinner() {
         for (var i = 0; i < arguments.length; i++) {
           arguments[i].src = '';
           arguments[i].poster = 'img/webrtc.png';
           arguments[i].style.background = '';
         }
       }

       /**
        * Lightbox utility (to display media pipeline image in a modal dialog)
        */
       $(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
         event.preventDefault();
         $(this).ekkoLightbox();
       });