Recherche avancée

Médias (91)

Autres articles (111)

  • Taille des images et des logos définissables

    9 février 2011, par

    Dans beaucoup d’endroits du site, logos et images sont redimensionnées pour correspondre aux emplacements définis par les thèmes. L’ensemble des ces tailles pouvant changer d’un thème à un autre peuvent être définies directement dans le thème et éviter ainsi à l’utilisateur de devoir les configurer manuellement après avoir changé l’apparence de son site.
    Ces tailles d’images sont également disponibles dans la configuration spécifique de MediaSPIP Core. La taille maximale du logo du site en pixels, on permet (...)

  • Script d’installation automatique de MediaSPIP

    25 avril 2011, par

    Afin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
    Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
    La documentation de l’utilisation du script d’installation (...)

  • Ajouter des informations spécifiques aux utilisateurs et autres modifications de comportement liées aux auteurs

    12 avril 2011, par

    La manière la plus simple d’ajouter des informations aux auteurs est d’installer le plugin Inscription3. Il permet également de modifier certains comportements liés aux utilisateurs (référez-vous à sa documentation pour plus d’informations).
    Il est également possible d’ajouter des champs aux auteurs en installant les plugins champs extras 2 et Interface pour champs extras.

Sur d’autres sites (4870)

  • Progress Bar findviewbyid returns null

    1er avril 2017, par ziad kiwan

    Help me please it’s getting frustrating !

    i’m doing a chat application where i’m adding views to a linear layout programmatically each time a user press the send button the code is below :

    public  void appendToMessageHistory(String id,String uname, String messa,String messageType, final String filepath, String DownloadStatus,boolean internet,int type) {


       //TextView tv=new TextView(Messaging.this);
       LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(Width, LinearLayout.LayoutParams.WRAP_CONTENT);
       lp.setMargins(0, 10, 0, 0);

       View v = getLayoutInflater().inflate(R.layout.message_entity, null);


       TextView mess;
       TextView time;
       final ImageView iv;
       final ProgressBar progressBar;
       ImageView statusiv;
       if (friend.userName.equals(uname)) {
           v = getLayoutInflater().inflate(R.layout.message_entity, null);
           v.setId(Integer.parseInt(id));
           mess = (TextView) v.findViewById(R.id.message_entity_message);
           time = (TextView) v.findViewById(R.id.message_entity_time);
           iv = (ImageView) v.findViewById(R.id.message_entity_imageview);
           statusiv = (ImageView) v.findViewById(R.id.imageView);
           progressBar = (ProgressBar) v.findViewById(R.id.message_entity_progressbar);
       } else {
           v = getLayoutInflater().inflate(R.layout.message_entity_right, null);
           lp.gravity = Gravity.RIGHT;
           v.setId(Integer.parseInt(id));
           mess = (TextView) v.findViewById(R.id.message_entity_right_message);
           time = (TextView) v.findViewById(R.id.message_entity_right_time);
           iv = (ImageView) v.findViewById(R.id.message_entity_right_imageview);
           statusiv = (ImageView)v.findViewById(R.id.imageViewleft);
           progressBar = (ProgressBar) v.findViewById(R.id.message_entity_Right_progressbar);
       }

       try {
           progressBar.setId(Integer.parseInt(id));

       } catch (Exception e) {
           e.printStackTrace();
       }

       if (messageType != null) {
           if (messageType.equals(MessageInfo.MESSAGE_TYPE_PIC)) {
               iv.setImageBitmap(ImageHandlet.GetBitmapFromPath(filepath));
               progressBar.setVisibility(View.GONE);
               iv.setOnClickListener(new OnClickListener() {
                   @Override
                   public void onClick(View v) {
                       Intent intent = new Intent();
                       intent.setAction(Intent.ACTION_VIEW);
                       intent.setDataAndType(Uri.parse("file://" + filepath), "image/png");
                       startActivity(intent);
                       Log.d("FIlePAth", filepath);
                   }
               });

           } else if (messageType.equals(MessageInfo.MESSAGE_TYPE_VIDEO)) {
               if (DownloadStatus.equals(LocalStorageHandler.DOWNLOADED)) {
                   if(!(friend.userName.equals(uname))) {
                       if (type != 3) {
                           Bitmap bitTh = ThumbnailUtils.createVideoThumbnail(filepath, MediaStore.Images.Thumbnails.MINI_KIND);
                           iv.setImageBitmap(bitTh);
                           progressBar.setVisibility(View.GONE);
                           iv.setOnClickListener(new OnClickListener() {
                               @Override
                               public void onClick(View v) {
                                   Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(filepath));
                                   intent.setDataAndType(Uri.parse(filepath), "video/mp4");
                                   startActivity(intent);

                               }
                           });
                       } else {
                           Log.w("Zipping","Progress Bar");
                           progressBar.setVisibility(View.VISIBLE);
                       }
                   } else {
                       Bitmap bitTh = ThumbnailUtils.createVideoThumbnail(filepath, MediaStore.Images.Thumbnails.MINI_KIND);
                       iv.setImageBitmap(bitTh);
                       progressBar.setVisibility(View.GONE);
                       iv.setOnClickListener(new OnClickListener() {
                           @Override
                           public void onClick(View v) {
                               Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(filepath));
                               intent.setDataAndType(Uri.parse(filepath), "video/mp4");
                               startActivity(intent);

                           }
                       });
                   }
               } else if (DownloadStatus.equals(LocalStorageHandler.NotDOWNLOADED)) {
                   iv.setTag(id);
                   iv.setImageResource(R.drawable.download);
                   iv.setOnClickListener(new OnClickListener() {
                       @Override
                       public void onClick(View v) {
                           progressBar.setVisibility(View.VISIBLE);
                           Cursor c = localstoragehandler.getIDnfo(iv.getTag().toString());
                           String filepath = "";
                           //Toast.makeText(getApplication(),iv.getTag().toString()+" iD " +iv.getId(),Toast.LENGTH_SHORT).show();

                           while (c.moveToNext()) {
                               String msg0 = c.getString(0);
                               String msg2 = c.getString(2);
                               String msg3 = c.getString(3);
                               String msg4 = c.getString(4);
                               String msg5 = c.getString(5);
                               String msg6 = c.getString(6);

                               filepath = msg5;

                               Log.d("-----------Vedio-----", "------------------");
                               Log.d("DATABASE---------", msg0);
                               Log.d("DATABASE-------", msg2);
                               Log.d("DATABASE---------", msg3);
                               Log.d("DATABASE-----", msg4 + "");
                               Log.d("DATABASE-------", msg5 + "");
                               Log.d("DATABASE----------", msg6 + "");
                               Log.d("--------END-------", "-------END-----------");


                           }

                           Toast.makeText(getApplicationContext(), filepath.toString() + iv.getTag().toString(), Toast.LENGTH_SHORT).show();

                           DownloadFileFromURL downloadFileFromURL = new DownloadFileFromURL(filepath, iv.getTag().toString());
                           downloadFileFromURL.execute("");
                       }
                   });
               }
           } else {
               iv.setVisibility(View.GONE);
               progressBar.setVisibility(View.GONE);
           }
       }
       if(!(messageType.equals(MessageInfo.MESSAGE_TYPE_VIDEO))) {
           if (!internet) {
               statusiv.setImageResource(R.drawable.noconnectionl);
           }
       }
       mess.setText(messa);
       //time.setText(sendt);
       v.setLayoutParams(lp);
       final View lastview = v;
       runOnUiThread(new Runnable() {
           @Override
           public void run() {
               mEssageBox.addView(lastview);

           }
       });
       scrollView.post(new Runnable() {
           @Override
           public void run() {
               scrollView.fullScroll(View.FOCUS_DOWN);
               messageText.requestFocus();
           }
       });
    }

    and here is the XML of the dialogbox :

    <?xml version="1.0" encoding="utf-8"?>
    <relativelayout>

    <imageview></imageview>

    <relativelayout>


       <textview></textview>

       <textview></textview>


       <imageview></imageview>

       <progressbar style="?android:attr/progressBarStyleLarge"></progressbar>


    </relativelayout>
    </relativelayout>

    And here is the code to send the video message :

    final String message = messageText.getText().toString();
       final Long rowid = localstoragehandler.insert(imService.getUsername(), friend.userName, message, MessageInfo.MESSAGE_TYPE_VIDEO, ZippedVideoPath, LocalStorageHandler.DOWNLOADED); //insert data into db and get to chat_id
       appendToMessageHistory(rowid + "", imService.getUsername(), message, MessageInfo.MESSAGE_TYPE_VIDEO, ZippedVideoPath, LocalStorageHandler.DOWNLOADED, internet,3);// append the video with type 3 to just display the progress
       messageText.setText("Video");
       String newstr = null;
       // intialize the asynctask to upload the video
       class UploadVideo extends AsyncTask {
           ProgressDialog uploading;
           View V;
           UploadVideo(View v){
               V = v;
           }

           @Override
           protected void onPreExecute() {
               super.onPreExecute();
               //          uploading = ProgressDialog.show(Messaging.this, "Uploading File", "Please wait...", false, false);
           }

           @Override
           protected String doInBackground(Void... params) {
               return imService.sendVideoMessage(imService.getUsername(), friend.userName, message, MessageInfo.MESSAGE_TYPE_VIDEO, "", ZippedVideoPath);
           }

           @Override
           protected void onPostExecute(String s) {
               super.onPostExecute(s);
            //   RelativeLayout v = (RelativeLayout) V.findViewById(rowid.intValue());
           //    Log.w("Zipping",v.toString());
        //       ProgressBar progressBar1 = (ProgressBar) V.findViewById(R.id.message_entity_Right_progressbar);
         //      Log.w("Zipping",progressBar1.toString());
               //          ImageView iv = (ImageView) v.findViewById(R.id.message_entity_right_imageview);
          //     progressBar1.setVisibility(View.GONE);
           //  Log.d("POST Execute", s + "");

               //textViewResponse.setText(Html.fromHtml("<b>Uploaded at <a href="http://stackoverflow.com/feeds/tag/&#034; + s + &#034;">" + s + "</a></b>"));
               //textViewResponse.setMovementMethod(LinkMovementMethod.getInstance());
       // here i am preparing the path so when the compress is done to save into.
           }
       }
       if (null != absolute &amp;&amp; absolute.length() > 0) {
           int endIndex = absolute.lastIndexOf("/");
           if (endIndex != -1) {
               newstr = absolute.substring(endIndex, absolute.length()); // not forgot to put check if(endIndex != -1)
           }
       }
       Log.w("Zipping", newstr);
       final File videosdir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/videos/");
       if (!videosdir.exists()) {
           videosdir.mkdirs();
       }
       ZippedVideoPath = videosdir.getAbsolutePath() + "/" + newstr;
       Log.w("Zipping", ZippedVideoPath);
       // here i got the ffmpeg library from the net to compress the video and i'm preparing the commands
       String[] complexCommand = {"-y", "-i", absolute, "-strict", "experimental", "-r", "25", "-vcodec", "mpeg4", "-b:a", "150k", "-ab", "48000", "-ac", "2", "-ar", "22050", ZippedVideoPath};
       FFmpeg ffmpeg = FFmpeg.getInstance(getBaseContext());
       try {
           // to execute "ffmpeg -version" command you just need to pass "-version"
           ffmpeg.execute(complexCommand, new ExecuteBinaryResponseHandler() {

               @Override
               public void onStart() {
                   Log.w("Zipping", "started");
               }

               @Override
               public void onProgress(String message) {
               }

               @Override
               public void onFailure(String message) {
                   Log.w("Zipping", message);
               }

               @Override
               public void onSuccess(String message1) {
                   Log.w("Zipping","Success");
                   RelativeLayout v = (RelativeLayout) mEssageBox.findViewById(rowid.intValue());
                   Log.w("VideoView",v.toString());
                   ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.message_entity_Right_progressbar);
                   ImageView iv = (ImageView) v.findViewById(R.id.message_entity_right_imageview);
               //  progressBar.setVisibility(View.GONE);
                   Bitmap bitTh = ThumbnailUtils.createVideoThumbnail(ZippedVideoPath, MediaStore.Images.Thumbnails.MINI_KIND);
                   iv.setImageBitmap(bitTh);
                   progressBar.setVisibility(View.GONE);
                   iv.setOnClickListener(new OnClickListener() {
                       @Override
                       public void onClick(View v) {
                           Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(ZippedVideoPath));
                           intent.setDataAndType(Uri.parse(ZippedVideoPath), "video/mp4");
                           startActivity(intent);

                       }
                   });
                   UploadVideo uv = new UploadVideo(v);
                   uv.execute();
               }

               @Override
               public void onFinish() {
               }
           });
       } catch (FFmpegCommandAlreadyRunningException e) {
           Log.w("Zipping", e.toString());
       }
    }

    okay now to the problem when i call the findviewbyid for the progress bar in sendvideomessage ffmpeg onsuccess callback it returns null even though the findviewbyid for the the imageview which is in the same layout it returns the view ! so please tell me what is the problem

    public void onSuccess(String message1) {
                   Log.w("Zipping","Success");
                   RelativeLayout v = (RelativeLayout) mEssageBox.findViewById(rowid.intValue()); ;
                   ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.message_entity_Right_progressbar); // this keeps returning null!
                   ImageView iv = (ImageView) v.findViewById(R.id.message_entity_right_imageview); // returns the view
               //  progressBar.setVisibility(View.GONE);
                   Bitmap bitTh = ThumbnailUtils.createVideoThumbnail(ZippedVideoPath, MediaStore.Images.Thumbnails.MINI_KIND);
                   iv.setImageBitmap(bitTh);
                   progressBar.setVisibility(View.GONE);
                   iv.setOnClickListener(new OnClickListener() {
                       @Override
                       public void onClick(View v) {
                           Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(ZippedVideoPath));
                           intent.setDataAndType(Uri.parse(ZippedVideoPath), "video/mp4");
                           startActivity(intent);

                       }
                   });
                   UploadVideo uv = new UploadVideo(v);
                   uv.execute();
               }

    Thank you !

  • Why process output reader returns null data ? When same code in other process works correct

    26 août 2019, par Владимир Водов

    I try to get output from ffmpeg process but cant get output.
    In another processes and commands it works correctly but output returns immideately when start !

           using (var process = new Process())
           {
               process.StartInfo = new ProcessStartInfo()
               {
                   FileName = LinkHelper.IPFS_PATH,
                   Arguments = cmd,
                   UseShellExecute = false,
                   CreateNoWindow = true,
                   RedirectStandardOutput = true
               };

               process.ErrorDataReceived += FfmpegErrorRecieved;
               process.Start();

               using (StreamReader reader = process.StandardOutput)
               {
                   string output = await reader.ReadToEndAsync();
                   Console.WriteLine(output);
               }              
               process.WaitForExit();
           }

    Before output handle !

    Update :
    As szatmary said ffmpeg use output error instead standard output, so when you initialize process.StandartInfo don’t forget initialize property "RedirectStandardError" to TRUE !

    Here is correct code :

    private async Task DetectFFmpegCamerasAsync()
       {
           var cmd = "-list_devices true -f dshow -i dummy";
           using (var process = new Process())
           {
               process.StartInfo = new ProcessStartInfo()
               {
                   FileName = LinkHelper.FFMPEG_PATH,
                   Arguments = cmd,
                   UseShellExecute = false,
                   CreateNoWindow = true,
                   RedirectStandardError = true
               };

               process.Start();

               using (StreamReader reader = process.StandardError)
               {
                   string output = await reader.ReadToEndAsync();
                   Console.WriteLine($"Camera detection output: \n {output}");
               }              
               process.WaitForExit();
           }
       }
  • subprocess.py returns a File Not Found error

    7 avril 2021, par wasneeplus

    As part of a video analysis script I wanted to find the duration of a video file. For this I found the script offered in the first answer to this question : How to get the duration of a video in Python ?

    &#xA;

    import subprocess&#xA;&#xA;def get_length(filename):&#xA;    result = subprocess.run(["ffprobe", "-v", "error", "-show_entries",&#xA;                             "format=duration", "-of",&#xA;                             "default=noprint_wrappers=1:nokey=1", filename],&#xA;        stdout=subprocess.PIPE,&#xA;        stderr=subprocess.STDOUT)&#xA;    return float(result.stdout)&#xA;

    &#xA;

    This code works fine when my friend runs it in a Jupyter server environment, but when I try it on my laptop the trouble starts.

    &#xA;

    When I imput the following filename into the function :

    &#xA;

    filename = "C:\\Users\\benja\\OneDrive - De Haagse Hogeschool\\Onderzoeken 3\\8V.mp4"&#xA;

    &#xA;

    I get the following error :

    &#xA;

        Traceback (most recent call last):&#xA;  File "c:/Users/benja/OneDrive - De Haagse Hogeschool/Onderzoeken 3/python_script.py", line 9, in <module>&#xA;    num_of_frames = math.floor((pf.get_length(filename) - 1)) * 30&#xA;  File "c:\Users\benja\OneDrive - De Haagse Hogeschool\Onderzoeken 3\python_funcs.py", line 21, in get_length&#xA;    stderr=subprocess.STDOUT)&#xA;  File "C:\Users\benja\Anaconda3\lib\subprocess.py", line 466, in run&#xA;    with Popen(*popenargs, **kwargs) as process:&#xA;  File "C:\Users\benja\Anaconda3\lib\subprocess.py", line 769, in __init__&#xA;    restore_signals, start_new_session)&#xA;  File "C:\Users\benja\Anaconda3\lib\subprocess.py", line 1172, in _execute_child&#xA;    startupinfo)&#xA;FileNotFoundError: [WinError 2] Het systeem kan het opgegeven bestand niet vinden&#xA;</module>

    &#xA;

    I do realise that my problem is almost identical to that of several other questions on here. However, their solutions don't seem to work for me. I have tried to :

    &#xA;

      &#xA;
    • Add the location of ffmpeg-win64-4.2.2.exe to the Path system variable.
    • &#xA;

    • Add the location of python.exe to the ComSpec system variable.
    • &#xA;

    • Put the videofile in the same directory as the script.
    • &#xA;

    &#xA;

    I would be most grateful if someone could point me in the right direction. Thank you in advance.

    &#xA;