Recherche avancée

Médias (1)

Mot : - Tags -/école

Autres articles (38)

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

  • XMP PHP

    13 mai 2011, par

    Dixit Wikipedia, XMP signifie :
    Extensible Metadata Platform ou XMP est un format de métadonnées basé sur XML utilisé dans les applications PDF, de photographie et de graphisme. Il a été lancé par Adobe Systems en avril 2001 en étant intégré à la version 5.0 d’Adobe Acrobat.
    Étant basé sur XML, il gère un ensemble de tags dynamiques pour l’utilisation dans le cadre du Web sémantique.
    XMP permet d’enregistrer sous forme d’un document XML des informations relatives à un fichier : titre, auteur, historique (...)

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

Sur d’autres sites (6756)

  • 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 ?

    


    import subprocess

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


    


    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.

    


    When I imput the following filename into the function :

    


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


    


    I get the following error :

    


        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;

  • 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();
           }
       }
  • 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 :

    &lt;?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 !