Recherche avancée

Médias (0)

Mot : - Tags -/content

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

Autres articles (72)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Récupération d’informations sur le site maître à l’installation d’une instance

    26 novembre 2010, par

    Utilité
    Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
    Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (4591)

  • ffmpeg working fine directly on server but not from PHP webpage

    13 février 2014, par Paks

    I have manually installed ffmpeg and required packages on CentOS 5.1(Final).

    If I fire the command directly on server using putty, it converts video in required format but not able to run same command from PHP webpage using exec() function.

    I checked exec() command permission and it is fine.

    ffmpeg installation directory : /root/ffmpeg_build/
    ffmpeg file path : /root/bin/

    Please guide me what could be the problem.

  • Recording video on Android using JavaCV (Updated 2014 02 17)

    25 septembre 2014, par Fabio Bergmann

    I’m trying to record a video in Android using the JavaCV lib.
    I need to record the video in 640x360.

    I have installed everything as described in README.txt file and I followed the example as below :
    https://code.google.com/p/javacv/source/browse/samples/RecordActivity.java
    In this example, the video size is this :
    private int imageWidth = 320 ;
    private int imageHeight = 240 ;

    In my case, I need to record a video in 640x360 H.264.

    (UPDATE) I have reverted my code and kept exactly like in the example, just changing imageWidth and imageHeight to 640x360.
    Now I’m getting the video like this image :
    http://bergmann.net.br/img/screenshot_video_error.png

    Here is my code :

    import static com.googlecode.javacv.cpp.opencv_core.IPL_DEPTH_8U;

    import java.io.IOException;
    import java.nio.ShortBuffer;

    import android.app.Activity;
    import android.content.Context;
    import android.content.pm.ActivityInfo;
    import android.hardware.Camera;
    import android.hardware.Camera.PreviewCallback;
    import android.media.AudioFormat;
    import android.media.AudioRecord;
    import android.media.MediaRecorder;
    import android.os.Bundle;
    import android.os.PowerManager;
    import android.util.Log;
    import android.view.Display;
    import android.view.KeyEvent;
    import android.view.LayoutInflater;
    import android.view.SurfaceHolder;
    import android.view.SurfaceView;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.view.WindowManager;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.RelativeLayout;

    import com.autosonvideo.helpers.Helpers;
    import com.autosonvideo.logic.CameraHelpers;
    import com.googlecode.javacv.FFmpegFrameRecorder;
    import com.googlecode.javacv.cpp.opencv_core.IplImage;

    public class FFmpegRecordActivity extends Activity implements OnClickListener {

       private final static String CLASS_LABEL = "RecordActivity";
       private final static String LOG_TAG = CLASS_LABEL;

       private PowerManager.WakeLock mWakeLock;

       private String ffmpeg_link;

       long startTime = 0;
       boolean recording = false;

       private volatile FFmpegFrameRecorder recorder;

       private boolean isPreviewOn = false;

       private int sampleAudioRateInHz = 44100;
       private int imageWidth = 640;
       private int imageHeight = 480;

       private int finalImageWidth = 640;
       private int finalImageHeight = 360;

       private int frameRate = 30;

       /* audio data getting thread */
       private AudioRecord audioRecord;
       private AudioRecordRunnable audioRecordRunnable;
       private Thread audioThread;
       volatile boolean runAudioThread = true;

       /* video data getting thread */
       private Camera cameraDevice;
       private CameraView cameraView;

       private IplImage yuvIplimage = null;

       /* layout setting */
       private final int bg_screen_bx = 232;
       private final int bg_screen_by = 128;
       private final int bg_screen_width = 700;
       private final int bg_screen_height = 500;
       private final int bg_width = 1123;
       private final int bg_height = 715;
       private final int live_width = 1280;
       private final int live_height = 960;
       private int screenWidth, screenHeight;
       private Button btnRecorderControl;

       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

           setContentView(R.layout.main);

           PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
           mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
                   CLASS_LABEL);
           mWakeLock.acquire();

           initLayout();
           initRecorder();
       }

       @Override
       protected void onResume() {
           super.onResume();

           if (mWakeLock == null) {
               PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
               mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
                       CLASS_LABEL);
               mWakeLock.acquire();
           }
       }

       @Override
       protected void onPause() {
           super.onPause();

           if (mWakeLock != null) {
               mWakeLock.release();
               mWakeLock = null;
           }
       }

       @Override
       protected void onDestroy() {
           super.onDestroy();

           recording = false;

           if (cameraView != null) {
               cameraView.stopPreview();
               cameraDevice.release();
               cameraDevice = null;
           }

           if (mWakeLock != null) {
               mWakeLock.release();
               mWakeLock = null;
           }
       }

       private void initLayout() {

           /* get size of screen */
           Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
                   .getDefaultDisplay();
           screenWidth = display.getWidth();
           screenHeight = display.getHeight();
           RelativeLayout.LayoutParams layoutParam = null;
           LayoutInflater myInflate = null;
           myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
           RelativeLayout topLayout = new RelativeLayout(this);
           setContentView(topLayout);
           LinearLayout preViewLayout = (LinearLayout) myInflate.inflate(
                   R.layout.main, null);
           layoutParam = new RelativeLayout.LayoutParams(screenWidth, screenHeight);
           topLayout.addView(preViewLayout, layoutParam);

           /* add control button: start and stop */
           btnRecorderControl = (Button) findViewById(R.id.recorder_control);
           btnRecorderControl.setText("Start");
           btnRecorderControl.setOnClickListener(this);

           /* add camera view */
           int display_width_d = (int) (1.0 * bg_screen_width * screenWidth / bg_width);
           int display_height_d = (int) (1.0 * bg_screen_height * screenHeight / bg_height);
           int prev_rw, prev_rh;
           if (1.0 * display_width_d / display_height_d > 1.0 * live_width
                   / live_height) {
               prev_rh = display_height_d;
               prev_rw = (int) (1.0 * display_height_d * live_width / live_height);
           } else {
               prev_rw = display_width_d;
               prev_rh = (int) (1.0 * display_width_d * live_height / live_width);
           }
           layoutParam = new RelativeLayout.LayoutParams(prev_rw, prev_rh);
           layoutParam.topMargin = (int) (1.0 * bg_screen_by * screenHeight / bg_height);
           layoutParam.leftMargin = (int) (1.0 * bg_screen_bx * screenWidth / bg_width);

           cameraDevice = Camera.open();
           Log.i(LOG_TAG, "cameara open");
           cameraView = new CameraView(this, cameraDevice);
           topLayout.addView(cameraView, layoutParam);
           Log.i(LOG_TAG, "cameara preview start: OK");
       }

       // ---------------------------------------
       // initialize ffmpeg_recorder
       // ---------------------------------------
       private void initRecorder() {

           Log.w(LOG_TAG, "init recorder");

           if (yuvIplimage == null) {
               yuvIplimage = IplImage.create(finalImageWidth, finalImageHeight,
                       IPL_DEPTH_8U, 2);
               Log.i(LOG_TAG, "create yuvIplimage");
           }

           ffmpeg_link = CameraHelpers.getOutputMediaFile(
                   CameraHelpers.MEDIA_TYPE_VIDEO).toString();

           Log.i(LOG_TAG, "ffmpeg_url: " + ffmpeg_link);
           recorder = new FFmpegFrameRecorder(ffmpeg_link, finalImageWidth,
                   finalImageHeight, 1);
           recorder.setFormat("mp4");
           recorder.setSampleRate(sampleAudioRateInHz);
           // Set in the surface changed method
           recorder.setFrameRate(frameRate);

           Log.i(LOG_TAG, "recorder initialize success");

           audioRecordRunnable = new AudioRecordRunnable();
           audioThread = new Thread(audioRecordRunnable);
       }

       public void startRecording() {

           try {
               recorder.start();
               startTime = System.currentTimeMillis();
               recording = true;
               audioThread.start();

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

       public void stopRecording() {

           runAudioThread = false;

           if (recorder != null && recording) {
               recording = false;
               Log.v(LOG_TAG,
                       "Finishing recording, calling stop and release on recorder");
               try {
                   recorder.stop();
                   recorder.release();
               } catch (FFmpegFrameRecorder.Exception e) {
                   e.printStackTrace();
               }
               recorder = null;

           }
       }

       @Override
       public boolean onKeyDown(int keyCode, KeyEvent event) {

           if (keyCode == KeyEvent.KEYCODE_BACK) {
               if (recording) {
                   stopRecording();
               }

               finish();

               return true;
           }

           return super.onKeyDown(keyCode, event);
       }

       // ---------------------------------------------
       // audio thread, gets and encodes audio data
       // ---------------------------------------------
       class AudioRecordRunnable implements Runnable {

           @Override
           public void run() {
               android.os.Process
                       .setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);

               // Audio
               int bufferSize;
               short[] audioData;
               int bufferReadResult;

               bufferSize = AudioRecord
                       .getMinBufferSize(sampleAudioRateInHz,
                               AudioFormat.CHANNEL_IN_MONO,
                               AudioFormat.ENCODING_PCM_16BIT);
               audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
                       sampleAudioRateInHz, AudioFormat.CHANNEL_IN_MONO,
                       AudioFormat.ENCODING_PCM_16BIT, bufferSize);

               audioData = new short[bufferSize];

               Log.d(LOG_TAG, "audioRecord.startRecording()");
               audioRecord.startRecording();

               /* ffmpeg_audio encoding loop */
               while (runAudioThread) {
                   // Log.v(LOG_TAG,"recording? " + recording);
                   bufferReadResult = audioRecord.read(audioData, 0,
                           audioData.length);
                   if (bufferReadResult > 0) {
                       Log.v(LOG_TAG, "bufferReadResult: " + bufferReadResult);
                       // If "recording" isn't true when start this thread, it
                       // never get's set according to this if statement...!!!
                       // Why? Good question...
                       if (recording) {
                           try {
                               recorder.record(ShortBuffer.wrap(audioData, 0,
                                       bufferReadResult));
                               // Log.v(LOG_TAG,"recording " + 1024*i + " to " +
                               // 1024*i+1024);
                           } catch (FFmpegFrameRecorder.Exception e) {
                               Log.v(LOG_TAG, e.getMessage());
                               e.printStackTrace();
                           }
                       }
                   }
               }
               Log.v(LOG_TAG, "AudioThread Finished, release audioRecord");

               /* encoding finish, release recorder */
               if (audioRecord != null) {
                   audioRecord.stop();
                   audioRecord.release();
                   audioRecord = null;
                   Log.v(LOG_TAG, "audioRecord released");
               }
           }
       }

       // ---------------------------------------------
       // camera thread, gets and encodes video data
       // ---------------------------------------------
       class CameraView extends SurfaceView implements SurfaceHolder.Callback,
               PreviewCallback {

           private SurfaceHolder mHolder;
           private Camera mCamera;

           public CameraView(Context context, Camera camera) {
               super(context);
               Log.w("camera", "camera view");
               mCamera = camera;
               mHolder = getHolder();
               mHolder.addCallback(CameraView.this);
               mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
               mCamera.setPreviewCallback(CameraView.this);
           }

           @Override
           public void surfaceCreated(SurfaceHolder holder) {
               try {
                   stopPreview();
                   mCamera.setPreviewDisplay(holder);
               } catch (IOException exception) {
                   mCamera.release();
                   mCamera = null;
               }
           }

           public void surfaceChanged(SurfaceHolder holder, int format, int width,
                   int height) {
               Log.v(LOG_TAG, "Setting imageWidth: " + imageWidth
                       + " imageHeight: " + imageHeight + " frameRate: "
                       + frameRate);
               Camera.Parameters camParams = mCamera.getParameters();
               camParams.setPreviewSize(imageWidth, imageHeight);

               Log.v(LOG_TAG,
                       "Preview Framerate: " + camParams.getPreviewFrameRate());

               camParams.setPreviewFrameRate(frameRate);
               mCamera.setParameters(camParams);
               startPreview();
           }

           @Override
           public void surfaceDestroyed(SurfaceHolder holder) {
               try {
                   mHolder.addCallback(null);
                   mCamera.setPreviewCallback(null);
               } catch (RuntimeException e) {
                   // The camera has probably just been released, ignore.
               }
           }

           public void startPreview() {
               if (!isPreviewOn && mCamera != null) {
                   isPreviewOn = true;
                   mCamera.startPreview();
               }
           }

           public void stopPreview() {
               if (isPreviewOn && mCamera != null) {
                   isPreviewOn = false;
                   mCamera.stopPreview();
               }
           }

           @Override
           public void onPreviewFrame(byte[] data, Camera camera) {
               /* get video data */
               if (yuvIplimage != null && recording) {
                   // yuvIplimage.getByteBuffer().put(data);

                   final int startY = 640 * (480 - 360) / 2;
                   final int lenY = 640 * 360;
                   yuvIplimage.getByteBuffer().put(data, startY, lenY);
                   final int startVU = 640 * 480 + 320 * 2 * (240 - 180) / 2;
                   final int lenVU = 320 * 180 * 2;
                   yuvIplimage.getByteBuffer().put(data, startVU, lenVU);

                   Log.v(LOG_TAG, "Writing Frame");
                   try {
                       long t = 1000 * (System.currentTimeMillis() - startTime);
                       if (t > recorder.getTimestamp()) {
                           recorder.setTimestamp(t);
                       }
                       recorder.record(yuvIplimage);
                   } catch (FFmpegFrameRecorder.Exception e) {
                       Log.v(LOG_TAG, e.getMessage());
                       e.printStackTrace();
                   }
               }
           }
       }

       @Override
       public void onClick(View v) {
           if (!recording) {
               startRecording();
               Log.w(LOG_TAG, "Start Button Pushed");
               btnRecorderControl.setText("Stop");
           } else {
               // This will trigger the audio recording loop to stop and then set
               // isRecorderStart = false;
               stopRecording();
               Log.w(LOG_TAG, "Stop Button Pushed");
               btnRecorderControl.setText("Start");
           }
       }
    }
  • a lot of GREEN Color at YUV420p —> RGB in OpenGL 2.0 Shader on iOS

    25 octobre 2012, par 이형근

    I want to make a movie player for iOS using ffmpeg and OpenGL ES 2.0
    but I have some problem. Output RGB image has a lot of GREEN color.
    This is code and images

    • 480x320 width & height :
    • 512x512 Texture width & height

    I got a YUV420p row data from ffmpeg AVFrame.

       for (int i = 0, nDataLen = 0; i < 3; i++) {
           int nShift = (i == 0) ? 0 : 1;
           uint8_t *pYUVData = (uint8_t *)_frame->data[i];
           for (int j = 0; j < (mHeight >> nShift); j++) {
               memcpy(&pData->pOutBuffer[nDataLen], pYUVData, (mWidth >> nShift));
               pYUVData += _frame->linesize[i];
               nDataLen += (mWidth >> nShift);
           }
       }

    and prepare texture for Y, U & V channel.

    //: U Texture
       if (sampler1Texture) glDeleteTextures(1, &sampler1Texture);

       glActiveTexture(GL_TEXTURE1);
       glGenTextures(1, &sampler1Texture);
       glBindTexture(GL_TEXTURE_2D, sampler1Texture);

       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
       // This is necessary for non-power-of-two textures
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
       glEnable(GL_TEXTURE_2D);

       glTexImage2D(GL_TEXTURE_2D,
                    0,
                    GL_LUMINANCE,
                    texW / 2,
                    texH / 2,
                    0,
                    GL_LUMINANCE,
                    GL_UNSIGNED_BYTE,
                    NULL);

       //: V Texture
       if (sampler2Texture) glDeleteTextures(1, &sampler2Texture);

       glActiveTexture(GL_TEXTURE2);
       glGenTextures(1, &sampler2Texture);
       glBindTexture(GL_TEXTURE_2D, sampler2Texture);

       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
       // This is necessary for non-power-of-two textures
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
       glEnable(GL_TEXTURE_2D);

       glTexImage2D(GL_TEXTURE_2D,
                    0,
                    GL_LUMINANCE,
                    texW / 2,
                    texH / 2,
                    0,
                    GL_LUMINANCE,
                    GL_UNSIGNED_BYTE,
                    NULL);

       //: Y Texture
       if (sampler0Texture) glDeleteTextures(1, &sampler0Texture);

       glActiveTexture(GL_TEXTURE0);
       glGenTextures(1, &sampler0Texture);
       glBindTexture(GL_TEXTURE_2D, sampler0Texture);

       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
       // This is necessary for non-power-of-two textures
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
       glEnable(GL_TEXTURE_2D);

       glTexImage2D(GL_TEXTURE_2D,
                    0,
                    GL_LUMINANCE,
                    texW,
                    texH,
                    0,
                    GL_LUMINANCE,
                    GL_UNSIGNED_BYTE,
                    NULL);

    Rendering part is below.

    int _idxU = mFrameW * mFrameH;
    int _idxV = _idxU + (_idxU / 4);

    // U data
    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, sampler1Texture);
    glUniform1i(sampler1Uniform, 1);

    glTexSubImage2D(
                   GL_TEXTURE_2D,
                   0,
                   0,
                   0,
                   mFrameW / 2,            // source width
                   mFrameH / 2,            // source height
                   GL_LUMINANCE,
                   GL_UNSIGNED_BYTE,
                   &_frameData[_idxU]);

    // V data
    glActiveTexture(GL_TEXTURE2);
    glBindTexture(GL_TEXTURE_2D, sampler2Texture);
    glUniform1i(sampler2Texture, 2);

    glTexSubImage2D(
                   GL_TEXTURE_2D,
                   0,
                   0,
                   0,
                   mFrameW / 2,            // source width
                   mFrameH / 2,            // source height
                   GL_LUMINANCE,
                   GL_UNSIGNED_BYTE,
                   &_frameData[_idxV]);

    // Y data
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, sampler0Texture);
    glUniform1i(sampler0Uniform, 0);

    glTexSubImage2D(
                   GL_TEXTURE_2D,
                   0,
                   0,
                   0,
                   mFrameW,            // source width
                   mFrameH,            // source height
                   GL_LUMINANCE,
                   GL_UNSIGNED_BYTE,
                   _frameData);

    Vertex Shader & Fragment Shader is below.

    attribute vec4 Position;
    attribute vec2 TexCoordIn;

    varying vec2 TexCoordOut;
    varying vec2 TexCoordOut_UV;

    uniform mat4 Projection;
    uniform mat4 Modelview;

    void main()
    {
       gl_Position = Projection * Modelview * Position;
       TexCoordOut = TexCoordIn;
    }



    uniform sampler2D sampler0; // Y Texture Sampler
    uniform sampler2D sampler1; // U Texture Sampler
    uniform sampler2D sampler2; // V Texture Sampler

    varying highp vec2 TexCoordOut;

    void main()
    {
       highp float y = texture2D(sampler0, TexCoordOut).r;
       highp float u = texture2D(sampler2, TexCoordOut).r - 0.5;
       highp float v = texture2D(sampler1, TexCoordOut).r - 0.5;

       //y = 0.0;
       //u = 0.0;
       //v = 0.0;

       highp float r = y + 1.13983 * v;
       highp float g = y - 0.39465 * u - 0.58060 * v;
       highp float b = y + 2.03211 * u;

       gl_FragColor = vec4(r, g, b, 1.0);
    }

    Y Texture (Grayscale) is correct but U & V has a lot of Green Color.
    So final RGB image (Y+U+V) has a lot of GREEN Color.
    What's the problem ?

    Please help.
    thanks.