Recherche avancée

Médias (1)

Mot : - Tags -/musée

Autres articles (41)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

Sur d’autres sites (11251)

  • video proccesing : extract frames and encrypt them then insert them back to the video in java using xuggler

    24 juillet 2015, par Anas M. Jubara

    I’m working on a video encryption application .. the main idea is to input the video file to the application and the application should output it in an encrypted form... am using xuggler library to manipulate the video and get to the frames and AES for encryption.
    my code works fine for accessing the frames and encrypting them, what i need help with is how to write the encrypted frame back to the video file to replace the original one without corrupting the video file for the video players.
    Here is my code

    package xuggler;

    import com.xuggle.mediatool.IMediaReader;
    import com.xuggle.mediatool.IMediaWriter;
    import com.xuggle.mediatool.MediaListenerAdapter;
    import com.xuggle.mediatool.ToolFactory;
    import com.xuggle.mediatool.event.IVideoPictureEvent;
    import com.xuggle.xuggler.Global;
    import com.xuggle.xuggler.ICodec;

    import java.awt.Graphics2D;
    import java.awt.Point;
    import java.awt.Transparency;
    import java.awt.image.BufferedImage;
    import java.awt.image.ColorModel;
    import java.awt.image.ComponentColorModel;
    import java.awt.image.DataBuffer;
    import java.awt.image.DataBufferByte;
    import java.awt.image.Raster;
    import java.awt.image.WritableRaster;

    import java.io.File;

    import java.security.InvalidKeyException;
    import java.security.NoSuchAlgorithmException;
    import java.security.SecureRandom;

    import java.util.concurrent.TimeUnit;
    import java.util.logging.Level;
    import java.util.logging.Logger;

    import javax.crypto.BadPaddingException;
    import javax.crypto.Cipher;
    import javax.crypto.IllegalBlockSizeException;
    import javax.crypto.KeyGenerator;
    import javax.crypto.NoSuchPaddingException;
    import javax.crypto.SecretKey;

    import javax.imageio.ImageIO;


    public class DecodeAndCaptureFrames extends MediaListenerAdapter
    {

    // The number of seconds between frames.
         public static final double SECONDS_BETWEEN_FRAMES = 5;

     //The number of micro-seconds between frames.
     public static final long MICRO_SECONDS_BETWEEN_FRAMES =(long)      (Global.DEFAULT_PTS_PER_SECOND * SECONDS_BETWEEN_FRAMES);

     // Time of last frame write
     private static long mLastPtsWrite = Global.NO_PTS;

    private static final double FRAME_RATE = 50;

    private static final int SECONDS_TO_RUN_FOR = 20;

    private static final String outputFilename = "D:\\K.mp4";

    public static IMediaWriter writer = ToolFactory.makeWriter(outputFilename);
    //receive BufferedImage and returns its byte data
       public static byte[] get_byte_data(BufferedImage image) {
       WritableRaster raster = image.getRaster();
       DataBufferByte buffer = (DataBufferByte) raster.getDataBuffer();
       return buffer.getData();
    }


    //create new_img with the attributes of image
    public static BufferedImage user_space(BufferedImage image) {
       //create new_img with the attributes of image
       BufferedImage new_img = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
       Graphics2D graphics = new_img.createGraphics();
       graphics.drawRenderedImage(image, null);
       graphics.dispose(); //release all allocated memory for this image
       return new_img;
    }

    public static BufferedImage toImage(byte[] imagebytes, int width, int height) {
       DataBuffer buffer = new DataBufferByte(imagebytes, imagebytes.length);
       WritableRaster raster = Raster.createInterleavedRaster(buffer, width, height,
          3 * width, 3, new int[]{2, 1, 0}, (Point) null);

       ColorModel cm = new ComponentColorModel(ColorModel.getRGBdefault().getColorSpace(),
               false, true, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
       return new BufferedImage(cm, raster, true, null);
    }

    public static byte[] encrypt(byte[] orgnlbytes, String key) throws NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException {
       byte[] encbytes = null;
       try {
           Cipher cipher = Cipher.getInstance("AES");
           KeyGenerator keyGen = KeyGenerator.getInstance("AES");
           SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
           // cryptograph. secure random
           random.setSeed(key.getBytes());

           keyGen.init(128, random);
           // for example
           SecretKey secretKey = keyGen.generateKey();
           try {
               cipher.init(Cipher.ENCRYPT_MODE, secretKey);
           } catch (InvalidKeyException ex) {
               Logger.getLogger(DecodeAndCaptureFrames.class.getName()).log(Level.SEVERE, null, ex);
           }
           encbytes = cipher.doFinal(orgnlbytes);
       }
       catch (NoSuchAlgorithmException ex) {
           Logger.getLogger(DecodeAndCaptureFrames.class.getName()).log(Level.SEVERE, null, ex);
       }        catch (NoSuchPaddingException ex)
       {
           System.out.print("can not encrypt buffer");
       }

       return encbytes;
    }


     /**
      * The video stream index, used to ensure we display frames from one
      * and only one video stream from the media container.
      */

     private int mVideoStreamIndex = -1;

     /**
      * Takes a media container (file) as the first argument, opens it and
      *  writes some of it's video frames to PNG image files in the
      *  temporary directory.
      *
      * @param args must contain one string which represents a filename
      */

     public static void main(String[] args)
     {
       // create a new mr. decode and capture frames


       DecodeAndCaptureFrames decodeAndCaptureFrames;
       decodeAndCaptureFrames = new DecodeAndCaptureFrames("D:\\K.mp4");
     }

     /** Construct a DecodeAndCaptureFrames which reads and captures
      * frames from a video file.
      *
      * @param filename the name of the media file to read
      */


     //makes reader to the file and read the data of it
     public DecodeAndCaptureFrames(String filename)
     {
       // create a media reader for processing video

      IMediaReader reader = ToolFactory.makeReader(filename);

    // stipulate that we want BufferedImages created in BGR 24bit color space
    reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);


    // note that DecodeAndCaptureFrames is derived from
    // MediaReader.ListenerAdapter and thus may be added as a listener
    // to the MediaReader. DecodeAndCaptureFrames implements
    // onVideoPicture().

    reader.addListener(this);

    // read out the contents of the media file, note that nothing else
    // happens here.  action happens in the onVideoPicture() method
    // which is called when complete video pictures are extracted from
    // the media source

    while (reader.readPacket() == null)
     do {} while(false);
     }

    /**
      * Called after a video frame has been decoded from a media stream.
      * Optionally a BufferedImage version of the frame may be passed
      * if the calling {@link IMediaReader} instance was configured to
      * create BufferedImages.
      *
      * This method blocks, so return quickly.
      */

     public void onVideoPicture(IVideoPictureEvent event)
     {
       try
       {
         // if the stream index does not match the selected stream index,
         // then have a closer look

     if (event.getStreamIndex() != mVideoStreamIndex)
     {
       // if the selected video stream id is not yet set, go ahead an
       // select this lucky video stream

       if (-1 == mVideoStreamIndex)
         mVideoStreamIndex = event.getStreamIndex();

       // otherwise return, no need to show frames from this video stream

       else
         return;
     }

     // if uninitialized, backdate mLastPtsWrite so we get the very
     // first frame

     if (mLastPtsWrite == Global.NO_PTS)
       mLastPtsWrite = event.getTimeStamp() - MICRO_SECONDS_BETWEEN_FRAMES;

     // if it's time to write the next frame

     if (event.getTimeStamp() - mLastPtsWrite >= MICRO_SECONDS_BETWEEN_FRAMES)
     {
       // Make a temporary file name

      // File file = File.createTempFile("frame", ".jpeg");

       // write out PNG

    //        ImageIO.write(event.getImage(), "png", file);

       BufferedImage orgnlimage = event.getImage();
           orgnlimage = user_space(orgnlimage);
           byte[] orgnlimagebytes = get_byte_data(orgnlimage);
           byte[] encryptedbytes = encrypt(orgnlimagebytes, "abc");
           BufferedImage encryptedimage = toImage(encryptedbytes, orgnlimage.getWidth(), orgnlimage.getHeight());


           ImageIO.write(encryptedimage, "png", File.createTempFile("frame", ".png"));
    //         indicate file written

       double seconds = ((double)event.getTimeStamp())
         / Global.DEFAULT_PTS_PER_SECOND;
    //        System.out.printf("at elapsed time of %6.3f seconds wrote: %s\n",seconds, file);

       // update last write time

       mLastPtsWrite += MICRO_SECONDS_BETWEEN_FRAMES;
     }
    }
    catch (Exception e)
    {
     e.printStackTrace();
    }
     }

    }
  • Problems with ffmpeg command line on android

    17 mai 2017, par user2193172

    I managed to compile the ffmpeg Static build. But when I am trying to call the ffmpeg command line I get a Java IOException : No such file or Directory.

    My code is as follows :

    public void merge_video(View view){

       if(ffmpeg_file.exists()){
             Log.d(null, "ffmpeg exists");
         }else{
             Log.d(null, "Could not locate ffmpeg in the folder");
         }

         File file1 = new File("/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_22.mp4");
         if(file1.exists()){
             Log.d(null,"File 1 exists");
         }
         File file2 = new File("/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_28.mp4");
         if(file2.exists()){
             Log.d(null,"File 2 exists");
         }

         String[] ffmpegCommand = new String[5];
         ffmpegCommand[0] = "/mnt/sdcard/com.ffmpeg_test/ffmpeg";
         ffmpegCommand[1] = "-i";
         ffmpegCommand[2] = "concat:/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_22.mp4|/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_28.mp4";
         ffmpegCommand[3] = "copy";
         ffmpegCommand[4] = "/mnt/sdcard/com.ffmpeg_test/output.mp4";  

         try {
             Process ffmpegProcess = new ProcessBuilder(ffmpegCommand).redirectErrorStream(true).start();

             String line;
             BufferedReader reader = new BufferedReader(new InputStreamReader(ffmpegProcess.getInputStream()));
             Log.d(null, "*******Starting FFMPEG");

             while((line = reader.readLine())!=null){

                 Log.d(null, "***"+line+"***");
             }
             Log.d(null,"****ending FFMPEG****");

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

    The LogCat print is as follows :

    03-27 20:41:10.522: W/System.err(24709): java.io.IOException: Error running exec(). Command: [/mnt/sdcard/com.ffmpeg_test/ffmpeg, -i, concat:/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_22.mp4|/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_28.mp4, copy, /mnt/sdcard/com.ffmpeg_test/output.mp4] Working Directory: null Environment: [ANDROID_SOCKET_zygote=13, TMPDIR=/data/local/tmp, ANDROID_BOOTLOGO=1, EXTERNAL_STORAGE=/mnt/sdcard, ANDROID_ASSETS=/system/app, PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin, ASEC_MOUNTPOINT=/mnt/asec, LOOP_MOUNTPOINT=/mnt/obb, BOOTCLASSPATH=/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar, USBHOST_STORAGE=/mnt/sdcard/usbStorage, ANDROID_DATA=/data, LD_LIBRARY_PATH=/vendor/lib:/system/lib, ANDROID_ROOT=/system, ANDROID_PROPERTY_WORKSPACE=12,32768, EXTERNAL_STORAGE2=/mnt/sdcard/external_sd]
    03-27 20:41:10.522: W/System.err(24709):    at java.lang.ProcessManager.exec(ProcessManager.java:224)
    03-27 20:41:10.522: W/System.err(24709):    at java.lang.ProcessBuilder.start(ProcessBuilder.java:202)
    03-27 20:41:10.522: W/System.err(24709):    at com.example.ffmpeg_test.MainActivity.merge_video(MainActivity.java:106)
    03-27 20:41:10.522: W/System.err(24709):    at java.lang.reflect.Method.invokeNative(Native Method)
    03-27 20:41:10.522: W/System.err(24709):    at java.lang.reflect.Method.invoke(Method.java:507)
    03-27 20:41:10.527: W/System.err(24709):    at android.view.View$1.onClick(View.java:2149)
    03-27 20:41:10.527: W/System.err(24709):    at android.view.View.performClick(View.java:2538)
    03-27 20:41:10.527: W/System.err(24709):    at android.view.View$PerformClick.run(View.java:9152)
    03-27 20:41:10.527: W/System.err(24709):    at android.os.Handler.handleCallback(Handler.java:587)
    03-27 20:41:10.527: W/System.err(24709):    at android.os.Handler.dispatchMessage(Handler.java:92)
    03-27 20:41:10.527: W/System.err(24709):    at android.os.Looper.loop(Looper.java:123)
    03-27 20:41:10.527: W/System.err(24709):    at android.app.ActivityThread.main(ActivityThread.java:3691)
    03-27 20:41:10.527: W/System.err(24709):    at java.lang.reflect.Method.invokeNative(Native Method)
    03-27 20:41:10.527: W/System.err(24709):    at java.lang.reflect.Method.invoke(Method.java:507)
    03-27 20:41:10.532: W/System.err(24709):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
    03-27 20:41:10.532: W/System.err(24709):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
    03-27 20:41:10.537: W/System.err(24709):    at dalvik.system.NativeStart.main(Native Method)
    03-27 20:41:10.537: W/System.err(24709): Caused by: java.io.IOException: No such file or directory
    03-27 20:41:10.537: W/System.err(24709):    at java.lang.ProcessManager.exec(Native Method)
    03-27 20:41:10.537: W/System.err(24709):    at java.lang.ProcessManager.exec(ProcessManager.java:222)
    03-27 20:41:10.537: W/System.err(24709):    ... 16 more
    03-27 20:41:36.057: W/KeyCharacterMap(24709): No keyboard for id 0
    03-27 20:41:36.057: W/KeyCharacterMap(24709): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
  • Why can’t I run the ffmpeg executable stored in /mnt/sdcard ?

    18 novembre 2024, par user2193172

    I managed to compile the ffmpeg Static build. But when I am trying to call the ffmpeg command line I get a Java IOException : No such file or Directory.

    



    My code is as follows :

    



    public void merge_video(View view){

    if(ffmpeg_file.exists()){
          Log.d(null, "ffmpeg exists");
      }else{
          Log.d(null, "Could not locate ffmpeg in the folder");
      }

      File file1 = new File("/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_22.mp4");
      if(file1.exists()){
          Log.d(null,"File 1 exists");
      }
      File file2 = new File("/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_28.mp4");
      if(file2.exists()){
          Log.d(null,"File 2 exists");
      }

      String[] ffmpegCommand = new String[5];
      ffmpegCommand[0] = "/mnt/sdcard/com.ffmpeg_test/ffmpeg";
      ffmpegCommand[1] = "-i";
      ffmpegCommand[2] = "concat:/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_22.mp4|/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_28.mp4";
      ffmpegCommand[3] = "copy";
      ffmpegCommand[4] = "/mnt/sdcard/com.ffmpeg_test/output.mp4";  

      try {
          Process ffmpegProcess = new ProcessBuilder(ffmpegCommand).redirectErrorStream(true).start();

          String line;
          BufferedReader reader = new BufferedReader(new InputStreamReader(ffmpegProcess.getInputStream()));
          Log.d(null, "*******Starting FFMPEG");

          while((line = reader.readLine())!=null){

              Log.d(null, "***"+line+"***"); 
          }
          Log.d(null,"****ending FFMPEG****");

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


    



    The LogCat print is as follows :

    



    03-27 20:41:10.522: W/System.err(24709): java.io.IOException: Error running exec(). Command: [/mnt/sdcard/com.ffmpeg_test/ffmpeg, -i, concat:/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_22.mp4|/mnt/sdcard/com.ffmpeg_test/VID_3_25_2013_12_28.mp4, copy, /mnt/sdcard/com.ffmpeg_test/output.mp4] Working Directory: null Environment: [ANDROID_SOCKET_zygote=13, TMPDIR=/data/local/tmp, ANDROID_BOOTLOGO=1, EXTERNAL_STORAGE=/mnt/sdcard, ANDROID_ASSETS=/system/app, PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin, ASEC_MOUNTPOINT=/mnt/asec, LOOP_MOUNTPOINT=/mnt/obb, BOOTCLASSPATH=/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar, USBHOST_STORAGE=/mnt/sdcard/usbStorage, ANDROID_DATA=/data, LD_LIBRARY_PATH=/vendor/lib:/system/lib, ANDROID_ROOT=/system, ANDROID_PROPERTY_WORKSPACE=12,32768, EXTERNAL_STORAGE2=/mnt/sdcard/external_sd]
03-27 20:41:10.522: W/System.err(24709):    at java.lang.ProcessManager.exec(ProcessManager.java:224)
03-27 20:41:10.522: W/System.err(24709):    at java.lang.ProcessBuilder.start(ProcessBuilder.java:202)
03-27 20:41:10.522: W/System.err(24709):    at com.example.ffmpeg_test.MainActivity.merge_video(MainActivity.java:106)
03-27 20:41:10.522: W/System.err(24709):    at java.lang.reflect.Method.invokeNative(Native Method)
03-27 20:41:10.522: W/System.err(24709):    at java.lang.reflect.Method.invoke(Method.java:507)
03-27 20:41:10.527: W/System.err(24709):    at android.view.View$1.onClick(View.java:2149)
03-27 20:41:10.527: W/System.err(24709):    at android.view.View.performClick(View.java:2538)
03-27 20:41:10.527: W/System.err(24709):    at android.view.View$PerformClick.run(View.java:9152)
03-27 20:41:10.527: W/System.err(24709):    at android.os.Handler.handleCallback(Handler.java:587)
03-27 20:41:10.527: W/System.err(24709):    at android.os.Handler.dispatchMessage(Handler.java:92)
03-27 20:41:10.527: W/System.err(24709):    at android.os.Looper.loop(Looper.java:123)
03-27 20:41:10.527: W/System.err(24709):    at android.app.ActivityThread.main(ActivityThread.java:3691)
03-27 20:41:10.527: W/System.err(24709):    at java.lang.reflect.Method.invokeNative(Native Method)
03-27 20:41:10.527: W/System.err(24709):    at java.lang.reflect.Method.invoke(Method.java:507)
03-27 20:41:10.532: W/System.err(24709):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
03-27 20:41:10.532: W/System.err(24709):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
03-27 20:41:10.537: W/System.err(24709):    at dalvik.system.NativeStart.main(Native Method)
03-27 20:41:10.537: W/System.err(24709): Caused by: java.io.IOException: No such file or directory
03-27 20:41:10.537: W/System.err(24709):    at java.lang.ProcessManager.exec(Native Method)
03-27 20:41:10.537: W/System.err(24709):    at java.lang.ProcessManager.exec(ProcessManager.java:222)
03-27 20:41:10.537: W/System.err(24709):    ... 16 more
03-27 20:41:36.057: W/KeyCharacterMap(24709): No keyboard for id 0
03-27 20:41:36.057: W/KeyCharacterMap(24709): Using default keymap: /system/usr/keychars/qwerty.kcm.bin