Recherche avancée

Médias (1)

Mot : - Tags -/Rennes

Autres articles (58)

  • Encodage et transformation en formats lisibles sur Internet

    10 avril 2011

    MediaSPIP transforme et ré-encode les documents mis en ligne afin de les rendre lisibles sur Internet et automatiquement utilisables sans intervention du créateur de contenu.
    Les vidéos sont automatiquement encodées dans les formats supportés par HTML5 : MP4, Ogv et WebM. La version "MP4" est également utilisée pour le lecteur flash de secours nécessaire aux anciens navigateurs.
    Les documents audios sont également ré-encodés dans les deux formats utilisables par HTML5 :MP3 et Ogg. La version "MP3" (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

Sur d’autres sites (8987)

  • Converting DVD image with subtitles to MKV using avconv

    16 janvier 2016, par Carlos Eugenio Thompson Pinzón

    This is the procedure I know to convert a DVD image to another videoformat (v.g. MP4) :

    1. concatenate the VTS_01_n.VOB files inside VIDEO_TS folder (for n >= 0) into a single VOB file.
    2. use avconv or ffmpeg in order to convert that VOB into another format.

    So far so good, however now I want to convert the DVD image with the subtitles. As far as I know the MKV format supports subtitles, so it seems an obvious choice. Alternatively I might use any other format with hard subtitles (subtitles as part of the video image).

    However, the subtitle encoding in the DVD image is dvdsub and I get the following error

    Only SUBTITLE_ASS type supported.
    Subtitle encoding failed

    However, when running avconv -codecs I get :

    ...
    DES    dvdsub          DVD subtitles
    ...

    And the -c:s copy switch, while it prevents the command to fail, it does not seem to produce a subtitle that the player can understand.

    So, how can I create ass subtitles from dvdsub using avconv ?

    My VOB file has eight subtitle channels and two audio channels. The Ubuntu video app does not show any subtitles, and only the first audio channel seems to be working, do the DVD image might be broken.

    Another file, for a double-layer DVD, displays the Subtitle encoding error, however when using the -c:s copy switch it further displays :

    Application provided invalid, non monotonically increasing dts to muxer in stream 2: 49 >= 49
    av_interleaved_write_frame(): Invalid argument

    Thank you in advance for any ideas on how to solve these problems.

    (I am using Ubuntu where ffmpeg is an alias for avconv. I know it is possible to install the real ffmpeg but so far I have not done so.)


    update : commands and console outputs :

    commands

    cat VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB VTS_01_4.VOB VTS_01_5.VOB > ~/temp/mymovie.VOB
    cd ~/temp
    avconv -i mymovie.VOB

    output

    avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
     built on Mar 30 2013 22:20:06 with gcc 4.7.2
    [mpeg @ 0x1a64d40] max_analyze_duration reached
    Input #0, mpeg, from 'mymovie.VOB':
     Duration: 00:00:01.95, start: 0.280633, bitrate: -2147483 kb/s
       Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 7500 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
       Stream #0.1[0x20]: Subtitle: dvdsub
       Stream #0.2[0x21]: Subtitle: dvdsub
       Stream #0.3[0x22]: Subtitle: dvdsub
       Stream #0.4[0x23]: Subtitle: dvdsub
       Stream #0.5[0x24]: Subtitle: dvdsub
       Stream #0.6[0x25]: Subtitle: dvdsub
       Stream #0.7[0x26]: Subtitle: dvdsub
       Stream #0.8[0x27]: Subtitle: dvdsub
       Stream #0.9[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
       Stream #0.10[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    At least one output file must be specified

    command

    avconv -i mymovie.VOB mymovie.mkv

    output

    avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
     built on Mar 30 2013 22:20:06 with gcc 4.7.2
    [mpeg @ 0x1cdad40] max_analyze_duration reached
    Input #0, mpeg, from 'mymovie.VOB':
     Duration: 00:00:01.95, start: 0.280633, bitrate: -2147483 kb/s
       Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 7500 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
       Stream #0.1[0x20]: Subtitle: dvdsub
       Stream #0.2[0x21]: Subtitle: dvdsub
       Stream #0.3[0x22]: Subtitle: dvdsub
       Stream #0.4[0x23]: Subtitle: dvdsub
       Stream #0.5[0x24]: Subtitle: dvdsub
       Stream #0.6[0x25]: Subtitle: dvdsub
       Stream #0.7[0x26]: Subtitle: dvdsub
       Stream #0.8[0x27]: Subtitle: dvdsub
       Stream #0.9[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
       Stream #0.10[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    File 'mymovie.mkv' already exists. Overwrite ? [y/N] y
    [buffer @ 0x1ce23c0] w:720 h:480 pixfmt:yuv420p
    Output #0, matroska, to 'mymovie.mkv':
     Metadata:
       encoder         : Lavf53.21.1
       Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 29.97 tbc
       Stream #0.1: Audio: libvorbis, 48000 Hz, 5.1, s16
       Stream #0.2: Subtitle: ass, 200 kb/s
    Stream mapping:
     Stream #0:0 -> #0:0 (mpeg2video -> mpeg4)
     Stream #0:9 -> #0:1 (ac3 -> libvorbis)
     Stream #0:1 -> #0:2 (dvdsub -> ass)
    Press ctrl-c to stop encoding
    [ass @ 0x1ce0140] Only SUBTITLE_ASS type supported.
    Subtitle encoding failed

    command

    avconv -i mymovie.VOB -c:s copy mymovie.mkv

    output omitted.

    command

    avconv -i mymovie.mkv

    output

    avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
     built on Mar 30 2013 22:20:06 with gcc 4.7.2
    [matroska,webm @ 0xbc1d40] Estimating duration from bitrate, this may be inaccurate
    Input #0, matroska,webm, from 'mymovie.mkv':
     Metadata:
       ENCODER         : Lavf53.21.1
     Duration: 01:05:09.47, start: 0.000000, bitrate: N/A
       Stream #0.0: Video: mpeg4 (Simple Profile), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 29.97 fps, 29.97 tbr, 1k tbn, 30k tbc (default)
       Stream #0.1: Audio: vorbis, 48000 Hz, 5.1, s16 (default)
       Stream #0.2: Subtitle: dvdsub (default)
    At least one output file must be specified

    Now, for the double-layer :
    commands

    cat VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB VTS_01_4.VOB VTS_01_5.VOB VTS_01_6.VOB VTS_01_7.VOB VTS_01_8.VOB > ~/temp/mylongmovie.VOB
    cd ~/temp
    avconv -i mylongmovie.VOB mylongmovie.mkv

    output

    avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
     built on Mar 30 2013 22:20:06 with gcc 4.7.2
    [mpeg @ 0x13c2d40] max_analyze_duration reached
    Input #0, mpeg, from 'Cosmos-0203.VOB':
     Duration: 00:00:30.24, start: 0.280633, bitrate: 2103365 kb/s
       Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 8000 kb/s, 27.46 fps, 59.94 tbr, 90k tbn, 59.94 tbc
       Stream #0.1[0x20]: Subtitle: dvdsub
       Stream #0.2[0x21]: Subtitle: dvdsub
       Stream #0.3[0x22]: Subtitle: dvdsub
       Stream #0.4[0x23]: Subtitle: dvdsub
       Stream #0.5[0x24]: Subtitle: dvdsub
       Stream #0.6[0x25]: Subtitle: dvdsub
       Stream #0.7[0x26]: Subtitle: dvdsub
       Stream #0.8[0x27]: Subtitle: dvdsub
       Stream #0.9[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
       Stream #0.10[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    File 'mylongmovie.mkv' already exists. Overwrite ? [y/N] y
    [buffer @ 0x13ca3c0] w:720 h:480 pixfmt:yuv420p
    Output #0, matroska, to 'mylongmovie.mkv':
     Metadata:
       encoder         : Lavf53.21.1
       Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 59.94 tbc
       Stream #0.1: Audio: libvorbis, 48000 Hz, 5.1, s16
       Stream #0.2: Subtitle: ass, 200 kb/s
    Stream mapping:
     Stream #0:0 -> #0:0 (mpeg2video -> mpeg4)
     Stream #0:9 -> #0:1 (ac3 -> libvorbis)
     Stream #0:1 -> #0:2 (dvdsub -> ass)
    Press ctrl-c to stop encoding
    [ass @ 0x13d19c0] Only SUBTITLE_ASS type supported.
    Subtitle encoding failed

    command

    avconv -i mylongmovie.VOB -c:s copy mylongmovie.mkv

    output

    avconv version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
     built on Mar 30 2013 22:20:06 with gcc 4.7.2
    [mpeg @ 0xce1d40] max_analyze_duration reached
    Input #0, mpeg, from 'mylongmovie.VOB':
     Duration: 00:00:30.24, start: 0.280633, bitrate: 2103365 kb/s
       Stream #0.0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [PAR 8:9 DAR 4:3], 8000 kb/s, 27.46 fps, 59.94 tbr, 90k tbn, 59.94 tbc
       Stream #0.1[0x20]: Subtitle: dvdsub
       Stream #0.2[0x21]: Subtitle: dvdsub
       Stream #0.3[0x22]: Subtitle: dvdsub
       Stream #0.4[0x23]: Subtitle: dvdsub
       Stream #0.5[0x24]: Subtitle: dvdsub
       Stream #0.6[0x25]: Subtitle: dvdsub
       Stream #0.7[0x26]: Subtitle: dvdsub
       Stream #0.8[0x27]: Subtitle: dvdsub
       Stream #0.9[0x81]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
       Stream #0.10[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
    File 'mylongmovie.mkv' already exists. Overwrite ? [y/N] y
    [buffer @ 0xce93c0] w:720 h:480 pixfmt:yuv420p
    Output #0, matroska, to 'mylongmovie.mkv':
     Metadata:
       encoder         : Lavf53.21.1
       Stream #0.0: Video: mpeg4, yuv420p, 720x480 [PAR 8:9 DAR 4:3], q=2-31, 200 kb/s, 1k tbn, 59.94 tbc
       Stream #0.1: Audio: libvorbis, 48000 Hz, 5.1, s16
       Stream #0.2: Subtitle: dvdsub
    Stream mapping:
     Stream #0:0 -> #0:0 (mpeg2video -> mpeg4)
     Stream #0:9 -> #0:1 (ac3 -> libvorbis)
     Stream #0:1 -> #0:2 (copy)
    Press ctrl-c to stop encoding
    [matroska @ 0xce4b40] Application provided invalid, non monotonically increasing dts to muxer in stream 2: 49 >= 49
    av_interleaved_write_frame(): Invalid argument
  • Android FFmpegPlayer Streaming Service onClick notification

    8 octobre 2013, par agony

    I have a MainActivity class that displays the list of streams available for my project and the StreamingActivity class where the streaming is done.

    If the user selected an item from the list it will start the StreamingActivity and start playing the stream.
    I'm having trouble to continue streaming music when the user pressed the notification and returning it to the StreamingActivity class if the user pressed or clicked the home menu or when the app goes to onDestroy().

    I'm using FFmpegPlayer for my project 'coz it requires to play mms :// live streams for local FM station.

    Here's my code :

    public class StreamingActivity extends BaseActivity  implements ActionBar.TabListener,
    PlayerControlListener, IMediaPlayerServiceClient {


    private StatefulMediaPlayer mMediaPlayer;
    private FFmpegService mService;
    private boolean mBound;

    public static final String TAG = "StationActivity";

    private static Bundle mSavedInstanceState;

    private static PlayerFragment mPlayerFragment;
    private static DJListFragment mDjListFragment;

    private SectionsPagerAdapter mSectionsPagerAdapter;
    private ViewPager mViewPager;

    private String stream = "";
    private String fhz = "";
    private String page = "0";

    private Dialog shareDialog;
       private ProgressDialog dialog;

    private boolean isStreaming;


    /*************************************************************************************************************/

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

       Bundle bundle = getIntent().getExtras();
       if(bundle !=null){
           fhz = bundle.getString("fhz");
           stream = bundle.getString("stream");
       }

       Log.d(TAG, "page: " + page + " fhz: " + fhz + " stream: " + stream + " isStreaming: " + isStreaming);

       getSupportActionBar().setTitle("Radio \n" + fhz);
       getSupportActionBar().setDisplayHomeAsUpEnabled(true);
       getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

       mPlayerFragment = (PlayerFragment) Fragment.instantiate(this, PlayerFragment.class.getName(), null);
       mDjListFragment = (DJListFragment) Fragment.instantiate(this, DJListFragment.class.getName(), null);

       mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

       mViewPager = (ViewPager) findViewById(R.id.pager);
       mViewPager.setAdapter(mSectionsPagerAdapter);
       mViewPager.setCurrentItem(Integer.parseInt(page));

       mSavedInstanceState = savedInstanceState;

       Tab playingTab = getSupportActionBar().newTab();
       playingTab.setText(getString(R.string.playing_label));
       playingTab.setTabListener(this);

       Tab djTab = getSupportActionBar().newTab();
       djTab.setText(getString(R.string.dj_label));
       djTab.setTabListener(this);

       getSupportActionBar().addTab(playingTab);
       getSupportActionBar().addTab(djTab);

       // When swiping between different sections, select the corresponding
       // tab. We can also use ActionBar.Tab#select() to do this if we have
       // a reference to the Tab.
       mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
           @Override
           public void onPageSelected(int position) {
               StationActivity.this.getSupportActionBar().setSelectedNavigationItem(position);
           }
       });

       if (mSavedInstanceState != null) {
           getSupportActionBar().setSelectedNavigationItem(mSavedInstanceState.getInt("tab", 0));
       }

       dialog = new ProgressDialog(this);

       bindToService();

       UriBean.getInstance().setStream(stream);
       Log.d(TAG ,"stream: " + UriBean.getInstance().getStream());

    }

    /********************************************************************************************************/

    public class SectionsPagerAdapter extends FragmentPagerAdapter {
       public SectionsPagerAdapter(FragmentManager fm) {
           super(fm);
       }

       @Override
       public Fragment getItem(int position) {
           if (position == 0) {
               return mPlayerFragment;
           } else {
               return mDjListFragment;
           }
       }

       @Override
       public int getCount() {
           return 2;
       }
    }

    @Override
    public void onTabSelected(Tab tab, FragmentTransaction ft) {
       // When the given tab is selected, switch to the corresponding page in the ViewPager.
       mViewPager.setCurrentItem(tab.getPosition());
    }

    @Override
    public void onTabUnselected(Tab tab, FragmentTransaction ft) { }

    @Override
    public void onTabReselected(Tab tab, FragmentTransaction ft) { }

    /********************************************************************************************************/

    public void showLoadingDialog() {
       dialog.setMessage("Buffering...");
       dialog.show();
    }

    public void dismissLoadingDialog() {
       dialog.dismiss();
    }

    /********************************************************************************************************/

    /**
    * Binds to the instance of MediaPlayerService. If no instance of MediaPlayerService exists, it first starts
    * a new instance of the service.
    */
    public void bindToService() {
       Intent intent = new Intent(this, FFmpegService.class);

       if (Util.isFFmpegServiceRunning(getApplicationContext())){
           // Bind to Service
           Log.i(TAG, "bindService");
           bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
       } else {
           //start service and bind to it
           Log.i(TAG, "startService & bindService");
           startService(intent);
           bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
       }
    }


    /**
    * Defines callbacks for service binding, passed to bindService()
    */
    private ServiceConnection mConnection = new ServiceConnection() {
       @Override
       public void onServiceConnected(ComponentName className, IBinder serviceBinder) {
           Log.d(TAG,"service connected");

           //bound with Service. get Service instance
           MediaPlayerBinder binder = (FFmpegService.MediaPlayerBinder) serviceBinder;
           mService = binder.getService();

           //send this instance to the service, so it can make callbacks on this instance as a client
           mService.setClient(StationActivity.this);
           mBound = true;

           Log.d(TAG, "isPlaying === SERVICE: " + mService.isPlaying());

           //if

           startStreaming();
       }

       @Override
       public void onServiceDisconnected(ComponentName arg0) {
           mBound = false;
           mService = null;
       }
    };

    /********************************************************************************************************/

    @Override
    public void onPlayerPlayStop() {
       Log.d(TAG, "onPlayerPlayStop");

       Log.v(TAG, "isStreaming: " + isStreaming);
       Log.v(TAG, "mBound:  " + mBound);

       if (mBound) {
           Log.d(TAG, "bound.............");
           mMediaPlayer = mService.getMediaPlayer();
           //pressed pause ->pause
           if (!PlayerFragment.play.isChecked()) {
               if (mMediaPlayer.isStarted()) {
                   Log.d(TAG, "pause");
                   mService.pauseMediaPlayer();
               }
           } else { //pressed play
               // STOPPED, CREATED, EMPTY, -> initialize
               if (mMediaPlayer.isStopped() || mMediaPlayer.isCreated() || mMediaPlayer.isEmpty()) {
                   startStreaming();
               } else if (mMediaPlayer.isPrepared() || mMediaPlayer.isPaused()) { //prepared, paused -> resume play
                   Log.d(TAG, "start");
                   mService.startMediaPlayer();
               }
           }

           Log.d(TAG, "isPlaying === SERVICE: " + mService.isPlaying());
       }
    }

    /********************************************************************************************************/

    @Override
    public void onDownload() {
       Toast.makeText(this, "Not yet available...", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onComment() {
       FragmentManager fm = getSupportFragmentManager();
       DialogFragment newFragment = MyAlertDialogFragment.newInstance();
       newFragment.show(fm, "comment_dialog");
    }

    @Override
    public void onShare() {
       showShareDialog();
    }

    /********************************************************************************************************/

    private void startStreaming() {
       Log.d(TAG, "@startLoading");
       boolean isNetworkFound = Util.checkConnectivity(getApplicationContext());
       if(isNetworkFound) {
           Log.d(TAG, "network found");
           mService.initializePlayer(stream);
           isStreaming = true;
       } else {
           Toast.makeText(getApplicationContext(), "No internet connection found...", Toast.LENGTH_SHORT).show();
       }

       Log.d(TAG, "isStreaming: " + isStreaming);
       Log.d(TAG, "isPlaying === SERVICE: " + mService.isPlaying());
    }

    @Override
    public void onInitializePlayerStart() {
       showLoadingDialog();
    }

    @Override
    public void onInitializePlayerSuccess() {
       dismissLoadingDialog();
       PlayerFragment.play.setChecked(true);


       Log.d(TAG, "isPlaying === SERVICE: " + mService.isPlaying());
    }

    @Override
    public void onError() {
       Toast.makeText(getApplicationContext(), "Not connected to the server...", Toast.LENGTH_SHORT).show();
    }

       @Override
    public void onDestroy() {
       Log.d(TAG, "onDestroy");
       super.onDestroy();
       uiHelper.onDestroy();

       Log.d(TAG, "isPlaying === SERVICE: " + mService.isPlaying());
       if (mBound) {
           mService.unRegister();
           unbindService(mConnection);
           mBound = false;
       }

       Log.d(TAG, "service: " + Util.isFFmpegServiceRunning(getApplicationContext()));
    }

    @Override
    public void onStop(){
       Log.d(TAG, "onStop");
       super.onStop();
    }

    /*******************************************************************************************************/

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
       int itemId = item.getItemId();
       switch (itemId){
       case android.R.id.home:
           onBackPressed();
           break;
       default:
           break;
       }    
       return true;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
       Log.d(TAG, "@onKeyDown");
       if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0){
           //this.moveTaskToBack(true);
           onBackPressed();
           return true;
       }
       return super.onKeyDown(keyCode, event);
    }
    }






    public class FFmpegService  extends Service implements IMediaPlayerThreadClient {

    private FFmpegPlayerThread mMediaPlayerThread       = new FFmpegPlayerThread(this);
    private final Binder mBinder                        = new MediaPlayerBinder();
    private IMediaPlayerServiceClient mClient;
    //private StreamStation mCurrentStation;

    private boolean mIsSupposedToBePlaying = false;

    private boolean isPausedInCall = false;
    private PhoneStateListener phoneStateListener;
    private TelephonyManager telephonyManager;

    @Override
    public void onCreate(){
       mMediaPlayerThread.start();
    }

    /**
    * A class for clients binding to this service. The client will be passed an object of this class
    * via its onServiceConnected(ComponentName, IBinder) callback.
    */
    public class MediaPlayerBinder extends Binder {
       /**
        * Returns the instance of this service for a client to make method calls on it.
        * @return the instance of this service.
        */
       public FFmpegService getService() {
           return FFmpegService.this;
       }
    }

    /**
    * Returns the contained StatefulMediaPlayer
    * @return
    */
    public StatefulMediaPlayer getMediaPlayer() {
       return mMediaPlayerThread.getMediaPlayer();
    }

    public boolean isPlaying() {
       return mIsSupposedToBePlaying;
    }

    @Override
    public IBinder onBind(Intent arg0) {
       return mBinder;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

       telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
       phoneStateListener = new PhoneStateListener() {
           @Override
           public void onCallStateChanged(int state, String incomingNumber) {
               // String stateString = "N/A";
               Log.v("FFmpegService", "Starting CallStateChange");
               switch (state) {
               case TelephonyManager.CALL_STATE_OFFHOOK:
               case TelephonyManager.CALL_STATE_RINGING:
                   if (mMediaPlayerThread != null) {
                       pauseMediaPlayer();
                       isPausedInCall = true;
                   }
                   break;
               case TelephonyManager.CALL_STATE_IDLE:
                   // Phone idle. Start playing.
                   if (mMediaPlayerThread != null) {
                       if (isPausedInCall) {
                           isPausedInCall = false;
                           startMediaPlayer();
                       }
                   }
                   break;
               }
           }
       };

       // Register the listener with the telephony manager
       telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);

       return START_STICKY;
    }

    /**
    * Sets the client using this service.
    * @param client The client of this service, which implements the IMediaPlayerServiceClient interface
    */
    public void setClient(IMediaPlayerServiceClient client) {
       this.mClient = client;
    }


    public void initializePlayer(final String station) {
       //mCurrentStation = station;
       mMediaPlayerThread.initializePlayer(station);
    }

    public void startMediaPlayer() {

       Intent notificationIntent = new Intent(getApplicationContext(), StreamingActivity.class);
       //notificationIntent.putExtra("page", "0");
       //notificationIntent.putExtra("isPlaying", isPlaying());
       notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
       PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0 , notificationIntent , PendingIntent.FLAG_UPDATE_CURRENT);

       NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
               .setSmallIcon(R.drawable.ic_launcher)
               .setContentTitle("You are listening to Radio...")
               .setContentText("test!!!")
               .setContentIntent(contentIntent);

       startForeground(1, mBuilder.build());

       NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
       notificationManager.notify(1, mBuilder.build());

       mIsSupposedToBePlaying = true;
       mMediaPlayerThread.startMediaPlayer();
    }

    public void dismissNotification(Context context) {
       String ns = Context.NOTIFICATION_SERVICE;
       NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
       mNotificationManager.cancel(1);
    }

    /**
    * Pauses playback
    */
    public void pauseMediaPlayer() {
       Log.d("MediaPlayerService","pauseMediaPlayer() called");
       mMediaPlayerThread.pauseMediaPlayer();
       stopForeground(true);
       mIsSupposedToBePlaying = false;
       dismissNotification(this);
    }
    /**
    * Stops playback
    */
    public void stopMediaPlayer() {
       stopForeground(true);
       mMediaPlayerThread.stopMediaPlayer();

       mIsSupposedToBePlaying = false;
       dismissNotification(this);
    }

    public void resetMediaPlayer() {
       mIsSupposedToBePlaying = false;
       stopForeground(true);
       mMediaPlayerThread.resetMediaPlayer();
       dismissNotification(this);
    }

    @Override
    public void onError() {
       mIsSupposedToBePlaying = false;
       mClient.onError();
       dismissNotification(this);
    }

    @Override
    public void onInitializePlayerStart() {
       mClient.onInitializePlayerStart();
    }

    @Override
    public void onInitializePlayerSuccess() {
       startMediaPlayer();
       mClient.onInitializePlayerSuccess();
       mIsSupposedToBePlaying = true;
    }

    public void unRegister() {
       this.mClient = null;
       mIsSupposedToBePlaying = false;
       dismissNotification(this);
    }

    }

    Hoping someone can help me here...

  • encoding XDCAM MXF with FFMPEG

    9 octobre 2013, par magingax

    Trying to encode XDCAM HD422 MXF with FFMPEG
    But can't know specific setting for encoder/format/mux
    Anyone can show me sample code or give some advice for that ?