Recherche avancée

Médias (0)

Mot : - Tags -/configuration

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

Autres articles (111)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • Le profil des utilisateurs

    12 avril 2011, par

    Chaque utilisateur dispose d’une page de profil lui permettant de modifier ses informations personnelle. Dans le menu de haut de page par défaut, un élément de menu est automatiquement créé à l’initialisation de MediaSPIP, visible uniquement si le visiteur est identifié sur le site.
    L’utilisateur a accès à la modification de profil depuis sa page auteur, un lien dans la navigation "Modifier votre profil" est (...)

  • Configurer la prise en compte des langues

    15 novembre 2010, par

    Accéder à la configuration et ajouter des langues prises en compte
    Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
    De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
    Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...)

Sur d’autres sites (9079)

  • Facing issue with mp4Parser

    20 novembre 2014, par Rohit

    I am trying to trim video with the help of mp4Parser. In output am getting trimmed video but just before video finishes it give error "Sorry cant Play this video". Video am making is H264.

       public static void main(String args) throws IOException {

       Movie movie = new MovieCreator()
               .build(new RandomAccessFileIsoBufferWrapperImpl(
                       new File(
                               "/sdcard/Videos11/"+args+".mp4")));

       List<track> tracks = movie.getTracks();
       Log.e("Tracks","Following are the Tracks:- "+tracks);
       movie.setTracks(new LinkedList<track>());
       // remove all tracks we will create new tracks from the old

       double startTime = 0.000;
       double endTime = 6.000;

       boolean timeCorrected = false;

       // Here we try to find a track that has sync samples. Since we can only
       // start decoding
       // at such a sample we SHOULD make sure that the start of the new
       // fragment is exactly
       // such a frame
       for (Track track : tracks) {
           if (track.getSyncSamples() != null
                   &amp;&amp; track.getSyncSamples().length > 0) {
               if (timeCorrected) {
                   // This exception here could be a false positive in case we
                   // have multiple tracks
                   // with sync samples at exactly the same positions. E.g. a
                   // single movie containing
                   // multiple qualities of the same video (Microsoft Smooth
                   // Streaming file)

                   throw new RuntimeException(
                           "The startTime has already been corrected by another track with SyncSample. Not Supported.");
               }
               startTime = correctTimeToNextSyncSample(track, startTime);
               endTime = correctTimeToNextSyncSample(track, endTime);
               timeCorrected = true;
           }
       }

       for (Track track : tracks) {
           long currentSample = 0;
           double currentTime = 0;
           long startSample = -1;
           long endSample = -1;

           for (int i = 0; i &lt; track.getDecodingTimeEntries().size(); i++) {
               TimeToSampleBox.Entry entry = track.getDecodingTimeEntries().get(i);
               for (int j = 0; j &lt; entry.getCount(); j++) {
                   // entry.getDelta() is the amount of time the current sample
                   // covers.

                   if (currentTime &lt;= startTime) {
                       // current sample is still before the new starttime
                       startSample = currentSample;
                   }
                   if (currentTime &lt;= endTime) {
                       // current sample is after the new start time and still
                       // before the new endtime
                       endSample = currentSample;
                   } else {
                       // current sample is after the end of the cropped video
                       break;
                   }
                   currentTime += (double) entry.getDelta()
                           / (double) track.getTrackMetaData().getTimescale();
                   currentSample++;
               }
           }
           movie.addTrack(new CroppedTrack(track, startSample, endSample));
       }

       IsoFile out = new DefaultMp4Builder().build(movie);

       String filePath = "sdcard/test"+i+".mp4";
       i++;
       File f = new File(filePath);
       FileOutputStream fos = new FileOutputStream(f);
       BufferedOutputStream bos = new BufferedOutputStream(fos, 65535);
       out.getBox(new IsoOutputStream(fos));
       bos.close();
       fos.flush();
       fos.close();

    }

    private static double correctTimeToNextSyncSample(Track track,
           double cutHere) {
       double[] timeOfSyncSamples = new double[track.getSyncSamples().length];
       long currentSample = 0;
       double currentTime = 0;
       for (int i = 0; i &lt; track.getDecodingTimeEntries().size(); i++) {
           TimeToSampleBox.Entry entry = track.getDecodingTimeEntries().get(i);
           for (int j = 0; j &lt; entry.getCount(); j++) {
               if (Arrays.binarySearch(track.getSyncSamples(),
                       currentSample + 1) >= 0) {
                   // samples always start with 1 but we start with zero
                   // therefore +1
                   timeOfSyncSamples[Arrays.binarySearch(
                           track.getSyncSamples(), currentSample + 1)] = currentTime;
               }
               currentTime += (double) entry.getDelta()
                       / (double) track.getTrackMetaData().getTimescale();
               currentSample++;
           }
       }
       for (double timeOfSyncSample : timeOfSyncSamples) {
           if (timeOfSyncSample > cutHere) {
               return timeOfSyncSample;
           }
       }
       return timeOfSyncSamples[timeOfSyncSamples.length - 1];
    }
    </track></track>

    Making video of 30 seconds and want to trim first 6 seconds. Working but in last(between 5 to 6 sec) it shows Cant play this video. Any help will be appreciated.

  • ffmpeg and hardware acceleration

    17 novembre 2014, par user1541069

    This code is to decode an h264 stream from camera using ffmpeg, but I want to use hardware acceleration for decoding video. I can’t find a good example.

       string url = @"rtsp://admin:123456@192.168.0.201:554";

           FFmpegInvoke.av_register_all();
           FFmpegInvoke.avcodec_register_all();
           FFmpegInvoke.avformat_network_init();


           AVFormatContext* pFormatContext = FFmpegInvoke.avformat_alloc_context();
           if (FFmpegInvoke.avformat_open_input(&amp;pFormatContext, url, null, null) != 0)
               throw new Exception("Could not open file");

           if (FFmpegInvoke.avformat_find_stream_info(pFormatContext, null) != 0)
               throw new Exception("Could not find stream info");

           AVStream* pStream = null;
           for (int i = 0; i &lt; pFormatContext->nb_streams; i++)
           {
               if (pFormatContext->streams[i]->codec->codec_type == AVMediaType.AVMEDIA_TYPE_VIDEO)
               {
                   pStream = pFormatContext->streams[i];
                   break;
               }
           }
           if (pStream == null)
               throw new Exception("Could not found video stream");

           AVCodecContext codecContext = *(pStream->codec);
           int width = codecContext.width;
           int height = codecContext.height;
           AVPixelFormat sourcePixFmt = codecContext.pix_fmt;
           AVCodecID codecId = codecContext.codec_id;
           var convertToPixFmt = AVPixelFormat.PIX_FMT_BGR24;
           SwsContext* pConvertContext = FFmpegInvoke.sws_getContext(width, height, sourcePixFmt,
                                                                      width, height, convertToPixFmt,
                                                                      FFmpegInvoke.SWS_FAST_BILINEAR, null, null, null);
           if (pConvertContext == null)
               throw new Exception("Could not initialize the conversion context");

           var pConvertedFrame = (AVPicture*)FFmpegInvoke.avcodec_alloc_frame();
           int convertedFrameBufferSize = FFmpegInvoke.avpicture_get_size(convertToPixFmt, width, height);
           var pConvertedFrameBuffer = (byte*)FFmpegInvoke.av_malloc((uint) convertedFrameBufferSize);
           FFmpegInvoke.avpicture_fill(pConvertedFrame, pConvertedFrameBuffer, convertToPixFmt, width, height);

           AVCodec* pCodec = FFmpegInvoke.avcodec_find_decoder(codecId);
           if (pCodec == null)
               throw new Exception("Unsupported codec");

           // Reusing codec context from stream info,
           // as an alternative way it could look like this: (but it works not for all kind of codecs)
           // AVCodecContext* pCodecContext = FFmpegInvoke.avcodec_alloc_context3(pCodec);
           AVCodecContext* pCodecContext = &amp;codecContext;

           if ((pCodec->capabilities &amp; FFmpegInvoke.CODEC_CAP_TRUNCATED) == FFmpegInvoke.CODEC_CAP_TRUNCATED)
               pCodecContext->flags |= FFmpegInvoke.CODEC_FLAG_TRUNCATED;

           if (FFmpegInvoke.avcodec_open2(pCodecContext, pCodec, null) &lt; 0)
               throw new Exception("Could not open codec");

           AVFrame* pDecodedFrame = FFmpegInvoke.avcodec_alloc_frame();

           var packet = new AVPacket();
           AVPacket* pPacket = &amp;packet;
           FFmpegInvoke.av_init_packet(pPacket);

           int frameNumber = 0;
           while (true)
           {
               Console.WriteLine("frame: {0}", frameNumber);

               if (FFmpegInvoke.av_read_frame(pFormatContext, pPacket) &lt; 0)
                   throw new Exception("Could not read frame");

               if (pPacket->stream_index != pStream->index)
                   continue;

               int gotPicture = 0;
               int size = FFmpegInvoke.avcodec_decode_video2(pCodecContext, pDecodedFrame, &amp;gotPicture, pPacket);
               if (size &lt; 0)
                   throw new Exception(string.Format("Error while decoding frame {0}", frameNumber));

               if (gotPicture == 1)
               {
                   byte** src = &amp;pDecodedFrame->data_0;
                   byte** dst = &amp;pConvertedFrame->data_0;
                   FFmpegInvoke.sws_scale(pConvertContext, src, pDecodedFrame->linesize, 0,
                                           height, dst, pConvertedFrame->linesize);

                   byte* convertedFrameAddress = pConvertedFrame->data_0;

                   var imageBufferPtr = new IntPtr(convertedFrameAddress);

                   using (var bitmap = new Bitmap(width, height, pConvertedFrame->linesize[0], PixelFormat.Format24bppRgb, imageBufferPtr))
                   {
                       bitmap.Save(@"frame.buffer.jpg", ImageFormat.Jpeg);
                   }
               }
               //frameNumber++;
           }

           FFmpegInvoke.av_free(pConvertedFrame);
           FFmpegInvoke.av_free(pConvertedFrameBuffer);
           FFmpegInvoke.sws_freeContext(pConvertContext);

           FFmpegInvoke.av_free(pDecodedFrame);
           FFmpegInvoke.avcodec_close(pCodecContext);
           FFmpegInvoke.avformat_close_input(&amp;pFormatContext);

    How can I use hardware acceleration for decoding stream(hwaccel) ?

  • How to verify user permissions – Introducing the Piwik Platform

    9 novembre 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 make your plugin multilingual). This time you’ll learn how to verify user permissions. For this tutorial you will need to have basic knowledge of PHP and the Piwik platform.

    When should a plugin verify permissions ?

    Usually you want to do this before executing any action – such as deleting or fetching data – and before rendering any sensitive information that should not be accessible by everyone. For instance in an API method or Controller action. You sometimes also need to verify permissions before registering menu items or widgets.

    How does Piwik’s user management work ?

    It is quite simple as it only differentiates between a few roles : View permission, Admin permission and Super User permission. If you manage multiple websites with Piwik a user can be assigned to different roles as a user might have no permission for some websites but view or admin permission for another set of websites.

    Worth mentioning is that roles inherit from each other. This means the role admin automatically includes the role view and a super user automatically covers the view and admin role.

    Getting started

    In this post, we assume that you have already set up your development environment and created a plugin. If not, visit the Piwik Developer Zone where you’ll find the tutorial Setting up Piwik and other Guides that help you to develop a plugin.

    Verifying user permissions

    To protect your data the platform offers many convenient methods in the \Piwik\Piwik class. There you will find methods that either start with check, is or has. While methods that start with check throw an exception in case a condition is not met, the other methods return a boolean true or false.

    Use methods that throw an exception if you want to stop any further execution in case a user does not have an appropriate role. The platform will catch the exception and display an error message or ask the user to log in.

    1. public function deleteAllMessages()
    2. {
    3.     // delete messages only if user has super user access, otherwise show an error message
    4.     Piwik::checkUserSuperUserAccess();
    5.  
    6.     $this-&gt;getModel()-&gt;deleteAllMessages();
    7. }

    Télécharger

    Use methods that return a boolean for instance when registering menu items or widgets.

    1. public function configureAdminMenu(MenuAdmin $menu)
    2. {
    3.     if (Piwik::hasUserSuperUserAccess()) {
    4.         $menu-&gt;addPlatformItem('Plugins', $this-&gt;urlForDefaultAction());
    5.     }
    6. }

    Télécharger

    It is important to be aware that just because the menu item won’t be displayed in the UI a user can still open the registered URL manually. Therefore you have to check for permissions in the actual controller action as well.

    View permission

    A user having a view permission should be only able to view reports but not make any changes apart from his personal settings. The methods that end with UserHasSomeViewAccess make sure a user has at least view permission for one website whereas the methods *UserHasViewAccess($idSites = array(1,2,3)) check whether a user has view access for all of the given websites.

    1. Piwik::checkUserHasSomeViewAccess();
    2.  
    3. Piwik::checkUserHasViewAccess($idSites = array(1,2,3));

    Télécharger

    As a plugin developer you would usually use the latter example to verify the permissions for specific websites. Use the first example in case you develop something like an “All Websites Dashboard” where you only want to make sure the user has a view permission for at least one website.

    Admin permission

    A user having an admin permission cannot only view reports but also change website related settings. The methods to check for this role are similar to the ones before, just swap the term View with Admin.

    1. Piwik::checkUserHasSomeAdminAccess();
    2.  
    3. Piwik::checkUserHasAdminAccess($idSites = array(1,2,3));

    Télécharger

    Super user permission

    A user having the super user permission is allowed to access all of the data stored in Piwik and change any settings. To check if a user has this role use one of the methods that end with UserSuperUserAccess.

    Piwik::checkUserHasSuperUserAccess();

    As a plugin developer you would check for this permission for instance in places where your plugin shows an activity log over all users or where it offers the possibility to change any system wide settings.

    Getting information about the currently logged in user

    Sometimes you might want to know which user is currently logged in. This can be useful if you want to persist user related information in the database or if you want to send an email to the currently logged in user. You can easily get this information by calling the following methods :

    1. $login = Piwik::getCurrentUserLogin()
    2. $email = Piwik::getCurrentUserEmail()

    Télécharger

    Advanced features

    Of course there is more that you can do. For instance you can verify whether a user is an anonymous user or whether a user has a specific role. You can also perform any operation in the context of a super user even if the current user does not have this role. Would you like to know more about those features ? Check out the Piwik class reference, the Security guide and the Manage Users user guide.

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