Recherche avancée

Médias (1)

Mot : - Tags -/Christian Nold

Autres articles (72)

  • Menus personnalisés

    14 novembre 2010, par

    MediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
    Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
    Menus créés à l’initialisation du site
    Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

Sur d’autres sites (11450)

  • ffmpeg error when using non root user

    29 août 2014, par mkern

    I have installed ffmpeg and it works perfect if you are root or using sudo but it errors out when trying to use it as a non-root user. I have performed the same install on a test VPS and it installs without issue so it appears to be isolated to this cPanel server. I haven’t been able to identify why.

    Non-Root :

    > ffmpeg -v debug -i 1.mov 1.avi ffmpeg version N-65949-g0ddb051
    > Copyright (c) 2000-2014 the FFmpeg developers   built on Aug 28 2014
    > 11:39:47 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)  
    > configuration: --enable-gpl --enable-libmp3lame --enable-libvorbis
    > --enable-libvpx --enable-libx264   libavutil      54.  7.100 / 54.  7.100   libavcodec     56.  0.101 / 56.  0.101   libavformat    56.  3.100 / 56.  3.100   libavdevice    56.  0.100 / 56.  0.100   libavfilter     5.  0.103 /  5.  0.103   libswscale      3.  0.100 /
    > 3.  0.100   libswresample   1.  1.100 /  1.  1.100   libpostproc    53.  0.100 / 53.  0.100 Splitting the commandline. Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
    > Reading option '-i' ... matched as input file with argument '1.mov'.
    > Reading option '1.avi' ... matched as output file. Finished splitting
    > the commandline. Parsing a group of options: global . Applying option
    > v (set logging level) with argument debug. Successfully parsed a group
    > of options. Parsing a group of options: input file 1.mov. Successfully
    > parsed a group of options. Opening an input file: 1.mov.
    > [mov,mp4,m4a,3gp,3g2,mj2 @ 0x348fc20] Format mov,mp4,m4a,3gp,3g2,mj2
    > probed with size=2048 and score=100 [mov,mp4,m4a,3gp,3g2,mj2 @
    > 0x348fc20] ISO: File Type Major Brand: qt   [mov,mp4,m4a,3gp,3g2,mj2 @
    > 0x348fc20] Before avformat_find_stream_info() pos: 698348 bytes
    > read:39602 seeks:1 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x348fc20] All info
    > found [mov,mp4,m4a,3gp,3g2,mj2 @ 0x348fc20] After
    > avformat_find_stream_info() pos: 169190 bytes read:2333362 seeks:67
    > frames:148 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mov':  
    > Metadata:
    >     major_brand     : qt  
    >     minor_version   : 0
    >     compatible_brands: qt  
    >     creation_time   : 2014-06-05 04:40:27
    >     model           : iPhone 5
    >     model-eng       : iPhone 5
    >     encoder         : 7.1.1
    >     encoder-eng     : 7.1.1
    >     date            : 2014-06-04T21:40:27-0700
    >     date-eng        : 2014-06-04T21:40:27-0700
    >     make            : Apple
    >     make-eng        : Apple   Duration: 00:00:07.15, start: 0.000023, bitrate: 781 kb/s
    >     Stream #0:0(und), 41, 1/600: Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 480x360, 1/1200, 710 kb/s, 29.09
    > fps, 600 tbr, 600 tbn, 1200 tbc (default)
    >     Metadata:
    >       rotate          : 90
    >       creation_time   : 2014-06-05 04:40:27
    >       handler_name    : Core Media Data Handler
    >       encoder         : H.264
    >     Side data:
    >       displaymatrix: rotation of -90.00 degrees
    >     Stream #0:1(und), 107, 1/44100: Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
    >     Metadata:
    >       creation_time   : 2014-06-05 04:40:27
    >       handler_name    : Core Media Data Handler Successfully opened the file. Parsing a group of options: output file 1.avi. Successfully
    > parsed a group of options. Opening an output file: 1.avi. Successfully
    > opened the file. detected 24 logical cores [graph 0 input from stream
    > 0:0 @ 0x34aa3a0] Setting 'video_size' to value '480x360' [graph 0
    > input from stream 0:0 @ 0x34aa3a0] Setting 'pix_fmt' to value '0'
    > [graph 0 input from stream 0:0 @ 0x34aa3a0] Setting 'time_base' to
    > value '1/600' [graph 0 input from stream 0:0 @ 0x34aa3a0] Setting
    > 'pixel_aspect' to value '0/1' [graph 0 input from stream 0:0 @
    > 0x34aa3a0] Setting 'sws_param' to value 'flags=2' [graph 0 input from
    > stream 0:0 @ 0x34aa3a0] Setting 'frame_rate' to value '320/11' [graph
    > 0 input from stream 0:0 @ 0x34aa3a0] w:480 h:360 pixfmt:yuv420p
    > tb:1/600 fr:320/11 sar:0/1 sws_param:flags=2 [format @ 0x3496b00]
    > compat: called with args=[yuv420p] [format @ 0x3496b00] Setting
    > 'pix_fmts' to value 'yuv420p' [AVFilterGraph @ 0x348f320]
    > query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
    > [AVFilterGraph @ 0x34bbe60] Error initializing threading.
    > [AVFilterGraph @ 0x34bbe60] Error creating filter 'anull' Error
    > opening filters! [AVIOContext @ 0x34967c0] Statistics: 0 seeks, 0
    > writeouts [AVIOContext @ 0x348f1e0] Statistics: 2333362 bytes read, 67
    > seeks

    [AVFilterGraph @ 0x34bbe60] Error initializing threading.
    [AVFilterGraph @ 0x34bbe60] Error creating filter ’anull’ Error
    opening filters !

    As ROOT :

    ffmpeg -v verbose -i 1.mov 1.avi
    ffmpeg version N-65949-g0ddb051 Copyright (c) 2000-2014 the FFmpeg developers
     built on Aug 28 2014 11:39:47 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
     configuration: --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264
     libavutil      54.  7.100 / 54.  7.100
     libavcodec     56.  0.101 / 56.  0.101
     libavformat    56.  3.100 / 56.  3.100
     libavdevice    56.  0.100 / 56.  0.100
     libavfilter     5.  0.103 /  5.  0.103
     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 '1.mov':
     Metadata:
       major_brand     : qt  
       minor_version   : 0
       compatible_brands: qt  
       creation_time   : 2014-06-05 04:40:27
       model           : iPhone 5
       model-eng       : iPhone 5
       encoder         : 7.1.1
       encoder-eng     : 7.1.1
       date            : 2014-06-04T21:40:27-0700
       date-eng        : 2014-06-04T21:40:27-0700
       make            : Apple
       make-eng        : Apple
     Duration: 00:00:07.15, start: 0.000023, bitrate: 781 kb/s
       Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 480x360, 710 kb/s, 29.09 fps, 600 tbr, 600 tbn, 1200 tbc (default)
       Metadata:
         rotate          : 90
         creation_time   : 2014-06-05 04:40:27
         handler_name    : Core Media Data Handler
         encoder         : H.264
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
       Metadata:
         creation_time   : 2014-06-05 04:40:27
         handler_name    : Core Media Data Handler
    [graph 0 input from stream 0:0 @ 0x27ed3a0] w:480 h:360 pixfmt:yuv420p tb:1/600 fr:320/11 sar:0/1 sws_param:flags=2
    [graph 1 input from stream 0:1 @ 0x2800700] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x4
    Output #0, avi, to '1.avi':
     Metadata:
       major_brand     : qt  
       minor_version   : 0
       compatible_brands: qt  
       make-eng        : Apple
       model           : iPhone 5
       model-eng       : iPhone 5
       make            : Apple
       ISFT            : Lavf56.3.100
       ICRD            : 2014-06-04T21:40:27-0700
       date-eng        : 2014-06-04T21:40:27-0700
       Stream #0:0(und): Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 480x360, q=2-31, 200 kb/s, 29.09 fps, 29.09 tbn, 29.09 tbc (default)
       Metadata:
         rotate          : 90
         creation_time   : 2014-06-05 04:40:27
         handler_name    : Core Media Data Handler
         encoder         : Lavc56.0.101 mpeg4
       Stream #0:1(und): Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 44100 Hz, mono, fltp (default)
       Metadata:
         creation_time   : 2014-06-05 04:40:27
         handler_name    : Core Media Data Handler
         encoder         : Lavc56.0.101 libmp3lame
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))
     Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
    Press [q] to stop, [?] for help
    *** dropping frame 79 from stream 0 at ts 80
    *** dropping frame 113 from stream 0 at ts 114
    *** dropping frame 145 from stream 0 at ts 146
    *** dropping frame 177 from stream 0 at ts 178
    No more output streams to write to, finishing.
    frame=  204 fps=0.0 q=27.2 Lsize=     348kB time=00:00:07.15 bitrate= 398.4kbits/s dup=0 drop=4    
    video:271kB audio:56kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.560985%
    Input file #0 (1.mov):
     Input stream #0:0 (video): 208 packets read (634624 bytes); 208 frames decoded;
     Input stream #0:1 (audio): 308 packets read (56854 bytes); 308 frames decoded (315392 samples);
     Total: 516 packets (691478 bytes) demuxed
    Output file #0 (1.avi):
     Output stream #0:0 (video): 204 frames encoded; 204 packets muxed (276993 bytes);
     Output stream #0:1 (audio): 274 frames encoded (315392 samples); 275 packets muxed (57469 bytes);
     Total: 479 packets (334462 bytes) muxed

    strace and strace -e outputs :
    strace non root :

    579 clone(child_stack=0x7fd3bfd07ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|        CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fd3bfd089d0, tls=0x7fd3bfd08700, child_tidptr=0x7fd3bfd089d0) = 3        2637
       580 mmap(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fd3bed07000
       581 mprotect(0x7fd3bed07000, 4096, PROT_NONE) = 0
       582 clone(child_stack=0x7fd3bf506ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|        CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fd3bf5079d0, tls=0x7fd3bf507700, child_tidptr=0x7fd3bf5079d0) = -        1 EAGAIN (Resource temporarily unavailable)
       583 futex(0x253b420, FUTEX_WAKE_PRIVATE, 1) = 1
       584 futex(0x253b3f4, FUTEX_CMP_REQUEUE_PRIVATE, 1, 2147483647, 0x253b420, 4) = 2
       585 futex(0x253b420, FUTEX_WAKE_PRIVATE, 1) = 1
       586 futex(0x7fd3c2d0e9d0, FUTEX_WAIT, 32631, NULL) = 0
       587 munmap(0x7fd3bed07000, 8392704)         = 0
       588 munmap(0x7fd3c250e000, 8392704)         = 0
       589 munmap(0x7fd3c1d0d000, 8392704)         = 0
       590 munmap(0x7fd3c150c000, 8392704)         = 0
       591 write(2, "\33[1;32m[AVFilterGraph @ 0x253b0a"..., 39[AVFilterGraph @ 0x253b0a0] ) = 39
       592 write(2, "\33[1;31mError initializing thread"..., 41Error initializing threading.
       593 ) = 41
       594 write(2, "\33[1;32m[AVFilterGraph @ 0x253b0a"..., 39[AVFilterGraph @ 0x253b0a0] ) = 39
       595 write(2, "\33[1;31mError creating filter 'an"..., 41Error creating filter 'anull'
       596 ) = 41
       597 write(2, "\33[4;31mError opening filters!\n\33["..., 34Error opening filters!
       598 ) = 34

    strace -e non root :

    strace -e open ffmpeg -i 1.mov 5.avi
    open("/etc/ld.so.cache", O_RDONLY)      = 3
    open("/lib64/libasound.so.2", O_RDONLY) = 3
    open("/usr/lib64/libSDL-1.2.so.0", O_RDONLY) = 3
    open("/lib64/libpthread.so.0", O_RDONLY) = 3
    open("/usr/lib64/libx264.so.142", O_RDONLY) = 3
    open("/usr/lib64/libvpx.so.0", O_RDONLY) = 3
    open("/usr/local/lib/libvorbisenc.so.2", O_RDONLY) = 3
    open("/usr/local/lib/libvorbis.so.0", O_RDONLY) = 3
    open("/usr/local/lib/libmp3lame.so.0", O_RDONLY) = 3
    open("/lib64/libm.so.6", O_RDONLY)      = 3
    open("/lib64/libbz2.so.1", O_RDONLY)    = 3
    open("/usr/local/lib/libz.so.1", O_RDONLY) = 3
    open("/lib64/librt.so.1", O_RDONLY)     = 3
    open("/lib64/libc.so.6", O_RDONLY)      = 3
    open("/lib64/libdl.so.2", O_RDONLY)     = 3
    open("/usr/local/lib/libogg.so.0", O_RDONLY) = 3
    ffmpeg version N-65949-g0ddb051 Copyright (c) 2000-2014 the FFmpeg developers
     built on Aug 28 2014 11:39:47 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
     configuration: --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264
     libavutil      54.  7.100 / 54.  7.100
     libavcodec     56.  0.101 / 56.  0.101
     libavformat    56.  3.100 / 56.  3.100
     libavdevice    56.  0.100 / 56.  0.100
     libavfilter     5.  0.103 /  5.  0.103
     libswscale      3.  0.100 /  3.  0.100
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  0.100 / 53.  0.100
    open("1.mov", O_RDONLY|O_CLOEXEC)       = 3
    open("/etc/localtime", O_RDONLY)        = 4
    open("/proc/meminfo", O_RDONLY|O_CLOEXEC) = 4
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mov':
     Metadata:
       major_brand     : qt  
       minor_version   : 0
       compatible_brands: qt  
       creation_time   : 2014-06-05 04:40:27
       model           : iPhone 5
       model-eng       : iPhone 5
       encoder         : 7.1.1
       encoder-eng     : 7.1.1
       date            : 2014-06-04T21:40:27-0700
       date-eng        : 2014-06-04T21:40:27-0700
       make            : Apple
       make-eng        : Apple
     Duration: 00:00:07.15, start: 0.000023, bitrate: 781 kb/s
       Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 480x360, 710 kb/s, 29.09 fps, 600 tbr, 600 tbn, 1200 tbc (default)
       Metadata:
         rotate          : 90
         creation_time   : 2014-06-05 04:40:27
         handler_name    : Core Media Data Handler
         encoder         : H.264
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
       Metadata:
         creation_time   : 2014-06-05 04:40:27
         handler_name    : Core Media Data Handler
    open("5.avi", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 4
    [AVFilterGraph @ 0x26ff4a0] Error initializing threading.
    [AVFilterGraph @ 0x26ff4a0] Error creating filter 'anull'
    Error opening filters!

    strace root :

    579 clone(child_stack=0x7f4eb7c34ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|        CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f4eb7c359d0, tls=0x7f4eb7c35700, child_tidptr=0x7f4eb7c359d0) = 3        383
       580 mmap(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f4eb6c34000
       581 mprotect(0x7f4eb6c34000, 4096, PROT_NONE) = 0
       582 clone(child_stack=0x7f4eb7433ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|        CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f4eb74349d0, tls=0x7f4eb7434700, child_tidptr=0x7f4eb74349d0) = 3        384
       583 mmap(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f4eb6433000
       584 mprotect(0x7f4eb6433000, 4096, PROT_NONE) = 0
       585 clone(child_stack=0x7f4eb6c32ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|        CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f4eb6c339d0, tls=0x7f4eb6c33700, child_tidptr=0x7f4eb6c339d0) = 3        385
       586 mmap(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f4eb5c32000
       587 mprotect(0x7f4eb5c32000, 4096, PROT_NONE) = 0
       588 clone(child_stack=0x7f4eb6431ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|        CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f4eb64329d0, tls=0x7f4eb6432700, child_tidptr=0x7f4eb64329d0) = 3        386
       589 mmap(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f4eb5431000
       590 mprotect(0x7f4eb5431000, 4096, PROT_NONE) = 0
       591 clone(child_stack=0x7f4eb5c30ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|        CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f4eb5c319d0, tls=0x7f4eb5c31700, child_tidptr=0x7f4eb5c319d0) = 3        387
       592 mmap(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f4eb4c30000
       593 mprotect(0x7f4eb4c30000, 4096, PROT_NONE) = 0
       594 clone(child_stack=0x7f4eb542fff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|        CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f4eb54309d0, tls=0x7f4eb5430700, child_tidptr=0x7f4eb54309d0) = 3        388
       595 mmap(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f4eb442f000
       596 mprotect(0x7f4eb442f000, 4096, PROT_NONE) = 0
       597 clone(child_stack=0x7f4eb4c2eff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|        CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f4eb4c2f9d0, tls=0x7f4eb4c2f700, child_tidptr=0x7f4eb4c2f9d0) = 3        389
       598 mmap(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f4eb3c2e000

    strace -e root :

       strace -e open ffmpeg -i 1.mov 5.avi
       open("/etc/ld.so.cache", O_RDONLY)      = 3
       open("/lib64/libasound.so.2", O_RDONLY) = 3
       open("/usr/lib64/libSDL-1.2.so.0", O_RDONLY) = 3
       open("/lib64/libpthread.so.0", O_RDONLY) = 3
       open("/usr/lib64/libx264.so.142", O_RDONLY) = 3
       open("/usr/lib64/libvpx.so.0", O_RDONLY) = 3
       open("/usr/local/lib/libvorbisenc.so.2", O_RDONLY) = 3
       open("/usr/local/lib/libvorbis.so.0", O_RDONLY) = 3
       open("/usr/local/lib/libmp3lame.so.0", O_RDONLY) = 3
       open("/lib64/libm.so.6", O_RDONLY)      = 3
       open("/lib64/libbz2.so.1", O_RDONLY)    = 3
       open("/usr/local/lib/libz.so.1", O_RDONLY) = 3
       open("/lib64/librt.so.1", O_RDONLY)     = 3
       open("/lib64/libc.so.6", O_RDONLY)      = 3
       open("/lib64/libdl.so.2", O_RDONLY)     = 3
       open("/usr/local/lib/libogg.so.0", O_RDONLY) = 3
       ffmpeg version N-65957-gc6a3b00 Copyright (c) 2000-2014 the FFmpeg developers
         built on Aug 28 2014 13:37:32 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
         configuration: --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264 --prefix=/usr --libdir=/usr/lib64 --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264
         libavutil      54.  7.100 / 54.  7.100
         libavcodec     56.  0.101 / 56.  0.101
         libavformat    56.  3.100 / 56.  3.100
         libavdevice    56.  0.100 / 56.  0.100
         libavfilter     5.  0.103 /  5.  0.103
         libswscale      3.  0.100 /  3.  0.100
         libswresample   1.  1.100 /  1.  1.100
         libpostproc    53.  0.100 / 53.  0.100
       open("1.mov", O_RDONLY|O_CLOEXEC)       = 3
       open("/etc/localtime", O_RDONLY)        = 4
       open("/proc/meminfo", O_RDONLY|O_CLOEXEC) = 4
       Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mov':
         Metadata:
           major_brand     : qt  
           minor_version   : 0
           compatible_brands: qt  
           creation_time   : 2014-06-05 04:40:27
           model           : iPhone 5
           model-eng       : iPhone 5
           encoder         : 7.1.1
           encoder-eng     : 7.1.1
           date            : 2014-06-04T21:40:27-0700
           date-eng        : 2014-06-04T21:40:27-0700
           make            : Apple
           make-eng        : Apple
         Duration: 00:00:07.15, start: 0.000023, bitrate: 781 kb/s
           Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 480x360, 710 kb/s, 29.09 fps, 600 tbr, 600 tbn, 1200 tbc (default)
           Metadata:
             rotate          : 90
             creation_time   : 2014-06-05 04:40:27
             handler_name    : Core Media Data Handler
             encoder         : H.264
           Side data:
             displaymatrix: rotation of -90.00 degrees
           Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 63 kb/s (default)
           Metadata:
             creation_time   : 2014-06-05 04:40:27
             handler_name    : Core Media Data Handler
       File '5.avi' already exists. Overwrite ? [y/N] y
       open("5.avi", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 4
       Output #0, avi, to '5.avi':
         Metadata:
           major_brand     : qt  
           minor_version   : 0
           compatible_brands: qt  
           make-eng        : Apple
           model           : iPhone 5
           model-eng       : iPhone 5
           make            : Apple
           ISFT            : Lavf56.3.100
           ICRD            : 2014-06-04T21:40:27-0700
           date-eng        : 2014-06-04T21:40:27-0700
           Stream #0:0(und): Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 480x360, q=2-31, 200 kb/s, 29.09 fps, 29.09 tbn, 29.09 tbc (default)
           Metadata:
             rotate          : 90
             creation_time   : 2014-06-05 04:40:27
             handler_name    : Core Media Data Handler
             encoder         : Lavc56.0.101 mpeg4
           Stream #0:1(und): Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 44100 Hz, mono, fltp (default)
           Metadata:
             creation_time   : 2014-06-05 04:40:27
             handler_name    : Core Media Data Handler
             encoder         : Lavc56.0.101 libmp3lame
       Stream mapping:
         Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (native))
         Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
       Press [q] to stop, [?] for help
       frame=  204 fps=0.0 q=27.2 Lsize=     348kB time=00:00:07.15 bitrate= 398.4kbits/s dup=0 drop=4    
       video:271kB audio:56kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.560985%
  • How to create a scheduled task – Introducing the Piwik Platform

    28 août 2014, par Thomas Steur — Development

    This is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to create a custom theme in Piwik). This time you’ll learn how to execute scheduled tasks in the background, for instance sending a daily email. For this tutorial you will need to have basic knowledge of PHP.

    What can you do with scheduled tasks ?

    Scheduled tasks let you execute tasks regularly (hourly, weekly, …). For instance you can :

    • create and send custom reports or summaries
    • sync users and websites with other systems
    • clear any caches
    • import third-party data into Piwik
    • monitor your Piwik instance
    • execute any other task you can think of

    Getting started

    In this series of posts, we assume that you have already set up your development environment. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik.

    To summarize the things you have to do to get setup :

    • Install Piwik (for instance via git).
    • Activate the developer mode : ./console development:enable --full.
    • Generate a plugin : ./console generate:plugin --name="MyTasksPlugin". There should now be a folder plugins/MyTasksPlugin.
    • And activate the created plugin under Settings => Plugins.

    Let’s start creating a scheduled task

    We start by using the Piwik Console to create a tasks template :

    ./console generate:scheduledtask

    The command will ask you to enter the name of the plugin the task should belong to. I will simply use the above generated plugin name “MyTasksPlugin”. There should now be a file plugins/MyTasksPlugin/Tasks.php which contains some examples to get you started easily :

    class Tasks extends \Piwik\Plugin\Tasks
    {
       public function schedule()
       {
           $this->hourly('myTask');  // method will be executed once every hour
           $this->daily('myTask');   // method will be executed once every day
           $this->weekly('myTask');  // method will be executed once every week
           $this->monthly('myTask'); // method will be executed once every month

           // pass a parameter to the task
           $this->weekly('myTaskWithParam', 'anystring');

           // specify a different priority
           $this->monthly('myTask', null, self::LOWEST_PRIORITY);
           $this->monthly('myTaskWithParam', 'anystring', self::HIGH_PRIORITY);
       }

       public function myTask()
       {
           // do something
       }

       public function myTaskWithParam($param)
       {
           // do something
       }
    }

    A simple example

    As you can see in the generated template you can execute tasks hourly, daily, weekly and monthly by registering a method which represents the actual task :

    public function schedule()
    {
       // register method remindMeToLogIn to be executed once every day
       $this->daily('remindMeToLogIn');  
    }

    public function remindMeToLogIn()
    {
       $mail = new \Piwik\Mail();
       $mail->addTo('me@example.com');
       $mail->setSubject('Check stats');
       $mail->setBodyText('Log into your Piwik instance and check your stats!');
       $mail->send();
    }

    This example sends you an email once a day to remind you to log into your Piwik daily. The Piwik platform makes sure to execute the method remindMeToLogIn exactly once every day.

    How to pass a parameter to a task

    Sometimes you want to pass a parameter to a task method. This is useful if you want to register for instance one task for each user or for each website. You can achieve this by specifying a second parameter when registering the method to execute.

    public function schedule()
    {
       foreach (\Piwik\Site::getSites() as $site) {
           // create one task for each site and pass the URL of each site to the task
           $this->hourly('pingSite', $site['main_url']);
       }
    }

    public function pingSite($siteMainUrl)
    {
       file_get_contents($siteMainUrl);
    }

    How to test scheduled tasks

    After you have created your task you are surely wondering how to test it. First, you should write a unit or integration test which we will cover in one of our future blog posts. Just one hint : You can use the command ./console generate:test to create a test. To manually execute all scheduled tasks you can execute the API method CoreAdminHome.runScheduledTasks by opening the following URL in your browser :

    http://piwik.example.com/index.php?module=API&method=CoreAdminHome.runScheduledTasks&token_auth=YOUR_API_TOKEN

    Don’t forget to replace the domain and the token_auth URL parameter.

    There is one problem with executing the scheduled tasks : The platform makes sure they will be executed only once an hour, a day, etc. This means you can’t simply reload the URL and test the method again and again as you would have to wait for the next hour or day. The proper solution is to set the constant DEBUG_FORCE_SCHEDULED_TASKS to true within the file Core/TaskScheduler.php. Don’t forget to set it back to false again once you have finished testing it.

    Starting from Piwik 2.6.0 you can alternatively execute the following command :

    ./console core:run-scheduled-tasks --force --token-auth=YOUR_TOKEN_AUTH

    The option “–force” will make sure to execute even tasks that are not due to run at this time. So you won’t have to modify any files.

    Which tasks are registered and when is the next execution time of my task ?

    The TasksTimetable plugin from the Marketplace can answer this question for you. Simply install and activate the plugin with one click by going to Settings => Marketplace => Get new functionality. It’ll add a new admin menu item under Settings named Scheduled Tasks.

    Publishing your Plugin on the Marketplace

    In case you want to share your task(s) with other Piwik users you can do this by pushing your plugin to a public GitHub repository and creating a tag. Easy as that. Read more about how to distribute a plugin.

    Advanced features

    Isn’t it easy to create scheduled tasks ? We never even created a file ! Of course, based on our API design principle “The complexity of our API should never exceed the complexity of your use case.” you can accomplish more if you want. For instance, you can define priorities, you can directly register methods from different objects and classes, you can specify at which time of a day a task should run and more.

    Would you like to know more about tasks ? Go to our Tasks class reference in the Piwik Developer Zone.

    If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.

  • How to create a widget – Introducing the Piwik Platform

    4 septembre 2014, par Thomas Steur — Development

    This is the next post of our blog series where we introduce the capabilities of the Piwik platform (our previous post was How to create a scheduled task in Piwik). This time you’ll learn how to create a new widget. For this tutorial you will need to have basic knowledge of PHP.

    What is a widget in Piwik ?

    Widgets can be added to your dashboards or exported via a URL to embed it on any page. Most widgets in Piwik represent a report but a widget can display anything. For instance a RSS feed of your corporate news. If you prefer to have most of your business relevant data in one dashboard why not display the number of offline sales, the latest stock price, or other key metrics together with your analytics data ?

    Getting started

    In this series of posts, we assume that you have already set up your development environment. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik.

    To summarize the things you have to do to get setup :

    • Install Piwik (for instance via git).
    • Activate the developer mode : ./console development:enable --full.
    • Generate a plugin : ./console generate:plugin --name="MyWidgetPlugin". There should now be a folder plugins/MyWidgetPlugin.
    • And activate the created plugin under Settings => Plugins.

    Let’s start creating a widget

    We start by using the Piwik Console to create a widget template :

    ./console generate:widget

    The command will ask you to enter the name of the plugin the widget should belong to. I will simply use the above chosen plugin name “MyWidgetPlugin”. It will ask you for a widget category as well. You can select any existing category, for instance “Visitors”, “Live !” or “Actions”, or you can define a new category, for instance your company name. There should now be a file plugins/MyWidgetPlugin/Widgets.php which contains already some examples to get you started easily :

    1. class Widgets extends \Piwik\Plugin\Widgets
    2. {
    3.     /**
    4.      * Here you can define the category the widget belongs to. You can reuse any existing widget category or define your own category.
    5.      * @var string
    6.      */
    7.     protected $category = 'ExampleCompany';
    8.  
    9.     /**
    10.      * Here you can add one or multiple widgets. You can add a widget by calling the method "addWidget()" and pass the name of the widget as well as a method name that should be called to render the widget. The method can be defined either directly here in this widget class or in the controller in case you want to reuse the same action for instance in the menu etc.
    11.      */
    12.     protected function init()
    13.     {
    14.         $this->addWidget('Example Widget Name', $method = 'myExampleWidget');
    15.         $this->addWidget('Example Widget 2',    $method = 'myExampleWidget', $params = array('myparam' => 'myvalue'));
    16.     }
    17.  
    18.     /**
    19.      * This method renders a widget as defined in "init()". It's on you how to generate the content of the widget. As long as you return a string everything is fine. You can use for instance a "Piwik\View" to render a twig template. In such a case don't forget to create a twig template (eg. myViewTemplate.twig) in the "templates" directory of your plugin.
    20.      *
    21.      * @return string
    22.      */
    23.     public function myExampleWidget()
    24.     {
    25.         $view = new View('@MyWidgetPlugin/myViewTemplate');
    26.         return $view->render();
    27.     }
    28. }

    Télécharger

    As you might have noticed in the generated template we put emphasis on adding comments to explain you directly how to continue and where to get more information. Ideally this saves you some time and you don’t even have to search for more information on our developer pages. The category is defined in the property $category and can be changed at any time. Starting from Piwik 2.6.0 the generator will directly create a translation key if necessary to make it easy to translate the category into any language. Translations will be a topic in one of our future posts until then you can explore this feature on our Internationalization guide.

    A simple example

    We can define one or multiple widgets in the init method by calling addWidget($widgetName, $methodName). To do so we define the name of a widget which will be seen by your users as well as the name of the method that shall render the widget.

    protected $category = 'Example Company';

    public function init()
    {
       // Registers a widget named 'News' under the category 'Example Company'.
       // The method 'myCorporateNews' will be used to render the widget.
       $this->addWidget('News', $method = 'myCorporateNews');
    }

    public function myCorporateNews()
    {
       return file_get_contents('http://example.com/news');
    }

    This example would display the content of the specified URL within the widget as defined in the method myCorporateNews. It’s on you how to generate the content of the widget. Any string returned by this method will be displayed within the widget. You can use for example a View to render a Twig template. For simplification we are fetching the content from another site. A more complex version would cache this content for faster performance. Caching and views will be covered in one of our future posts as well.

    Example Widget

    Did you know ? To make your life as a developer as stress-free as possible the platform checks whether the registered method actually exists and whether the method is public. If not, Piwik will display a notification in the UI and advice you with the next step.

    Checking permissions

    Often you do not want to have the content of a widget visible to everyone. You can check for permissions by using one of our many convenient methods which all start with \Piwik\Piwik::checkUser*. Just to introduce some of them :

    // Make sure the current user has super user access
    \Piwik\Piwik::checkUserHasSuperUserAccess();

    // Make sure the current user is logged in and not anonymous
    \Piwik\Piwik::checkUserIsNotAnonymous();

    And here is an example how you can use it within your widget :

    public function myCorporateNews()
    {
       // Make sure there is an idSite URL parameter
       $idSite = Common::getRequestVar('idSite', null, 'int');

       // Make sure the user has at least view access for the specified site. This is useful if you want to display data that is related to the specified site.
       Piwik::checkUserHasViewAccess($idSite);

       $siteUrl = \Piwik\Site::getMainUrlFor($idSite);

       return file_get_contents($siteUrl . '/news');
    }

    In case any condition is not met an exception will be thrown and an error message will be presented to the user explaining that he does not have enough permissions. You’ll find the documentation for those methods in the Piwik class reference.

    How to test a widget

    After you have created your widgets you are surely wondering how to test it. First, you should write a unit or integration test which we will cover in one of our future blog posts. Just one hint : You can use the command ./console generate:test to create a test. To manually test a widget you can add a widget to a dashboard or export it.

    Publishing your Plugin on the Marketplace

    In case you want to share your widgets with other Piwik users you can do this by pushing your plugin to a public GitHub repository and creating a tag. Easy as that. Read more about how to distribute a plugin.

    Advanced features

    Isn’t it easy to create a widget ? We never even created a file ! Of course, based on our API design principle “The complexity of our API should never exceed the complexity of your use case.” you can accomplish more if you want : You can clarify parameters that will be passed to your widget, you can create a method in the Controller instead of the Widget class to make the same method also reusable for adding it to the menu, you can assign different categories to different widgets, you can remove any widgets that were added by the Piwik core or other plugins and more.

    Would you like to know more about widgets ? Go to our Widgets class reference in the Piwik Developer Zone.

    If you have any feedback regarding our APIs or our guides in the Developer Zone feel free to send it to us.