Recherche avancée

Médias (1)

Mot : - Tags -/wave

Autres articles (13)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

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

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

Sur d’autres sites (2833)

  • How to Crop the visible portion of landscape video in android ?

    30 août 2016, par Deepak
    1. I am working on Panning and cropping the landscape video using Texture View.I am in a half way that I can pan the landscape video from left to right vice versa by using this example
      https://github.com/crust87/Android-VideoCropView.

    enter image description here

    enter image description here

    1. FFMPEG can crop the particular portion of the video by using this command
      ffmpeg -i /sdcard/videokit/in.mp4 -filter:v crop=720:1088:0:0 -c:a
      copy /sdcard/videokit/out.mp4

    How can I crop only the video which is visible in Texture View and save it local storage in Android.

    crop=720:1088:0:0 is a hard coded width and height of the video and it is cropping fine.But how can I get the width and height of the visible video in Texture View to crop the visible video and Save it to the local storage in android.

    public class MainActivity extends Activity {

       // Layout Components
       private FrameLayout top_frame;

       // Attributes
       private String originalPath;
       @Override
       protected void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.check);
           top_frame = (FrameLayout)findViewById(R.id.top_frame);
       }

       @Override
       protected void onActivityResult(int requestCode, int resultCode, Intent data) {
           if (requestCode == 1000 && resultCode == RESULT_OK) {
               final VideoCropView mVideoCropView = new VideoCropView(this);
               mVideoCropView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

                   @Override
                   public void onPrepared(MediaPlayer mp) {
                       mVideoCropView.start();
                   }
               });
               top_frame.addView(mVideoCropView);
               Uri selectedVideoUri = data.getData();

               originalPath = getRealPathFromURI(selectedVideoUri);

               mVideoCropView.setVideoURI(selectedVideoUri);

               mVideoCropView.seekTo(1);
           }
       }

       public void onButtonLoadClick(View v) {
           top_frame.removeAllViews();
           Intent lIntent = new Intent(Intent.ACTION_PICK);
           lIntent.setType("video/*");
           lIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
           startActivityForResult(lIntent, 1000);
       }

       public String getRealPathFromURI(Uri contentUri) {    // getting image path from gallery.
           Cursor cursor = null;
           try {
               String[] proj = { MediaStore.Images.Media.DATA };
               cursor = getApplicationContext().getContentResolver().query(contentUri, proj, null, null, null);
               int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
               cursor.moveToFirst();
               return cursor.getString(column_index);
           } finally {
               if (cursor != null) {
                   cursor.close();
               }
           }
       }

    }

    CropVideoView

    public class VideoCropView extends TextureView implements MediaPlayerControl {
       // Constants
       private static final String LOG_TAG = "VideoCropView";
       private static final int STATE_ERROR = -1;
       private static final int STATE_IDLE = 0;
       private static final int STATE_PREPARING = 1;
       private static final int STATE_PREPARED = 2;
       private static final int STATE_PLAYING = 3;
       private static final int STATE_PAUSED = 4;
       private static final int STATE_PLAYBACK_COMPLETED = 5;

       // MediaPlayer Components
       protected Context mContext;
       private MediaPlayer mMediaPlayer;
       private Surface mSurface;
       private OnInfoListener mOnInfoListener;
       private OnCompletionListener mOCompletionListener;
       private OnErrorListener mOnErrorListener;
       private OnPreparedListener mOnPreparedListener;
       private OnTranslatePositionListener mOnTranslatePositionListener;

       // CropView Components
       private Matrix mMatrix;

       // MediaPlayer Attributes
       protected Uri mUri;
       private int mCurrentBufferPercentage;
       private int mSeekWhenPrepared;
       protected int mVideoWidth;
       protected int mVideoHeight;

       // CropView Attributes
       private float mRatioWidth;
       private float mRatioHeight;
       private float mPositionX;
       private float mPositionY;
       private float mBoundX;
       private float mBoundY;
       private int mRotate;
       private float mScaleX;
       private float mScaleY;
       private float mScale;

       // Working Variables
       private int mCurrentState = STATE_IDLE;
       private int mTargetState = STATE_IDLE;

       // Touch Event
       // past position x, y and move point
       float mPastX;
       float mPastY;
       float mTouchDistance;
       private Context context;

       // Constructors
       public VideoCropView(final Context context) {
           super(context);
           mContext = context;

           initAttributes();
           initVideoView();
       }

       public VideoCropView(final Context context, final AttributeSet attrs) {
           super(context, attrs);
           mContext = context;

           initAttributes(context, attrs, 0);
           initVideoView();
       }

       public VideoCropView(Context context, AttributeSet attrs, int defStyleAttr) {
           super(context, attrs, defStyleAttr);
           mContext = context;

           initAttributes(context, attrs, defStyleAttr);
           initVideoView();
       }

       private void initAttributes() {
           mRatioWidth = 1;
           mRatioHeight = 1;
       }

       private void initAttributes(Context context, AttributeSet attrs, int defStyleAttr) {
           TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.VideoCropView, defStyleAttr, 0);

           mRatioWidth = typedArray.getInteger(R.styleable.VideoCropView_ratio_width, 3);
           mRatioHeight = typedArray.getInteger(R.styleable.VideoCropView_ratio_height, 4);
       }

       @Override
       protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
           int heightLayout;
           int widthLayout;
           widthLayout = MeasureSpec.getSize(widthMeasureSpec);
           heightLayout = MeasureSpec.getSize(heightMeasureSpec);
           setMeasuredDimension(widthLayout, heightLayout);

           /*if(widthMeasureSpec < heightMeasureSpec){

               int width = MeasureSpec.getSize(widthMeasureSpec);
               int height = (int) ((width / mRatioWidth) * mRatioHeight);


               setMeasuredDimension(width, height);

           }else{

               int width = MeasureSpec.getSize(widthMeasureSpec);
               int height =MeasureSpec.getSize(heightMeasureSpec);
               setMeasuredDimension(width, height);

           }
    */
       }

       @Override
       public boolean onTouchEvent(MotionEvent event) {
           if(mCurrentState == STATE_ERROR || mCurrentState == STATE_IDLE || mCurrentState == STATE_PREPARING) {
               return false;
           }

           switch (event.getAction()) {
               case MotionEvent.ACTION_DOWN:
                   mPastX = event.getX();
                   mPastY = event.getY();
                   mTouchDistance = 0;
               case MotionEvent.ACTION_MOVE:
                   if(mBoundX!=0 || mBoundY!=0) {
                       float dx = event.getX() - mPastX;
                       float dy = event.getY() - mPastY;
                       updateViewPosition(dx, dy);
                       mPastX = event.getX();
                       mPastY = event.getY();
                       mTouchDistance += (Math.abs(dx) + Math.abs(dy));
                   }
                   break;
               case MotionEvent.ACTION_UP:
                   if (mTouchDistance < 25) {
                       if (isPlaying()) {
                           pause();
                       } else {
                           start();
                       }
                   }

                   mTouchDistance = 0;
                   break;
           }

           return true;
       }

       @Override
       public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
           super.onInitializeAccessibilityEvent(event);
           event.setClassName(VideoView.class.getName());
       }

       @Override
       public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
           super.onInitializeAccessibilityNodeInfo(info);
           info.setClassName(VideoView.class.getName());
       }

       public int resolveAdjustedSize(int desiredSize, int measureSpec) {
           Log.d(LOG_TAG, "Resolve called.");
           int result = desiredSize;
           int specMode = MeasureSpec.getMode(measureSpec);
           int specSize = MeasureSpec.getSize(measureSpec);

           switch (specMode) {
               case MeasureSpec.UNSPECIFIED:
               /*
                * Parent says we can be as big as we want. Just don't be larger
                * than max size imposed on ourselves.
                */
                   result = desiredSize;
                   break;

               case MeasureSpec.AT_MOST:
               /*
                * Parent says we can be as big as we want, up to specSize. Don't be
                * larger than specSize, and don't be larger than the max size
                * imposed on ourselves.
                */
                   result = Math.min(desiredSize, specSize);
                   break;

               case MeasureSpec.EXACTLY:
                   // No choice. Do what we are told.
                   result = specSize;
                   break;
           }
           return result;
       }

       public void initVideoView() {

           mVideoHeight = 0;
           mVideoWidth = 0;
           setFocusable(false);
           setSurfaceTextureListener(mSurfaceTextureListener);
           mCurrentState = STATE_IDLE;
           mTargetState = STATE_IDLE;

       }

       public void setVideoPath(String path) {
           if (path != null) {
               setVideoURI(Uri.parse(path));
           }
       }

       public void setVideoURI(Uri pVideoURI) {
           mUri = pVideoURI;
           mSeekWhenPrepared = 0;

           MediaMetadataRetriever retriever = new MediaMetadataRetriever();
           retriever.setDataSource(mContext, pVideoURI);

           // create thumbnail bitmap
           if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
               String rotation = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);

               try {
                   mRotate = Integer.parseInt(rotation);
               } catch(NumberFormatException e) {
                   mRotate = 0;
               }
           }

           retriever.release();

           openVideo();
           requestLayout();
           invalidate();
       }

       public void stopPlayback() {
           if (mMediaPlayer != null) {
               mMediaPlayer.stop();
               mMediaPlayer.release();
               mMediaPlayer = null;
               mCurrentState = STATE_IDLE;
               mTargetState = STATE_IDLE;
           }
       }

       public void openVideo() {
           if ((mUri == null) || (mSurface == null)) {
               // not ready for playback just yet, will try again later
               return;
           }
           // Tell the music playback service to pause
           // TODO: these constants need to be published somewhere in the
           // framework.
           Intent intent = new Intent("com.android.music.musicservicecommand");
           intent.putExtra("command", "pause");
           mContext.sendBroadcast(intent);

           // we shouldn't clear the target state, because somebody might have
           // called start() previously
           release(false);
           try {
               mMediaPlayer = new MediaPlayer();
               // TODO: create SubtitleController in MediaPlayer, but we need
               // a context for the subtitle renderers

               mMediaPlayer.setOnPreparedListener(mPreparedListener);
               mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
               mMediaPlayer.setOnCompletionListener(mCompletionListener);
               mMediaPlayer.setOnErrorListener(mErrorListener);
               mMediaPlayer.setOnInfoListener(mInfoListener);
               mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener);
               mCurrentBufferPercentage = 0;
               mMediaPlayer.setDataSource(mContext, mUri);
               mMediaPlayer.setSurface(mSurface);
               mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

               mMediaPlayer.setScreenOnWhilePlaying(true);
               mMediaPlayer.prepareAsync();
               mMediaPlayer.setLooping(true);
               mCurrentState = STATE_PREPARING;
           } catch (IllegalStateException e) {
               mCurrentState = STATE_ERROR;
               mTargetState = STATE_ERROR;
               e.printStackTrace();
           } catch (IOException e) {
               mCurrentState = STATE_ERROR;
               mTargetState = STATE_ERROR;
               e.printStackTrace();
           }
       }

       private OnVideoSizeChangedListener mSizeChangedListener = new OnVideoSizeChangedListener() {
           @Override
           public void onVideoSizeChanged(final MediaPlayer mp, final int width,
                                          final int height) {
               mVideoWidth = mp.getVideoWidth();
               mVideoHeight = mp.getVideoHeight();

               if (mVideoWidth != 0 && mVideoHeight != 0) {
                   requestLayout();
                   if(mVideoWidth >= mVideoHeight)
                   initVideo();
               }
           }
       };

       private OnPreparedListener mPreparedListener = new OnPreparedListener() {
           @Override
           public void onPrepared(final MediaPlayer mp) {
               mCurrentState = STATE_PREPARED;

               if (mOnPreparedListener != null) {
                   mOnPreparedListener.onPrepared(mp);
               }

               mVideoWidth = mp.getVideoWidth();
               mVideoHeight = mp.getVideoHeight();

               int seekToPosition = mSeekWhenPrepared; // mSeekWhenPrepared may be
               // changed after seekTo()
               if (seekToPosition != 0) {
                   seekTo(seekToPosition);
               }

               if ((mVideoWidth != 0) && (mVideoHeight != 0)) {
                   if(mVideoWidth >= mVideoHeight) initVideo();

                   if (mTargetState == STATE_PLAYING) {
                       start();
                   }
               } else {
                   // We don't know the video size yet, but should start anyway.
                   // The video size might be reported to us later.
                   if (mTargetState == STATE_PLAYING) {
                       start();
                   }
               }
           }
       };

       private OnCompletionListener mCompletionListener = new OnCompletionListener() {
           @Override
           public void onCompletion(final MediaPlayer mp) {
               mCurrentState = STATE_PLAYBACK_COMPLETED;
               mTargetState = STATE_PLAYBACK_COMPLETED;

               if (mOCompletionListener != null) {
                   mOCompletionListener.onCompletion(mMediaPlayer);
               }
           }
       };

       private OnInfoListener mInfoListener = new OnInfoListener() {
           public boolean onInfo(MediaPlayer mp, int arg1, int arg2) {
               if (mOnInfoListener != null) {
                   mOnInfoListener.onInfo(mp, arg1, arg2);
               }
               return true;
           }
       };

       private OnErrorListener mErrorListener = new OnErrorListener() {
           @Override
           public boolean onError(MediaPlayer mp, int framework_err, int impl_err) {
               Log.d(LOG_TAG, "Error: " + framework_err + "," + impl_err);
               mCurrentState = STATE_ERROR;
               mTargetState = STATE_ERROR;

               /* If an error handler has been supplied, use it and finish. */
               if (mOnErrorListener != null) {
                   if (mOnErrorListener.onError(mMediaPlayer, framework_err,
                           impl_err)) {
                       return true;
                   }
               }
               return true;
           }
       };

       private OnBufferingUpdateListener mBufferingUpdateListener = new OnBufferingUpdateListener() {
           @Override
           public void onBufferingUpdate(final MediaPlayer mp, final int percent) {
               mCurrentBufferPercentage = percent;
           }
       };

       public void setOnPreparedListener(OnPreparedListener listener) {
           mOnPreparedListener = listener;
       }

       public void setOnCompletionListener(OnCompletionListener listener) {
           mOCompletionListener = listener;
       }

       public void setOnErrorListener(OnErrorListener listener) {
           mOnErrorListener = listener;
       }

       public void setOnInfoListener(OnInfoListener listener) {
           mOnInfoListener = listener;
       }

       private void release(boolean cleartargetstate) {
           if (mMediaPlayer != null) {
               mMediaPlayer.reset();
               mMediaPlayer.release();
               mMediaPlayer = null;
               mCurrentState = STATE_IDLE;
               if (cleartargetstate) {
                   mTargetState = STATE_IDLE;
               }
           }
       }

       @Override
       public void start() {
           if (isInPlaybackState()) {
               mMediaPlayer.start();
               mCurrentState = STATE_PLAYING;

           }
           mTargetState = STATE_PLAYING;
       }

       @Override
       public void pause() {
           if (isInPlaybackState()) {
               if (mMediaPlayer.isPlaying()) {
                   mMediaPlayer.pause();
                   mCurrentState = STATE_PAUSED;
               }
           }

           mTargetState = STATE_PAUSED;
       }

       @Override
       public int getDuration() {
           if (isInPlaybackState()) {
               return mMediaPlayer.getDuration();
           }

           return -1;
       }

       @Override
       public int getCurrentPosition() {
           if (isInPlaybackState()) {
               return mMediaPlayer.getCurrentPosition();
           }
           return 0;
       }

       @Override
       public void seekTo(int msec) {
           if (isInPlaybackState()) {
               mMediaPlayer.seekTo(msec);
               mSeekWhenPrepared = 0;
           } else {
               mSeekWhenPrepared = msec;
           }
       }

       @Override
       public boolean isPlaying() {
           return isInPlaybackState() && mMediaPlayer.isPlaying();
       }

       @Override
       public int getBufferPercentage() {
           if (mMediaPlayer != null) {
               return mCurrentBufferPercentage;
           }
           return 0;
       }

       private boolean isInPlaybackState() {
           return (mMediaPlayer != null && mCurrentState != STATE_ERROR
                   && mCurrentState != STATE_IDLE && mCurrentState != STATE_PREPARING);
       }

       @Override
       public boolean canPause() {
           return false;
       }

       @Override
       public boolean canSeekBackward() {
           return false;
       }

       @Override
       public boolean canSeekForward() {
           return false;
       }

       @Override
       public int getAudioSessionId() {
           return -1;
       }

       SurfaceTextureListener mSurfaceTextureListener = new SurfaceTextureListener() {
           @Override
           public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
               mSurface = new Surface(surface);
               openVideo();
           }

           @Override
           public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
               boolean isValidState = (mTargetState == STATE_PLAYING);
               boolean hasValidSize = (mVideoWidth == width && mVideoHeight == height);
               if (mMediaPlayer != null && isValidState && hasValidSize) {
                   start();
               }
           }

           @Override
           public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
               if (mMediaPlayer != null) {
                   mMediaPlayer.reset();
                   mMediaPlayer.release();
                   mMediaPlayer = null;
               }

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

               return true;
           }

           @Override
           public void onSurfaceTextureUpdated(final SurfaceTexture surface) {

           }
       };

       @Override
       protected void onVisibilityChanged(View changedView, int visibility) {
           super.onVisibilityChanged(changedView, visibility);

           if (visibility == View.INVISIBLE || visibility == View.GONE) {
               if (isPlaying()) {
                   stopPlayback();
               }
           }
       }

       public float getScale() {
           return mScale;
       }

       private void initVideo() {
           try {
                   int width = getWidth();
                   int height = getHeight();
                   mScaleX = 1.0f;
                   mScaleY = 1.0f;
                   mPositionX = 0;
                   mPositionY = 0;
                   mBoundX = 0;
                   mBoundY = 0;
                   mMatrix = new Matrix();

                   mScaleX = (float) mVideoWidth / width;
                   mScaleY = (float) mVideoHeight / height;

                   mBoundX = width - mVideoWidth / mScaleY;
                   mBoundY = height - mVideoHeight / mScaleX;

                   if (mScaleX < mScaleY) {
                       mScale = mScaleX;
                       mScaleY = mScaleY * (1.0f / mScaleX);
                       mScaleX = 1.0f;
                       mBoundX = 0;
                   } else {
                       mScale = mScaleY;
                       mScaleX = mScaleX * (1.0f / mScaleY);
                       mScaleY = 1.0f;
                       mBoundY = 0;
                   }

                   mMatrix = new Matrix();
                   mMatrix.setScale(mScaleX, mScaleY);
                   setTransform(mMatrix);
           } catch (NumberFormatException e) {
               e.printStackTrace();
           }
       }

       public void updateViewPosition(float x, float y) {

           float nextX = mPositionX + x;
           float nextY = mPositionY + y;

           if(mScaleX == 1.0f) {
               x = 0;
           } else {
               if(nextX > 0) {
                   x = -mPositionX;
                   mPositionX = mPositionX + x;
               } else if(nextX < mBoundX) {
                   x = mBoundX - mPositionX;
                   mPositionX = mPositionX + x;
               } else {
                   mPositionX = nextX;
               }
           }

           if(mScaleY == 1.0f) {
               y = 0;
           } else {
               if(nextY > 0) {
                   y = -mPositionY;
                   mPositionY = mPositionY + y;
               } else if(nextY < mBoundY) {
                   y = mBoundY - mPositionY;
                   mPositionY = mPositionY + y;
               } else {
                   mPositionY = nextY;
               }
           }

           if(mOnTranslatePositionListener != null) {
               mOnTranslatePositionListener.onTranslatePosition(mPositionX, mPositionY, mPositionX * -mScale, mPositionY * -mScale);
           }

           mMatrix.postTranslate(x, y);
           setTransform(mMatrix);
           invalidate();
       }

    //  public void setOriginalRatio() {
    //      if(mVideoWidth != 0 && mVideoHeight != 0) {
    //          int gcd = gcd(mVideoWidth, mVideoHeight);
    //          setRatio(mVideoWidth / gcd, mVideoHeight / gcd);
    //      }
    //  }

       public int gcd(int n, int m) {
           while (m != 0) {
               int t = n % m;
               n = m;
               m = t;
           }

           return Math.abs(n);
       }

    //  public void setRatio(float ratioWidth, float ratioHeight) {
    //      mRatioWidth = ratioWidth;
    //      mRatioHeight = ratioHeight;
    //
    //      int seek = getCurrentPosition();
    //
    //      requestLayout();
    //      invalidate();
    //      openVideo();
    //
    //      seekTo(seek);
    //  }


       public float getRatioWidth() {
           return mRatioWidth;
       }

       public float getRatioHeight() {
           return mRatioHeight;
       }

       public float getRealPositionX() {
           return mPositionX * -mScale;
       }

       public float getRealPositionY() {
           return mPositionY * -mScale;
       }

       public int getVideoWidth() {
           return mVideoWidth;
       }

       public int getVideoHeight() {
           return mVideoHeight;
       }

       public int getRotate() {
           return mRotate;
       }

       public void setOnTranslatePositionListener(OnTranslatePositionListener pOnTranslatePositionListener) {
           mOnTranslatePositionListener = pOnTranslatePositionListener;
       }

       public void setContext(Context context) {
           this.context = context;
       }

       public interface OnTranslatePositionListener {
           public abstract void onTranslatePosition(float x, float y, float rx, float ry);
       }
    }

    FFMPEG for cropping particular portion

    ffmpeg -i /sdcard/videokit/in.mp4 -filter:v crop=720:1088:0:0 -c:a copy /sdcard/videokit/out.mp4

    public class SimpleExample extends Activity {

       String workFolder = null;
       String demoVideoFolder = null;
       String demoVideoPath = null;
       String vkLogPath = null;
       private boolean commandValidationFailedFlag = false;


       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.ffmpeg_demo_client_1);

           demoVideoFolder = Environment.getExternalStorageDirectory().getAbsolutePath() + "/videokit/";
           demoVideoPath = demoVideoFolder + "in.mp4";

           Log.i(Prefs.TAG, getString(R.string.app_name) + " version: " + GeneralUtils.getVersionName(getApplicationContext()) );
           workFolder = getApplicationContext().getFilesDir().getAbsolutePath() + "/";
           //Log.i(Prefs.TAG, "workFolder: " + workFolder);
           vkLogPath = workFolder + "vk.log";

           GeneralUtils.copyLicenseFromAssetsToSDIfNeeded(this, workFolder);
           GeneralUtils.copyDemoVideoFromAssetsToSDIfNeeded(this, demoVideoFolder);

           Button invoke =  (Button)findViewById(R.id.invokeButton);
           invoke.setOnClickListener(new OnClickListener() {
               public void onClick(View v){
                   Log.i(Prefs.TAG, "run clicked.");
                   if (GeneralUtils.checkIfFileExistAndNotEmpty(demoVideoPath)) {
                       new TranscdingBackground(SimpleExample.this).execute();
                   }
                   else {
                       Toast.makeText(getApplicationContext(), demoVideoPath + " not found", Toast.LENGTH_LONG).show();
                   }
               }
           });

           int rc = GeneralUtils.isLicenseValid(getApplicationContext(), workFolder);
           Log.i(Prefs.TAG, "License check RC: " + rc);
       }

       public class TranscdingBackground extends AsyncTask
       {

           ProgressDialog progressDialog;
           Activity _act;
           String commandStr;

           public TranscdingBackground (Activity act) {
               _act = act;
           }



           @Override
           protected void onPreExecute() {
               EditText commandText = (EditText)findViewById(R.id.CommandText);
               commandStr = commandText.getText().toString();

               progressDialog = new ProgressDialog(_act);
               progressDialog.setMessage("FFmpeg4Android Transcoding in progress...");
               progressDialog.show();

           }

           protected Integer doInBackground(String... paths) {
               Log.i(Prefs.TAG, "doInBackground started...");

               // delete previous log
               boolean isDeleted = GeneralUtils.deleteFileUtil(workFolder + "/vk.log");
               Log.i(Prefs.TAG, "vk deleted: " + isDeleted);

               PowerManager powerManager = (PowerManager)_act.getSystemService(Activity.POWER_SERVICE);
               WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "VK_LOCK");
               Log.d(Prefs.TAG, "Acquire wake lock");
               wakeLock.acquire();

               ///////////// Set Command using code (overriding the UI EditText) /////
               //commandStr = "ffmpeg -y -i /sdcard/videokit/in.mp4 -strict experimental -s 320x240 -r 30 -aspect 3:4 -ab 48000 -ac 2 -ar 22050 -vcodec mpeg4 -b 2097152 /sdcard/videokit/out.mp4";
               //String[] complexCommand = {"ffmpeg", "-y" ,"-i", "/sdcard/videokit/in.mp4","-strict","experimental","-s", "160x120","-r","25", "-vcodec", "mpeg4", "-b", "150k", "-ab","48000", "-ac", "2", "-ar", "22050", "/sdcard/videokit/out.mp4"};
               ///////////////////////////////////////////////////////////////////////


               LoadJNI vk = new LoadJNI();
               try {


                   vk.run(GeneralUtils.utilConvertToComplex(commandStr), workFolder, getApplicationContext());




                   GeneralUtils.copyFileToFolder(vkLogPath, demoVideoFolder);


               } catch (Throwable e) {
                   Log.e(Prefs.TAG, "vk run exeption.", e);
               }
               finally {
                   if (wakeLock.isHeld())
                       wakeLock.release();
                   else{
                       Log.i(Prefs.TAG, "Wake lock is already released, doing nothing");
                   }
               }
               Log.i(Prefs.TAG, "doInBackground finished");
               return Integer.valueOf(0);
           }

           protected void onProgressUpdate(Integer... progress) {
           }

           @Override
           protected void onCancelled() {
               Log.i(Prefs.TAG, "onCancelled");
               //progressDialog.dismiss();
               super.onCancelled();
           }


           @Override
           protected void onPostExecute(Integer result) {
               Log.i(Prefs.TAG, "onPostExecute");
               progressDialog.dismiss();
               super.onPostExecute(result);

               // finished Toast
               String rc = null;
               if (commandValidationFailedFlag) {
                   rc = "Command Vaidation Failed";
               }
               else {
                   rc = GeneralUtils.getReturnCodeFromLog(vkLogPath);
               }
               final String status = rc;
               SimpleExample.this.runOnUiThread(new Runnable() {
                   public void run() {
                       Toast.makeText(SimpleExample.this, status, Toast.LENGTH_LONG).show();
                       if (status.equals("Transcoding Status: Failed")) {
                           Toast.makeText(SimpleExample.this, "Check: " + vkLogPath + " for more information.", Toast.LENGTH_LONG).show();
                       }
                   }
               });
           }

       }


    }
  • HTTP Livestreaming with ffmpeg

    25 août 2016, par Hugo14453

    Some context : I have an MKV file, I am attempting to stream it to http://localhost:8090/test.flv as an flv file.

    The stream begins and then immediately ends.

    The command I am using is :

    sudo ffmpeg -re -i input.mkv -c:v libx264 -maxrate 1000k -bufsize 2000k -an -bsf:v h264_mp4toannexb -g 50 http://localhost:8090/test.flv

    A breakdown of what I believe these options do incase this post becomes useful for someone else :

    sudo

    Run as root

    ffmpeg

    The stream command thingy

    -re

    Stream in real-time

    -i input.mkv

    Input option and path to input file

    -c:v libx264

    Use codec libx264 for conversion

    -maxrate 1000k -bufsize 2000k

    No idea, some options for conversion, seems to help

    -an -bsf:v h264_mp4toannexb

    Audio options I think, not sure really. Also seems to help

    -g 50

    Still no idea, maybe frame rateframerateframerateframerate ?

    http://localhost:8090/test.flv

    Output using http protocol to localhost on port 8090 as a file called test.flv

    Anyway the actual issue I have is that it begins to stream for about a second and then immediately ends.

    The mpeg command result :

    ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers
     built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
     configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
     libavutil      55. 28.100 / 55. 28.100
     libavcodec     57. 48.101 / 57. 48.101
     libavformat    57. 41.100 / 57. 41.100
     libavdevice    57.  0.102 / 57.  0.102
     libavfilter     6. 47.100 /  6. 47.100
     libavresample   3.  0.  0 /  3.  0.  0
     libswscale      4.  1.100 /  4.  1.100
     libswresample   2.  1.100 /  2.  1.100
     libpostproc    54.  0.100 / 54.  0.100
    Input #0, matroska,webm, from 'input.mkv':
     Metadata:
       encoder         : libebml v1.3.0 + libmatroska v1.4.0
       creation_time   : 1970-01-01 00:00:02
     Duration: 00:01:32.26, start: 0.000000, bitrate: 4432 kb/s
       Stream #0:0(eng): Video: h264 (High 10), yuv420p10le, 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
       Stream #0:1(nor): Audio: flac, 48000 Hz, stereo, s16 (default)
    [libx264 @ 0x2e1c380] using SAR=1/1
    [libx264 @ 0x2e1c380] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    [libx264 @ 0x2e1c380] profile High, level 4.0
    [libx264 @ 0x2e1c380] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=50 keyint_min=5 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1000 vbv_bufsize=2000 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
    [flv @ 0x2e3f0a0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
    Output #0, flv, to 'http://localhost:8090/test.flv':
     Metadata:
       encoder         : Lavf57.41.100
       Stream #0:0(eng): Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 23.98 fps, 1k tbn, 23.98 tbc (default)
       Metadata:
         encoder         : Lavc57.48.101 libx264
       Side data:
         cpb: bitrate max/min/avg: 1000000/0/0 buffer size: 2000000 vbv_delay: -1
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
    Press [q] to stop, [?] for help
    Killed   26 fps= 26 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A speed=   0x  

    The ffserver outputs :

    Sat Aug 20 12:40:11 2016 File '/test.flv' not found
    Sat Aug 20 12:40:11 2016 [SERVER IP] - - [POST] "/test.flv HTTP/1.1" 404 189

    The config file is :

    #Sample ffserver configuration file

    # Port on which the server is listening. You must select a different
    # port from your standard HTTP web server if it is running on the same
    # computer.
    Port 8090

    # Address on which the server is bound. Only useful if you have
    # several network interfaces.
    BindAddress 0.0.0.0

    # Number of simultaneous HTTP connections that can be handled. It has
    # to be defined *before* the MaxClients parameter, since it defines the
    # MaxClients maximum limit.
    MaxHTTPConnections 2000

    # Number of simultaneous requests that can be handled. Since FFServer
    # is very fast, it is more likely that you will want to leave this high
    # and use MaxBandwidth, below.
    MaxClients 1000

    # This the maximum amount of kbit/sec that you are prepared to
    # consume when streaming to clients.
    MaxBandwidth 1000

    # Access log file (uses standard Apache log file format)
    # '-' is the standard output.
    CustomLog -

    # Suppress that if you want to launch ffserver as a daemon.
    #NoDaemon


    ##################################################################
    # Definition of the live feeds. Each live feed contains one video
    # and/or audio sequence coming from an ffmpeg encoder or another
    # ffserver. This sequence may be encoded simultaneously with several
    # codecs at several resolutions.

    <feed>

    ACL allow 192.168.0.0 192.168.255.255

    # You must use 'ffmpeg' to send a live feed to ffserver. In this
    # example, you can type:
    #
    #ffmpeg http://localhost:8090/test.ffm

    # ffserver can also do time shifting. It means that it can stream any
    # previously recorded live stream. The request should contain:
    # "http://xxxx?date=[YYYY-MM-DDT][[HH:]MM:]SS[.m...]".You must specify
    # a path where the feed is stored on disk. You also specify the
    # maximum size of the feed, where zero means unlimited. Default:
    # File=/tmp/feed_name.ffm FileMaxSize=5M
    File /tmp/feed1.ffm
    FileMaxSize 200m

    # You could specify
    # ReadOnlyFile /saved/specialvideo.ffm
    # This marks the file as readonly and it will not be deleted or updated.

    # Specify launch in order to start ffmpeg automatically.
    # First ffmpeg must be defined with an appropriate path if needed,
    # after that options can follow, but avoid adding the http:// field
    #Launch ffmpeg

    # Only allow connections from localhost to the feed.
       ACL allow 127.0.0.1

    </feed>


    ##################################################################
    # Now you can define each stream which will be generated from the
    # original audio and video stream. Each format has a filename (here
    # 'test1.mpg'). FFServer will send this stream when answering a
    # request containing this filename.

    <stream>

    # coming from live feed 'feed1'
    Feed feed1.ffm

    # Format of the stream : you can choose among:
    # mpeg       : MPEG-1 multiplexed video and audio
    # mpegvideo  : only MPEG-1 video
    # mp2        : MPEG-2 audio (use AudioCodec to select layer 2 and 3 codec)
    # ogg        : Ogg format (Vorbis audio codec)
    # rm         : RealNetworks-compatible stream. Multiplexed audio and video.
    # ra         : RealNetworks-compatible stream. Audio only.
    # mpjpeg     : Multipart JPEG (works with Netscape without any plugin)
    # jpeg       : Generate a single JPEG image.
    # asf        : ASF compatible streaming (Windows Media Player format).
    # swf        : Macromedia Flash compatible stream
    # avi        : AVI format (MPEG-4 video, MPEG audio sound)
    Format mpeg

    # Bitrate for the audio stream. Codecs usually support only a few
    # different bitrates.
    AudioBitRate 32

    # Number of audio channels: 1 = mono, 2 = stereo
    AudioChannels 2

    # Sampling frequency for audio. When using low bitrates, you should
    # lower this frequency to 22050 or 11025. The supported frequencies
    # depend on the selected audio codec.
    AudioSampleRate 44100

    # Bitrate for the video stream
    VideoBitRate 64

    # Ratecontrol buffer size
    VideoBufferSize 40

    # Number of frames per second
    VideoFrameRate 3

    # Size of the video frame: WxH (default: 160x128)
    # The following abbreviations are defined: sqcif, qcif, cif, 4cif, qqvga,
    # qvga, vga, svga, xga, uxga, qxga, sxga, qsxga, hsxga, wvga, wxga, wsxga,
    # wuxga, woxga, wqsxga, wquxga, whsxga, whuxga, cga, ega, hd480, hd720,
    # hd1080
    VideoSize hd1080

    # Transmit only intra frames (useful for low bitrates, but kills frame rate).
    #VideoIntraOnly

    # If non-intra only, an intra frame is transmitted every VideoGopSize
    # frames. Video synchronization can only begin at an intra frame.
    VideoGopSize 12

    # More MPEG-4 parameters
    # VideoHighQuality
    # Video4MotionVector

    # Choose your codecs:
    #AudioCodec mp2
    #VideoCodec mpeg1video

    # Suppress audio
    #NoAudio

    # Suppress video
    #NoVideo

    #VideoQMin 3
    #VideoQMax 31

    # Set this to the number of seconds backwards in time to start. Note that
    # most players will buffer 5-10 seconds of video, and also you need to allow
    # for a keyframe to appear in the data stream.
    #Preroll 15

    # ACL:

    # You can allow ranges of addresses (or single addresses)
    ACL ALLOW localhost

    # You can deny ranges of addresses (or single addresses)
    #ACL DENY <first address="address">

    # You can repeat the ACL allow/deny as often as you like. It is on a per
    # stream basis. The first match defines the action. If there are no matches,
    # then the default is the inverse of the last ACL statement.
    #
    # Thus 'ACL allow localhost' only allows access from localhost.
    # 'ACL deny 1.0.0.0 1.255.255.255' would deny the whole of network 1 and
    # allow everybody else.

    </first></stream>


    ##################################################################
    # Example streams


    # Multipart JPEG

    #<stream>
    #Feed feed1.ffm
    #Format mpjpeg
    #VideoFrameRate 2
    #VideoIntraOnly
    #NoAudio
    #Strict -1
    #</stream>


    # Single JPEG

    #<stream>
    #Feed feed1.ffm
    #Format jpeg
    #VideoFrameRate 2
    #VideoIntraOnly
    ##VideoSize 352x240
    #NoAudio
    #Strict -1
    #</stream>


    # Flash

    #<stream>
    #Feed feed1.ffm
    #Format swf
    #VideoFrameRate 2
    #VideoIntraOnly
    #NoAudio
    #</stream>


    # ASF compatible

    <stream>
    Feed feed1.ffm
    Format asf
    VideoFrameRate 15
    VideoSize 352x240
    VideoBitRate 256
    VideoBufferSize 40
    VideoGopSize 30
    AudioBitRate 64
    StartSendOnKey
    </stream>


    # MP3 audio

    #<stream>
    #Feed feed1.ffm
    #Format mp2
    #AudioCodec mp3
    #AudioBitRate 64
    #AudioChannels 1
    #AudioSampleRate 44100
    #NoVideo
    #</stream>


    # Ogg Vorbis audio

    #<stream>
    #Feed feed1.ffm
    #Title "Stream title"
    #AudioBitRate 64
    #AudioChannels 2
    #AudioSampleRate 44100
    #NoVideo
    #</stream>


    # Real with audio only at 32 kbits

    #<stream>
    #Feed feed1.ffm
    #Format rm
    #AudioBitRate 32
    #NoVideo
    #NoAudio
    #</stream>


    # Real with audio and video at 64 kbits

    #<stream>
    #Feed feed1.ffm
    #Format rm
    #AudioBitRate 32
    #VideoBitRate 128
    #VideoFrameRate 25
    #VideoGopSize 25
    #NoAudio
    #</stream>


    ##################################################################
    # A stream coming from a file: you only need to set the input
    # filename and optionally a new format. Supported conversions:
    #    AVI -> ASF

    #<stream>
    #File "/usr/local/httpd/htdocs/tlive.rm"
    #NoAudio
    #</stream>

    #<stream>
    #File "/usr/local/httpd/htdocs/test.asf"
    #NoAudio
    #Author "Me"
    #Copyright "Super MegaCorp"
    #Title "Test stream from disk"
    #Comment "Test comment"
    #</stream>


    ##################################################################
    # RTSP examples
    #
    # You can access this stream with the RTSP URL:
    #   rtsp://localhost:5454/test1-rtsp.mpg
    #
    # A non-standard RTSP redirector is also created. Its URL is:
    #   http://localhost:8090/test1-rtsp.rtsp

    #<stream>
    #Format rtp
    #File "/usr/local/httpd/htdocs/test1.mpg"
    #</stream>


    # Transcode an incoming live feed to another live feed,
    # using libx264 and video presets

    #<stream>
    #Format rtp
    #Feed feed1.ffm
    #VideoCodec libx264
    #VideoFrameRate 24
    #VideoBitRate 100
    #VideoSize 480x272
    #AVPresetVideo default
    #AVPresetVideo baseline
    #AVOptionVideo flags +global_header
    #
    #AudioCodec libfaac
    #AudioBitRate 32
    #AudioChannels 2
    #AudioSampleRate 22050
    #AVOptionAudio flags +global_header
    #</stream>

    ##################################################################
    # SDP/multicast examples
    #
    # If you want to send your stream in multicast, you must set the
    # multicast address with MulticastAddress. The port and the TTL can
    # also be set.
    #
    # An SDP file is automatically generated by ffserver by adding the
    # 'sdp' extension to the stream name (here
    # http://localhost:8090/test1-sdp.sdp). You should usually give this
    # file to your player to play the stream.
    #
    # The 'NoLoop' option can be used to avoid looping when the stream is
    # terminated.

    #<stream>
    #Format rtp
    #File "/usr/local/httpd/htdocs/test1.mpg"
    #MulticastAddress 224.124.0.1
    #MulticastPort 5000
    #MulticastTTL 16
    #NoLoop
    #</stream>


    ##################################################################
    # Special streams

    # Server status

    <stream>
    Format status

    # Only allow local people to get the status
    ACL allow localhost
    ACL allow 192.168.0.0 192.168.255.255

    #FaviconURL http://pond1.gladstonefamily.net:8080/favicon.ico
    </stream>


    # Redirect index.html to the appropriate site

    <redirect>
    URL http://www.ffmpeg.org/
    </redirect>


    #http://www.ffmpeg.org/

    Any help is greatly appreciated, I will do my best draw a picture of the best answer based on their username.

  • FFMPEG dumping a RTSP streaming works on Windows but not in Ubuntu

    9 août 2016, par cuentafalsa7

    I have a camera with a RTSP server. When I try to save the streaming, using FFMPEG in Windows works ; in Ubuntu, FFMPEG it doesn’t.

    The command, in Windows is :

    ffmpeg.exe -i "rtsp://192.168.1.10:1236/?videoapi=mc&amp;h264=1000-20-1280-960" -r 20 test.mp4

    In Linux :

    ffmpeg -i "rtsp://192.168.1.10:1236/?videoapi=mc&amp;h264=1000-20-1280-960" -r 20 test.mp4

    The output in Linux is :

    $ ffmpeg  -i "rtsp://192.168.1.10:1236/?videoapi=mr&amp;h264=1000-20-1280-960" -r 20 test.mp4
    ffmpeg version 2.8.6-1ubuntu2 Copyright (c) 2000-2016 the FFmpeg developers                                                                                                                                                                                                    
     built with gcc 5.3.1 (Ubuntu 5.3.1-11ubuntu1) 20160311                                                                                                                                                                                                                      
     configuration: --prefix=/usr --extra-version=1ubuntu2 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv                                                                                                                                                                                                                                            
     libavutil      54. 31.100 / 54. 31.100                                                                                                                                                                                                                                      
     libavcodec     56. 60.100 / 56. 60.100                                                                                                                                                                                                                                      
     libavformat    56. 40.101 / 56. 40.101                                                                                                                                                                                                                                      
     libavdevice    56.  4.100 / 56.  4.100                                                                                                                                                                                                                                      
     libavfilter     5. 40.101 /  5. 40.101                                                                                                                                                                                                                                      
     libavresample   2.  1.  0 /  2.  1.  0                                                                                                                                                                                                                                      
     libswscale      3.  1.101 /  3.  1.101                                                                                                                                                                                                                                      
     libswresample   1.  2.101 /  1.  2.101                                                                                                                                                                                                                                      
     libpostproc    53.  3.100 / 53.  3.100                                                                                                                                                                                                                                      
    [rtsp @ 0x1f18340] UDP timeout, retrying with TCP                                                                                                                                                                                                                              
    [rtsp @ 0x1f18340] Nonmatching transport in server reply                                                                                                                                                                                                                      
    [rtsp @ 0x1f18340] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size                                                                                                                                                                          
    Consider increasing the value for the 'analyzeduration' and 'probesize' options                                                                                                                                                                                                
    rtsp://192.168.1.10:1236/?videoapi=mr&amp;h264=1000-20-1280-960: could not find codec parameters                                                                                                                                                                                  
    Input #0, rtsp, from 'rtsp://192.168.1.10:1236/?videoapi=mr&amp;h264=1000-20-1280-960':                                                                                                                                                                                          
     Metadata:                                                                                                                                                                                                                                                                    
       title           : Unnamed                                                                                                                                                                                                                                                  
       comment         : N/A                                                                                                                                                                                                                                                      
     Duration: N/A, bitrate: N/A                                                                                                                                                                                                                                                  
       Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc                                                                                                                                                                                                                
    Output #0, mp4, to 'test.mp4':                                                                                                                                                                                                                                                
    Output file #0 does not contain any stream              

    The ffmpeg.exe output is :

    >ffmpeg.exe
    ffmpeg version N-81300-gce2217b Copyright (c) 2000-2016 the FFmpeg developers
     built with gcc 5.4.0 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-lib
    ebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfree
    type --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-lib
    openjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame
    --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-
    libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
     libavutil      55. 28.100 / 55. 28.100
     libavcodec     57. 51.100 / 57. 51.100
     libavformat    57. 46.100 / 57. 46.100
     libavdevice    57.  0.102 / 57.  0.102
     libavfilter     6. 50.100 /  6. 50.100
     libswscale      4.  1.100 /  4.  1.100
     libswresample   2.  1.100 /  2.  1.100
     libpostproc    54.  0.100 / 54.  0.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

    Use -h to get full help or, even better, run 'man ffmpeg'

    The ffmpeg output in Ubuntu is :

    $ ffmpeg
    ffmpeg version 2.8.6-1ubuntu2 Copyright (c) 2000-2016 the FFmpeg developers                                                                                                                                                                                                    
     built with gcc 5.3.1 (Ubuntu 5.3.1-11ubuntu1) 20160311                                                                                                                                                                                                                      
     configuration: --prefix=/usr --extra-version=1ubuntu2 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv                                                                                                                                                                                                                                            
     libavutil      54. 31.100 / 54. 31.100                                                                                                                                                                                                                                      
     libavcodec     56. 60.100 / 56. 60.100                                                                                                                                                                                                                                      
     libavformat    56. 40.101 / 56. 40.101                                                                                                                                                                                                                                      
     libavdevice    56.  4.100 / 56.  4.100                                                                                                                                                                                                                                      
     libavfilter     5. 40.101 /  5. 40.101                                                                                                                                                                                                                                      
     libavresample   2.  1.  0 /  2.  1.  0                                                                                                                                                                                                                                      
     libswscale      3.  1.101 /  3.  1.101                                                                                                                                                                                                                                      
     libswresample   1.  2.101 /  1.  2.101                                                                                                                                                                                                                                      
     libpostproc    53.  3.100 / 53.  3.100                                                                                                                                                                                                                                      
    Hyper fast Audio and Video encoder                                                                                                                                                                                                                                            
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...                                                                                                                                                                                        

    Use -h to get full help or, even better, run 'man ffmpeg'  

    I’m using Windows 7 64 bits and Ubuntu 16.04.

    I have tried to increase the suggested values but didn’t work either.
    Any idea, except switching to Windows ?