Recherche avancée

Médias (0)

Mot : - Tags -/auteurs

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

Autres articles (39)

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer 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

  • Contribute to documentation

    13 avril 2011

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

Sur d’autres sites (6552)

  • MediaPlayer within TextureView not working as intended

    15 mars 2016, par Russiee

    I’ve put in a MediaPlayer within a TextureView, which itself is located inside a ListView.

    Yesterday, the MediaPlayer worked as intended with a test .mp4 clip.
    Today, the MediaPlayer tries doing some kind of FFmpeg Extractor, for which i’ve been unable to find any kind of information about.

    This is the stack trace :

    03-14 13:43:00.076 477-16532/? V/FFmpegExtractor: SniffFFMPEG
    03-14 13:43:00.076 477-16532/? I/FFmpegExtractor: android-source:0xafcff040
    03-14 13:43:00.077 477-16532/? D/FFMPEG: android source begin open
    03-14 13:43:00.077 477-16532/? D/FFMPEG: android open, url: android-source:0xafcff040
    03-14 13:43:00.077 477-16532/? D/FFMPEG: ffmpeg open android data source success, source ptr: 0xafcff040
    03-14 13:43:00.077 477-16532/? D/FFMPEG: android source open success
    03-14 13:43:00.149 477-16532/? I/FFMPEG: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'android-source:0xafcff040':
    03-14 13:43:00.149 477-16532/? I/FFMPEG:   Metadata:
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     major_brand     : qt  
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     minor_version   : 0
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     compatible_brands: qt  
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     creation_time   : 2016-03-13 19:24:58
    03-14 13:43:00.149 477-16532/? I/FFMPEG:   Duration: 00:00:10.88, start: 0.000000, bitrate: 11209 kb/s
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     Stream #0:0(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 86 kb/s (default)
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     Metadata:
    03-14 13:43:00.149 477-16532/? I/FFMPEG:       creation_time   : 2016-03-13 19:24:58
    03-14 13:43:00.149 477-16532/? I/FFMPEG:       handler_name    : Core Media Data Handler
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 11113 kb/s, 29.98 fps, 29.97 tbr, 600 tbn, 50 tbc (default)
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     Metadata:
    03-14 13:43:00.149 477-16532/? I/FFMPEG:       creation_time   : 2016-03-13 19:24:58
    03-14 13:43:00.149 477-16532/? I/FFMPEG:       handler_name    : Core Media Data Handler
    03-14 13:43:00.149 477-16532/? I/FFMPEG:       encoder         : H.264
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     Stream #0:2(und): Data: none (mebx / 0x7862656D), 1 kb/s (default)
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     Metadata:
    03-14 13:43:00.149 477-16532/? I/FFMPEG:       creation_time   : 2016-03-13 19:24:58
    03-14 13:43:00.149 477-16532/? I/FFMPEG:       handler_name    : Core Media Data Handler
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)
    03-14 13:43:00.149 477-16532/? I/FFMPEG:     Metadata:
    03-14 13:43:00.149 477-16532/? I/FFMPEG:       creation_time   : 2016-03-13 19:24:58
    03-14 13:43:00.149 477-16532/? I/FFMPEG:       handler_name    : Core Media Data Handler
    03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: FFmpegExtrator, url: android-source:0xafcff040, format_name: mov,mp4,m4a,3gp,3g2,mj2, format_long_name: QuickTime / MOV
    03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: list the formats suppoted by ffmpeg:
    03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: ========================================
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[00]: mpeg
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[01]: mpegts
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[02]: mov,mp4,m4a,3gp,3g2,mj2
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[03]: matroska,webm
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[04]: asf
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[05]: rm
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[06]: flv
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[07]: swf
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[08]: avi
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[09]: ape
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[10]: dts
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[11]: flac
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[12]: ac3
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[13]: wav
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[14]: ogg
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[15]: vc1
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: format_names[16]: hevc
    03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: ========================================
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: major_brand tag is:qt  
    03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: [mp4]format is mov, confidence should be larger than mpeg4
    03-14 13:43:00.149 477-16532/? D/FFMPEG: android source close
    03-14 13:43:00.149 477-16532/? I/FFmpegExtractor: sniff through BetterSniffFFMPEG success
    03-14 13:43:00.149 477-16532/? D/FFmpegExtractor: ffmpeg detected media content as 'video/mp4' with confidence 0.41
    03-14 13:43:00.149 477-16532/? I/MediaExtractor: Use extended extractor for the special mime(video/mp4) or codec
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: FFmpegExtractor::FFmpegExtractor
    03-14 13:43:00.149 477-16532/? V/FFmpegExtractor: mFilename: android-source:0xafcff040
    03-14 13:43:00.150 477-16532/? D/FFMPEG: android source begin open
    03-14 13:43:00.150 477-16532/? D/FFMPEG: android open, url: android-source:0xafcff040
    03-14 13:43:00.150 477-16532/? D/FFMPEG: ffmpeg open android data source success, source ptr: 0xafcff040
    03-14 13:43:00.150 477-16532/? D/FFMPEG: android source open success
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: file startTime: 0
    03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: the duration is 00:00:10.87
    03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: stream_index: 0
    03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: support the codec(aac)
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: Tag mp4a/0x6134706d with codec(aac)
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: audio stream extradata(2):
    03-14 13:43:00.230 477-16532/? V/codec_utils: AAC
    03-14 13:43:00.230 477-16532/? V/codec_utils: aac profile: 1, sf_index: 4, channel: 1
    03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: bit_rate: 86249, sample_rate: 44100, channels: 1, bits_per_coded_sample: 16, block_align:0
    03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: the time is 00:00:10.93
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: audio startTime:0
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: create a audio track
    03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: stream_index: 1
    03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: support the codec(h264)
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: Tag avc1/0x31637661 with codec(h264)
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: video stream extradata:
    03-14 13:43:00.230 477-16532/? V/codec_utils: AVC
    03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: width: 1920, height: 1080, bit_rate: 11113682
    03-14 13:43:00.230 477-16532/? I/FFmpegExtractor: the time is 00:00:10.87
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: video startTime:0
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: create a video track
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: the stream is AVC, the length of a NAL unit: 4
    03-14 13:43:00.230 477-16532/? V/FFmpegExtractor: Starting reader thread
    03-14 13:43:00.230 477-16532/? D/FFmpegExtractor: Reader thread started
    03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: mProbePkts: 0, mEOF: 0, pb->error(if has): 0, mDefersToCreateVideoTrack: 0, mDefersToCreateAudioTrack: 0
    03-14 13:43:00.231 477-16532/? D/FFmpegExtractor: supported mime: video/mp4
    03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: FFmpegExtractor::getMetaData
    03-14 13:43:00.231 477-16537/? V/FFmpegExtractor: FFmpegExtractor enter thread(readerEntry)
    03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: FFmpegExtractor::getTrack[0]
    03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: FFmpegExtractor::getTrackMetaData[0]
    03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: FFmpegExtractor::getTrack[1]
    03-14 13:43:00.231 477-16532/? V/FFmpegExtractor: FFmpegExtractor::getTrackMetaData[1]
    03-14 13:43:00.232 10973-10973/com.hobbyte.touringandroid E/MediaPlayer: Should have subtitle controller already set

    Upon trying to play the video file, I get this log :

    03-14 13:52:06.133 743-821/system_process W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client
    03-14 13:52:06.133 477-477/? D/NuPlayerDriver: start(0xb0f05040)
    03-14 13:52:06.133 477-16531/? I/GenericSource: start
    03-14 13:52:06.133 477-16531/? V/FFmpegExtractor: FFmpegExtractor::Track::start audio
    03-14 13:52:06.133 477-16531/? V/FFmpegExtractor: FFmpegExtractor::Track::start video
    03-14 13:52:06.133 477-16532/? V/FFmpegExtractor: read audio flush pkt
    03-14 13:52:06.133 477-16532/? V/FFmpegExtractor: read video flush pkt
    03-14 13:52:06.139 477-24743/? D/SoftFFmpegAudio: SoftFFmpegAudio component: OMX.ffmpeg.aac.decoder mMode: 1
    03-14 13:52:06.141 477-24743/? V/SoftFFmpegAudio: get pcm params, nChannels:4294967295, nSamplingRate:4294967295
    03-14 13:52:06.141 477-24743/? V/SoftFFmpegAudio: set OMX_IndexParamAudioPcm, nChannels:1, nSampleRate:44100, nBitsPerSample:16
    03-14 13:52:06.141 477-24743/? V/SoftFFmpegAudio: set OMX_IndexParamAudioAac, nChannels:1, nSampleRate:44100
    03-14 13:52:06.141 477-24743/? E/OMXNodeInstance: setParameter(1866465283) ERROR: 0x8000101a
    03-14 13:52:06.141 477-24743/? V/SoftFFmpegAudio: get pcm params, nChannels:1, nSamplingRate:44100
    03-14 13:52:06.147 477-24744/? E/OMXNodeInstance: OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
    03-14 13:52:06.147 477-24744/? E/ACodec: [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -2147483648
    03-14 13:52:06.149 477-24745/? I/SoftFFmpegAudio: got extradata, ignore: 0, size: 2
    03-14 13:52:06.150 477-24745/? I/SoftFFmpegAudio: extradata is ready, size: 2
    03-14 13:52:06.150 477-24745/? D/SoftFFmpegAudio: begin to open ffmpeg audio decoder(aac), mCtx sample_rate: 44100, channels: 1, , sample_fmt: (null)
    03-14 13:52:06.154 477-24745/? D/SoftFFmpegAudio: open ffmpeg audio decoder(aac) success, mCtx sample_rate: 44100, channels: 1, sample_fmt: fltp
    03-14 13:52:06.154 477-24745/? I/SoftFFmpegAudio: Create sample rate converter for conversion of 44100 Hz fltp 1 channels(mono) to 44100 Hz s16 1 channels(mono)!
    03-14 13:52:06.154 477-24743/? V/SoftFFmpegAudio: get pcm params, nChannels:1, nSamplingRate:44100
    03-14 13:52:06.155 477-24739/? D/AudioSink: bufferCount (8) is too small and increased to 12
    03-14 13:52:06.162 477-24747/? E/SoftAVC: Decoder failed: -2
    03-14 13:52:06.162 477-24744/? E/ACodec: [OMX.google.h264.decoder] ERROR(0x80001001)
    03-14 13:52:06.162 477-24744/? E/ACodec: signalError(omxError 0x80001001, internalError -2147483648)
    03-14 13:52:06.163 477-24741/? E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 6
    03-14 13:52:06.167 477-24740/? E/NuPlayerDecoder: Failed to queue input buffer for OMX.google.h264.decoder (err=-38)
    03-14 13:52:06.167 477-16531/? E/NuPlayer: received error(0xffffffda) from video decoder, flushing(0), now shutting down
    03-14 13:52:06.168 10973-11040/com.hobbyte.touringandroid E/MediaPlayer: error (1, -38)
    03-14 13:52:06.168 10973-10973/com.hobbyte.touringandroid E/MediaPlayer: Error (1,-38)
    03-14 13:52:06.168 477-24740/? E/NuPlayerDecoder: failed to flush OMX.google.h264.decoder (err=-38)
    03-14 13:52:06.168 477-16531/? E/NuPlayer: received error(0xffffffda) from video decoder, flushing(2), now shutting down
    03-14 13:52:06.169 10973-10989/com.hobbyte.touringandroid E/MediaPlayer: error (1, -38)
    03-14 13:52:06.170 10973-10973/com.hobbyte.touringandroid E/MediaPlayer: Error (1,-38)

    For reference, here is my class file :

       package com.hobbyte.touringandroid.ui.adapter;

    import android.content.Context;
    import android.graphics.SurfaceTexture;
    import android.media.AudioManager;
    import android.media.MediaPlayer;
    import android.util.DisplayMetrics;
    import android.view.Gravity;
    import android.view.LayoutInflater;
    import android.view.Surface;
    import android.view.TextureView;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ArrayAdapter;
    import android.widget.ImageButton;
    import android.widget.ImageView;
    import android.widget.SeekBar;
    import android.widget.TextView;

    import com.google.android.exoplayer.ExoPlayer;
    import com.google.android.exoplayer.FrameworkSampleSource;
    import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
    import com.google.android.exoplayer.SampleSource;
    import com.google.android.exoplayer.TrackRenderer;
    import com.hobbyte.touringandroid.App;
    import com.hobbyte.touringandroid.tourdata.ListViewItem;
    import com.hobbyte.touringandroid.internet.LoadImageFromURL;
    import com.hobbyte.touringandroid.R;

    import java.io.File;
    import java.io.IOException;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;

    /**
    * @author Nikita
    */
    public class PoiContentAdapter extends ArrayAdapter<listviewitem> {
       private static final String TAG = "PoiContentAdapter";

       public static final int HEADER = 0;
       public static final int BODY = 1;
       public static final int IMAGE = 2;
       public static final int VIDEO = 3;

       private static Pattern namePattern;
       private static final String FILE_NAME_PATTERN = "https?:\\/\\/[-\\w\\.\\/]*\\/(.+\\.(jpe?g|png|mp4))";

       private ListViewItem[] items;

       private String keyID;

       private TextureView textureView;
       private MediaPlayer player;
       private AudioManager audio;

       private ImageButton play;
       private ImageButton replay;
       private ImageButton mute;
       private ImageButton max;
       private SeekBar volume;

       private String filePath;

       @Override
       public int getViewTypeCount() {
           return 4;
       }

       @Override
           public int getItemViewType(int position) {
           return items[position].getType();
       }

       public PoiContentAdapter(Context context, ListViewItem[] content, String keyID) {
           super(context, 0, content);
           this.keyID = keyID;
           items = content;
           namePattern = Pattern.compile(FILE_NAME_PATTERN);
       }

       /**
        * Inflates a certain view depending on the type of ListViewItem (Normal text or Image URL)
        * @param position Position of item in the ItemList
        * @param view View
        * @param parent ParentView
        * @return the view in question
        */
       @Override
       public View getView(int position, View view, ViewGroup parent) {
           ListViewItem listViewItem = items[position];
           int listViewItemType = getItemViewType(position);
           String filename = null;

           TextView contentView;

           if (listViewItem.getUrl() != null) {
               Matcher m = namePattern.matcher(listViewItem.getUrl());
               if (m.matches()) {
                   filename = m.group(1);
               }
           }

           if (view == null) {
               if (listViewItemType == IMAGE) {
                   view = LayoutInflater.from(getContext()).inflate(R.layout.poi_image, parent, false);
               } else if(listViewItemType == VIDEO) {
                   view = LayoutInflater.from(getContext()).inflate(R.layout.poi_video, parent, false);
               } else {
                   view = LayoutInflater.from(getContext()).inflate(R.layout.poi_content, parent, false);
               }
           }

           switch (listViewItemType) {
               case IMAGE:
                   ImageView imageView = (ImageView) view.findViewById(R.id.poiContentImageView);
                   TextView textView = (TextView) view.findViewById(R.id.poiContentImageDesc);
                   textView.setText(listViewItem.getText());

                   if (filename != null) {
                       new LoadImageFromURL(imageView, App.context).execute(filename, keyID); //Load image in a separate thread
                   }
                   return view;

               case VIDEO:
                   filePath = getContext().getFilesDir() + "/" + String.format("%s/video/%s", keyID, filename);
                   File file = new File(filePath);
                   if(!file.exists()) {
                       view = LayoutInflater.from(getContext()).inflate(R.layout.poi_content, parent, false);
                       contentView = (TextView) view.findViewById(R.id.poiContentTextView);
                       contentView.setText("This contains a video." + "\n" + "Download this tour with Media to see this Video!" + "\n");
                       contentView.setGravity(Gravity.CENTER_HORIZONTAL);
                   } else {
                       System.out.println(filePath);
                       textureView = (TextureView) view.findViewById(R.id.poiContentVideoView);

                       DisplayMetrics metrics = App.context.getResources().getDisplayMetrics();
                       int height = metrics.heightPixels / 2;
                       int width = metrics.widthPixels;
                       textureView.setMinimumHeight(height);
                       textureView.setMinimumWidth(width);

                       play = (ImageButton) view.findViewById(R.id.playButton);
                       replay = (ImageButton) view.findViewById(R.id.replayButtoon);
                       mute = (ImageButton) view.findViewById(R.id.muteButton);
                       max = (ImageButton) view.findViewById(R.id.maxVolButton);
                       volume = (SeekBar) view.findViewById(R.id.volumeControl);
                       audio = (AudioManager) App.context.getSystemService(Context.AUDIO_SERVICE);

                       textureView.setSurfaceTextureListener(videoListener);
                       TextView videoDesc = (TextView) view.findViewById(R.id.poiContentVideoDesc);
                       videoDesc.setText(listViewItem.getText());
                   }
                   return view;
               case HEADER:
                   // TODO
                   if(view.findViewById(R.id.poiContentTextView) == null) {
                       view = LayoutInflater.from(getContext()).inflate(R.layout.poi_content, parent, false);
                   }
                   contentView = (TextView) view.findViewById(R.id.poiContentTextView);
                   contentView.setText(listViewItem.getText() + "\n");
                   if(listViewItem.getText().length() == 0) {
                       return new View(getContext());
                   }
                   return view;
               case BODY:
                   // TODO
                   contentView = (TextView) view.findViewById(R.id.poiContentTextView);
                   contentView.setText(listViewItem.getText() + "\n");
                   return view;
               default:
                   contentView = (TextView) view.findViewById(R.id.poiContentTextView);
                   contentView.setText("Something went wrong\n");
                   return view;
           }
       }

       private TextureView.SurfaceTextureListener videoListener = new TextureView.SurfaceTextureListener() {
           @Override
           public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
               Surface s = new Surface(surface);
               try {
                   player = new MediaPlayer();
                   player.setDataSource(filePath);
                   player.setSurface(s);
                   player.prepareAsync();
                   player.setAudioStreamType(AudioManager.STREAM_MUSIC);
                   player.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT);
                   player.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() {
                       @Override
                       public void onBufferingUpdate(MediaPlayer mp, int percent) {
                           //Do nothing
                       }
                   });
                   player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                       @Override
                       public void onCompletion(MediaPlayer mp) {
                           //Do nothing
                       }
                   });
                   player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                       @Override
                       public void onPrepared(final MediaPlayer mp) {
                           play.setOnClickListener(new View.OnClickListener() {
                               @Override
                               public void onClick(View v) {
                                   if(mp.isPlaying()) {
                                       mp.pause();
                                       play.setImageResource(R.mipmap.ic_play_arrow_white_36dp);
                                   } else {
                                       mp.start();
                                       play.setImageResource(R.mipmap.ic_pause_white_36dp);
                                   }
                               }
                           });

                           replay.setOnClickListener(new View.OnClickListener() {
                               @Override
                               public void onClick(View v) {
                                   if(mp.isPlaying()) {
                                       play.setImageResource(R.mipmap.ic_play_arrow_white_36dp);
                                       mp.pause();
                                       mp.seekTo(0);
                                   } else {
                                       play.setImageResource(R.mipmap.ic_play_arrow_white_36dp);
                                       mp.seekTo(0);
                                   }
                               }
                           });
                           mute.setOnClickListener(new View.OnClickListener() {
                               @Override
                               public void onClick(View v) {
                                   mp.setVolume(0.0f, 0.0f);
                                   volume.setProgress(0);
                               }
                           });
                           max.setOnClickListener(new View.OnClickListener() {
                               @Override
                               public void onClick(View v) {
                                   mp.setVolume(1.0f, 1.0f);
                                   volume.setProgress(audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
                               }
                           });

                           int maxVolume = audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
                           int currVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
                           volume.setMax(maxVolume);
                           volume.setProgress(currVolume);
                           volume.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                               @Override
                               public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                                   audio.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0);
                               }

                               @Override
                               public void onStartTrackingTouch(SeekBar seekBar) {

                               }

                               @Override
                               public void onStopTrackingTouch(SeekBar seekBar) {

                               }
                           });
                       }
                   });

                   player.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
                       @Override
                       public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
                           //Do nothing
                       }
                   });
               } catch (IllegalArgumentException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
               } catch (SecurityException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
               } catch (IllegalStateException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
               } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
               }
           }

           @Override
           public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {

           }

           @Override
           public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
               if (player != null) {
                   player.stop();
                   player.release();
                   player = null;
               }
               return true;
           }

           @Override
           public void onSurfaceTextureUpdated(SurfaceTexture surface) {

           }
       };
    }
    </listviewitem>

    I really do not understand in the slightest what is causing all these errors, and why the video file won’t play ?
    If anyone is able to help I will highly highly appreciate it !

    I am using Genymotion Emulator - Google Nexus 4 - API 21

    Thank you very much !

  • FFmpeg : avconv and ffserver - connection reset by peer

    5 mars 2016, par einsA

    I’m trying to stream a video via ffserver. My dev environment is a Raspberry Pi 2.

    I’m getting an av_interleaved_write_frame(): Connection reset by peer with the following approach :

    pi@raspberrypi:/opt/livefeed $ avconv -f mjpeg -i movie.mjpg -r 20 -b 2000k -vcodec libx264 -preset ultrafast -f flv -metadata streamName="mjpeg_to_flv" -metadata title="converting mjpeg to flv via avconv" http://localhost:8090/feed1.ffm
    avconv version 11.4-6:11.4-1~deb8u1+rpi1, Copyright (c) 2000-2014 the Libav developers
     built on Jun 16 2015 05:32:34 with gcc 4.9.2 (Raspbian 4.9.2-10)
    [mjpeg @ 0x20461e0] Estimating duration from bitrate, this may be inaccurate
    Input #0, mjpeg, from 'movie.mjpg':
     Duration: N/A, bitrate: N/A
       Stream #0.0: Video: mjpeg, yuvj422p, 768x512, 25 fps, 25 tbn
    [tcp @ 0x2050bc0] Connection to tcp://localhost:8090 failed (Connection refused), trying next address
    [libx264 @ 0x20501a0] using cpu capabilities: none!
    [libx264 @ 0x20501a0] profile Constrained Baseline, level 3.0
    [libx264 @ 0x20501a0] 264 - core 142 r2431 a5831aa - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=20 scenecut=0 intra_refresh=0 rc=abr mbtree=0 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
    Output #0, flv, to 'http://localhost:8090/feed1.ffm':
     Metadata:
       streamName      : mjpeg_to_flv
       title           : converting mjpeg to flv via avconv
       encoder         : Lavf56.1.0
       Stream #0.0: Video: libx264, yuv420p, 768x512, q=-1--1, 2000 kb/s, 20 fps, 1k tbn, 20 tbc
       Metadata:
         encoder         : Lavc56.1.0 libx264
    Stream mapping:
     Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
    Press ctrl-c to stop encoding
    av_interleaved_write_frame(): Connection reset by peer0000.00 bitrate=   0.0kbits/s

    I am able to stream the file doing it step by step with the following settings and commands :

    ffserver

    ffserver config :

    pi@raspberrypi:/opt/livefeed $ cat ffserver_flv.conf
    # FLV live feed

    Port 8090
    BindAddress 0.0.0.0
    MaxHTTPConnections 2000
    MaxClients 1000
    MaxBandwidth 1000
    CustomLog -

    <stream>
     Format status
     ACL allow localhost
     ACL allow 192.168.0.0 192.168.255.255
    </stream>

    <feed>
     File /tmp/feed_flv.ffm
     FileMaxSize 1G
     ACL allow 127.0.0.1
    </feed>

    <stream>
     Format flv
     Feed feed1.ffm

     VideoCodec libx264
     VideoFrameRate 30
     VideoBitRate 800
     VideoSize 720x576
     AVOptionVideo crf 23
     AVOptionVideo preset medium
     AVOptionVideo me_range 16
     AVOptionVideo qdiff 4
     AVOptionVideo qmin 10
     AVOptionVideo qmax 51
     AVOptionVideo flags +global_header

     NoAudio
    </stream>

    starting the server with :

    pi@raspberrypi:/opt/livefeed $ ffserver -v debug -f ffserver_flv.conf
    ffserver version N-78909-gfb2f164 Copyright (c) 2000-2016 the FFmpeg developers
     built with gcc 4.9.2 (Raspbian 4.9.2-10)
     configuration: --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-libass --enable-libfaac --enable-libmp3lame --enable-libfreetype
     libavutil      55. 19.100 / 55. 19.100
     libavcodec     57. 27.101 / 57. 27.101
     libavformat    57. 28.100 / 57. 28.100
     libavdevice    57.  0.101 / 57.  0.101
     libavfilter     6. 39.100 /  6. 39.100
     libswscale      4.  0.100 /  4.  0.100
     libswresample   2.  0.101 /  2.  0.101
     libpostproc    54.  0.100 / 54.  0.100
    ffserver_flv.conf:6: Port option is deprecated. Use HTTPPort instead.
    ffserver_flv.conf:7: BindAddress option is deprecated. Use HTTPBindAddress instead.
    ffserver_flv.conf:48: Setting default value for video bit rate tolerance = 200000. Use NoDefaults to disable it.
    ffserver_flv.conf:48: Setting default value for video rate control equation = tex^qComp. Use NoDefaults to disable it.
    ffserver_flv.conf:48: Setting default value for video max rate = 49537952. Use NoDefaults to disable it.
    ffserver_flv.conf:48: Setting default value for video buffer size = 1600000. Use NoDefaults to disable it.
    Sat Mar  5 13:29:46 2016 [file @ 0x2f3d0d0]Setting default whitelist 'file'
    Sat Mar  5 13:29:46 2016 [ffm @ 0x2f40bc0]Format ffm probed with size=2048 and score=101
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'time_base' to value '1/30'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'b' to value '800000'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'video_size' to value '720x576'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'me_range' to value '16'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'qdiff' to value '4'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'qmin' to value '10'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'qmax' to value '51'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'flags' to value '+global_header'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'bt' to value '200000'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'rc_eq' to value 'tex^qComp'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'maxrate' to value '1600000'
    Sat Mar  5 13:29:46 2016 [NULL @ 0x2f43760]Setting entry with key 'bufsize' to value '1600000'
    Sat Mar  5 13:29:46 2016 [AVIOContext @ 0x2f41450]Statistics: 32768 bytes read, 0 seeks
    Sat Mar  5 13:29:46 2016 FFserver started.

    avconv

    I’m converting a mjpeg movie (movie.mjpeg) via avconv to flv (movie.flv) :

    pi@raspberrypi:/opt/livefeed $ avconv -f mjpeg -i movie.mjpg -r 20 -b 2000k -vcodec libx264 -preset ultrafast -f flv -metadata streamName="mjpeg_to_flv" -metadata title="converting mjpeg to flv via avconv" movie.flv
    avconv version 11.4-6:11.4-1~deb8u1+rpi1, Copyright (c) 2000-2014 the Libav developers
     built on Jun 16 2015 05:32:34 with gcc 4.9.2 (Raspbian 4.9.2-10)
    [mjpeg @ 0x34f1e0] Estimating duration from bitrate, this may be inaccurate
    Input #0, mjpeg, from 'movie.mjpg':
     Duration: N/A, bitrate: N/A
       Stream #0.0: Video: mjpeg, yuvj422p, 768x512, 25 fps, 25 tbn
    [libx264 @ 0x3591a0] using cpu capabilities: none!
    [libx264 @ 0x3591a0] profile Constrained Baseline, level 3.0
    [libx264 @ 0x3591a0] 264 - core 142 r2431 a5831aa - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=20 scenecut=0 intra_refresh=0 rc=abr mbtree=0 bitrate=2000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
    Output #0, flv, to 'movie.flv':
     Metadata:
       streamName      : mjpeg_to_flv
       title           : converting mjpeg to flv via avconv
       encoder         : Lavf56.1.0
       Stream #0.0: Video: libx264, yuv420p, 768x512, q=-1--1, 2000 kb/s, 20 fps, 1k tbn, 20 tbc
       Metadata:
         encoder         : Lavc56.1.0 libx264
    Stream mapping:
     Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
    Press ctrl-c to stop encoding
    frame=   93 fps=  9 q=-1.0 Lsize=    1078kB time=4.60 bitrate=1919.3kbits/s    ts/s    
    video:1076kB audio:0kB other streams:0kB global headers:0kB muxing overhead: 0.201471%
    [libx264 @ 0x3591a0] frame I:1     Avg QP:19.00  size: 35978
    [libx264 @ 0x3591a0] frame P:92    Avg QP:21.43  size: 11574
    [libx264 @ 0x3591a0] mb I  I16..4: 100.0%  0.0%  0.0%
    [libx264 @ 0x3591a0] mb P  I16..4: 25.9%  0.0%  0.0%  P16..4: 53.6%  0.0%  0.0%  0.0%  0.0%    skip:20.5%
    [libx264 @ 0x3591a0] final ratefactor: 20.82
    [libx264 @ 0x3591a0] coded y,uvDC,uvAC intra: 28.9% 46.9% 18.2% inter: 33.7% 39.8% 2.8%
    [libx264 @ 0x3591a0] i16 v,h,dc,p: 29% 30% 28% 14%
    [libx264 @ 0x3591a0] i8c dc,h,v,p: 53% 26% 15%  7%
    [libx264 @ 0x3591a0] kb/s:1893.82

    send flv to ffserver

    pi@raspberrypi:/opt/livefeed $ ffmpeg -stream_loop -1 -i movie.flv http://localhost:8090/feed1.ffm
    ffmpeg version N-78909-gfb2f164 Copyright (c) 2000-2016 the FFmpeg developers
     built with gcc 4.9.2 (Raspbian 4.9.2-10)
     configuration: --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-libass --enable-libfaac --enable-libmp3lame --enable-libfreetype
     libavutil      55. 19.100 / 55. 19.100
     libavcodec     57. 27.101 / 57. 27.101
     libavformat    57. 28.100 / 57. 28.100
     libavdevice    57.  0.101 / 57.  0.101
     libavfilter     6. 39.100 /  6. 39.100
     libswscale      4.  0.100 /  4.  0.100
     libswresample   2.  0.101 /  2.  0.101
     libpostproc    54.  0.100 / 54.  0.100
    Input #0, flv, from 'movie.flv':
     Metadata:
       streamName      : mjpeg_to_flv
       title           : converting mjpeg to flv via avconv
       encoder         : Lavf56.1.0
     Duration: 00:00:04.65, start: 0.000000, bitrate: 1898 kb/s
       Stream #0:0: Video: h264 (Constrained Baseline), yuv420p, 768x512, 2000 kb/s, 20 fps, 20 tbr, 1k tbn, 40 tbc
    [tcp @ 0x30d2920] Connection to tcp://localhost:8090 failed (Connection refused), trying next address
    [tcp @ 0x329a080] Connection to tcp://localhost:8090 failed (Connection refused), trying next address
    [libx264 @ 0x325fb30] using cpu capabilities: ARMv6 NEON
    [libx264 @ 0x325fb30] profile High, level 3.1
    [libx264 @ 0x325fb30] 264 - core 148 r2665 a01e339 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - 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=6 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=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 vbv_maxrate=1600 vbv_bufsize=1600 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
    Output #0, ffm, to 'http://localhost:8090/feed1.ffm':
     Metadata:
       streamName      : mjpeg_to_flv
       title           : converting mjpeg to flv via avconv
       creation_time   : now
       encoder         : Lavf57.28.100
       Stream #0:0: Video: h264 (libx264), yuv420p, 720x576, q=10-51, 800 kb/s, 20 fps, 1000k tbn, 30 tbc
       Metadata:
         encoder         : Lavc57.27.101 libx264
       Side data:
         cpb: bitrate max/min/avg: 1600000/0/800000 buffer size: 1600000 vbv_delay: -1
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
    Press [q] to stop, [?] for help
    Past duration 0.999992 too large
       Last message repeated 2 times
    Past duration 0.999992 too large      4kB time=00:00:00.00 bitrate=N/A dup=5 drop=0 speed=   0x    
       Last message repeated 3 times
    Past duration 0.999992 too large      4kB time=00:00:00.00 bitrate=N/A dup=9 drop=0 speed=  
    [croped]    
    video:968kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.719636%
    [libx264 @ 0x325fb30] frame I:11    Avg QP:22.49  size: 13888
    [libx264 @ 0x325fb30] frame P:487   Avg QP:16.10  size:  1382
    [libx264 @ 0x325fb30] frame B:980   Avg QP:21.31  size:   168
    [libx264 @ 0x325fb30] consecutive B-frames: 11.0%  1.8%  0.4% 86.9%
    [libx264 @ 0x325fb30] mb I  I16..4: 11.5% 81.2%  7.3%
    [libx264 @ 0x325fb30] mb P  I16..4:  1.6%  5.0%  0.2%  P16..4: 12.0%  1.6%  0.7%  0.0%  0.0%    skip:79.0%
    [libx264 @ 0x325fb30] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  5.8%  0.1%  0.0%  direct: 0.0%  skip:94.1%  L0:55.3% L1:44.4% BI: 0.3%
    [libx264 @ 0x325fb30] 8x8 transform intra:75.4% inter:88.7%
    [libx264 @ 0x325fb30] coded y,uvDC,uvAC intra: 38.6% 48.2% 14.9% inter: 1.5% 2.3% 0.0%
    [libx264 @ 0x325fb30] i16 v,h,dc,p: 28% 32% 11% 28%
    [libx264 @ 0x325fb30] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 21% 31%  3%  4%  4%  4%  4%  4%
    [libx264 @ 0x325fb30] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 25% 23%  4%  7%  5%  7%  4%  3%
    [libx264 @ 0x325fb30] i8c dc,h,v,p: 63% 20% 14%  4%
    [libx264 @ 0x325fb30] Weighted P-Frames: Y:1.6% UV:1.2%
    [libx264 @ 0x325fb30] ref P L0: 67.5% 11.6% 13.8%  6.8%  0.3%
    [libx264 @ 0x325fb30] ref B L0: 58.7% 40.4%  0.9%
    [libx264 @ 0x325fb30] ref B L1: 96.2%  3.8%
    [libx264 @ 0x325fb30] kb/s:160.83
    Exiting normally, received signal 2.

    On another machine I can open the flv-stream via VLC by opening the address http://ip.running.ffserver:8090/live.flv.

    So why does it works step by step via the movie.flv file and not directly ?

    What is the difference between

    • avconv -f mjpeg -i movie.mjpg -r 20 -b 2000k -vcodec libx264 -preset ultrafast -f flv -metadata streamName="mjpeg_to_flv" -metadata title="converting mjpeg to flv via avconv" movie.flv
      followed by
      ffmpeg -stream_loop -1 -i movie.flv http://localhost:8090/feed1.ffm and

    • avconv -f mjpeg -i movie.mjpg -r 20 -b 2000k -vcodec libx264 -preset ultrafast -f flv -metadata streamName="mjpeg_to_flv" -metadata title="converting mjpeg to flv via avconv" http://localhost:8090/feed1.ffm ? Why ends this command with a av_interleaved_write_frame(): Connection reset by peer ?


    Informations and logs

    • ffserver log (both times) :

      Sat Mar  5 13:54:08 2016 127.0.0.1 - - [POST] "/feed1.ffm HTTP/1.1" 200 4096
    • ffserver version

      pi@raspberrypi:/opt/livefeed $ ffserver -version
      ffserver version N-78909-gfb2f164 Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 4.9.2 (Raspbian 4.9.2-10)
      configuration: --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-libass --enable-libfaac --enable-libmp3lame --enable-libfreetype
      libavutil      55. 19.100 / 55. 19.100
      libavcodec     57. 27.101 / 57. 27.101
      libavformat    57. 28.100 / 57. 28.100
      libavdevice    57.  0.101 / 57.  0.101
      libavfilter     6. 39.100 /  6. 39.100
      libswscale      4.  0.100 /  4.  0.100
      libswresample   2.  0.101 /  2.  0.101
      libpostproc    54.  0.100 / 54.  0.100
    • ffmpeg version

      pi@raspberrypi:/opt/livefeed $ ffmpeg -version
      ffmpeg version N-78909-gfb2f164 Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 4.9.2 (Raspbian 4.9.2-10)
      configuration: --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-libass --enable-libfaac --enable-libmp3lame --enable-libfreetype
      libavutil      55. 19.100 / 55. 19.100
      libavcodec     57. 27.101 / 57. 27.101
      libavformat    57. 28.100 / 57. 28.100
      libavdevice    57.  0.101 / 57.  0.101
      libavfilter     6. 39.100 /  6. 39.100
      libswscale      4.  0.100 /  4.  0.100
      libswresample   2.  0.101 /  2.  0.101
      libpostproc    54.  0.100 / 54.  0.100
    • avconv version :

      pi@raspberrypi:/opt/livefeed $ avconv -version
      avconv version 11.4-6:11.4-1~deb8u1+rpi1, Copyright (c) 2000-2014 the Libav developers
      built on Jun 16 2015 05:32:34 with gcc 4.9.2 (Raspbian 4.9.2-10)
      avconv 11.4-6:11.4-1~deb8u1+rpi1
      libavutil     54.  3. 0 / 54.  3. 0
      libavcodec    56.  1. 0 / 56.  1. 0
      libavformat   56.  1. 0 / 56.  1. 0
      libavdevice   55.  0. 0 / 55.  0. 0
      libavfilter    5.  0. 0 /  5.  0. 0
      libavresample  2.  1. 0 /  2.  1. 0
      libswscale     3.  0. 0 /  3.  0. 0

    Thanks and cheers

    Clemens

  • DASH package (mpd) I made freezes after raising the onratechange event

    7 mars 2016, par Nick Birke

    I am trying to created an adaptive stream from an mp4 file. I have a decent amount of experience at doing streaming, and have successfully implemented smooth streaming via Silverlight. We want a solution for everything that works in HTML5. I am pursuing DASH. So here are the steps I take...

    1. Resample the mp4 to different sizes using ffmpeg.
    2. Ensure the files are properly fragmented using Bento4s mp4Fragment utility.
    3. Create the DASH mpd file and associated segments using Bento4s mp4dash utility.

    I have done a lot of work to learn each of these utilities and create a process that gets to output that I think will work. To create reliable DASH artifacts. But it seems I am doing something wrong. Here are examples of command lines I run.

    For step one I create three different files... for three different rates and sizes... (these may not be the exact command lines, they are from old notes... but the parameter values are the ones I am using for sure)

    ffmpeg -y -i C:\_SIMULATED_SHARE_C\ff\big_buck_bunny.mp4 -c:v libx264 -x264opts keyint=24:min-keyint=24:no-scenecut -b:v 1500k -maxrate 1500k -bufsize 1000k -vf "scale=-1:720" C:\_SIMULATED_SHARE_C\ff\output\outputfile720.mp4

    ffmpeg -y -i C:\_SIMULATED_SHARE_C\ff\big_buck_bunny.mp4 -c:v libx264 -x264opts keyint=24:min-keyint=24:no-scenecut -b:v 800k -maxrate 800k -bufsize 500k -vf "scale=-1:540" C:\_SIMULATED_SHARE_C\ff\output\outputfile540.mp4

    ffmpeg -y -i C:\_SIMULATED_SHARE_C\ff\big_buck_bunny.mp4 -c:v libx264 -x264opts keyint=24:min-keyint=24:no-scenecut -b:v 400k -maxrate 400k -bufsize 400k -vf "scale=-1:360" C:\_SIMULATED_SHARE_C\ff\output\outputfile360.mp4

    So that gives you the three files that need to be fragmented. So I fragment them using the mp4fragment utility from Bento4. That command line is simple so I will not offer an example.

    The I use Bento4s mp4dash to create the dash. Something like this...

    "E:\\_INSTALL\\Bento4\\Bento4-SDK-1-4-3-607.x86-microsoft-win32-vs2010\\Bento4-SDK-1-4-3-607.x86-microsoft-win32-vs2010\\bin\\mp4dash.exe --mpd-name=\"\\\\d9fqt52\\_SIMULATED_SHARE_C\\ff\\output\\dash\\something.mpd\" -f -o \"\\\\d9fqt52\\_SIMULATED_SHARE_C\\ff\\output\\dash\" \"\\\\d9fqt52\\_SIMULATED_SHARE_C\\ff\\output\\bunny360f.mp4\" \"\\\\d9fqt52\\_SIMULATED_SHARE_C\\ff\\output\\bunny540f.mp4\" \"\\\\d9fqt52\\_SIMULATED_SHARE_C\\ff\\output\\bunny720f.mp4\" "

    This runs ok. And creates the mpd file, an audio folder with segment files, an a video folder with 3 folders each with the segment files.

    I am able to configure IIS to play the mpd ok. As well as the segement files. The video plays fine... and then it stops. It freezes between 50 and 60 seconds. Right before it freezes I can confirm that the onratechange event of the HTML5 video tag is raised. This is an event that is raised with the rate of play is changed. I do nothing to change this it just happens.

    The actual video in question is about 1hr long. Also I am using the dash.js library as a player.

    If you can identify any components or specifics I should change please let me know !

    UPDATE ON MAR 7, 2016

    As requested here is the MPD content...

    &lt;?xml version="1.0" ?>
    <mpd mediapresentationduration="PT51M51.909S" minbuffertime="PT0.80S" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" xmlns="urn:mpeg:dash:schema:mpd:2011">
     
     <period>
       
       <adaptationset lang="en" mimetype="audio/mp4" segmentalignment="true" startwithsap="1">
         <segmenttemplate duration="801" initialization="$RepresentationID$/init.mp4" media="$RepresentationID$/seg-$Number$.m4f" startnumber="1" timescale="1000"></segmenttemplate>
         <representation audiosamplingrate="48000" bandwidth="132491" codecs="mp4a.40.2">
           <audiochannelconfiguration schemeiduri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"></audiochannelconfiguration>
         </representation>
       </adaptationset>
       
       <adaptationset maxheight="720" maxwidth="1280" mimetype="video/mp4" minheight="540" minwidth="640" segmentalignment="true" startwithsap="1">
         <segmenttemplate duration="801" initialization="$RepresentationID$/init.mp4" media="$RepresentationID$/seg-$Number$.m4f" startnumber="1" timescale="1000"></segmenttemplate>
         <representation bandwidth="785536" codecs="avc1.64001F" framerate="30000/1001" height="540" scantype="progressive" width="960"></representation>
         <representation bandwidth="403537" codecs="avc1.64001E" framerate="30000/1001" height="360" scantype="progressive" width="640"></representation>
         <representation bandwidth="1496514" codecs="avc1.64001F" framerate="30000/1001" height="720" scantype="progressive" width="1280"></representation>
       </adaptationset>
     </period>
    </mpd>

    UPDATE ON MAR 7, 2016

    Here is the console output for two different videos that just stop for some unknown reason between 50 and 60s

    ///ABS VIDEO

    58393][rulesController] [RULES]: playbackTimeRule [Fragment:download,82,MediaSegment,0video] Default
    dash.all.js:11 [58395][rulesController] [RULES]: sameTimeRequestRule [Fragment:download,82,MediaSegment,0,video] Default
    dash.all.js:11 [58401][indexHandler][audio] Getting the request for time: 82.082
    dash.all.js:11 [58403][indexHandler][audio] Index for time 82.082 is 81
    dash.all.js:11 [58405][indexHandler][audio] SegmentTemplate: 81.08099999999999 / 1361.235
    dash.all.js:11 [58406][indexHandler][audio] SegmentTemplate: 82.082 / 1361.235
    dash.all.js:11 [58407][rulesController] [RULES]: playbackTimeRule [Fragment:download,82,MediaSegment,0audio] Default
    dash.all.js:11 [58417][fragmentLoader] loaded video:MediaSegment:82.082 (200, 18ms, 2ms)
    dash.all.js:11 [58419][rulesController] [RULES]: sameTimeRequestRule [Fragment:download,82,MediaSegment,0,audio] Default
    dash.all.js:11 [58435][fragmentLoader] loaded audio:MediaSegment:82.082 (200, 14ms, 0ms)
    dash.all.js:11 [59390][indexHandler][video] Getting the request for time: 83.083
    dash.all.js:11 [59392][indexHandler][video] Index for time 83.083 is 82
    dash.all.js:11 [59393][indexHandler][video] SegmentTemplate: 82.082 / 1361.235
    dash.all.js:11 [59394][indexHandler][video] SegmentTemplate: 83.08299999999998 / 1361.235
    dash.all.js:11 [59395][rulesController] [RULES]: playbackTimeRule [Fragment:download,83,MediaSegment,0video] Default
    dash.all.js:11 [59396][rulesController] [RULES]: sameTimeRequestRule [Fragment:download,83,MediaSegment,0,video] Default
    dash.all.js:11 [59401][indexHandler][audio] Getting the request for time: 83.083
    dash.all.js:11 [59403][indexHandler][audio] Index for time 83.083 is 82
    dash.all.js:11 [59404][indexHandler][audio] SegmentTemplate: 82.082 / 1361.235
    dash.all.js:11 [59406][indexHandler][audio] SegmentTemplate: 83.08299999999998 / 1361.235
    dash.all.js:11 [59408][rulesController] [RULES]: playbackTimeRule [Fragment:download,83,MediaSegment,0audio] Default
    dash.all.js:11 [59416][fragmentLoader] loaded video:MediaSegment:83.08299999999998 (200, 17ms, 1ms)
    dash.all.js:11 [59418][rulesController] [RULES]: sameTimeRequestRule [Fragment:download,83,MediaSegment,0,audio] Default
    dash.all.js:11 [59437][fragmentLoader] loaded audio:MediaSegment:83.08299999999998 (200, 14ms, 1ms)
    dash.all.js:11 [59902][scheduleController][video] Stalling Buffer
    dash.all.js:11 [59903][bufferController][video] Waiting for more buffer before starting playback.
    dash.all.js:11 [59906][scheduleController][audio] Stalling Buffer
    dash.all.js:11 [59907][bufferController][audio] Waiting for more buffer before starting playback.
    dash.all.js:11 [63684][playbackController] <video> ratechange:  0




    ///HOG VIDEO

    [58250][rulesController] [RULES]: playbackTimeRule [Fragment:download,105,MediaSegment,0audio] Default
    dash.all.js:11 [58266][fragmentLoader] loaded video:MediaSegment:84.105 (200, 28ms, 1ms)
    dash.all.js:11 [58269][rulesController] [RULES]: sameTimeRequestRule [Fragment:download,105,MediaSegment,0,audio] Default
    dash.all.js:11 [58287][fragmentLoader] loaded audio:MediaSegment:84.105 (200, 14ms, 1ms)
    dash.all.js:11 [58982][indexHandler][video] Getting the request for time: 84.906
    dash.all.js:11 [58983][indexHandler][video] Index for time 84.906 is 105
    dash.all.js:11 [58984][indexHandler][video] SegmentTemplate: 84.105 / 3111.909
    dash.all.js:11 [58984][indexHandler][video] SegmentTemplate: 84.906 / 3111.909
    dash.all.js:11 [58985][rulesController] [RULES]: playbackTimeRule [Fragment:download,106,MediaSegment,0video] Default
    dash.all.js:11 [58986][rulesController] [RULES]: sameTimeRequestRule [Fragment:download,106,MediaSegment,0,video] Default
    dash.all.js:11 [58989][indexHandler][audio] Getting the request for time: 84.906
    dash.all.js:11 [58990][indexHandler][audio] Index for time 84.906 is 105
    dash.all.js:11 [58991][indexHandler][audio] SegmentTemplate: 84.105 / 3111.909
    dash.all.js:11 [58992][indexHandler][audio] SegmentTemplate: 84.906 / 3111.909
    dash.all.js:11 [58993][rulesController] [RULES]: playbackTimeRule [Fragment:download,106,MediaSegment,0audio] Default
    dash.all.js:11 [59002][fragmentLoader] loaded video:MediaSegment:84.906 (200, 14ms, 1ms)
    dash.all.js:11 [59003][rulesController] [RULES]: sameTimeRequestRule [Fragment:download,106,MediaSegment,0,audio] Default
    dash.all.js:11 [59014][fragmentLoader] loaded audio:MediaSegment:84.906 (200, 8ms, 1ms)
    dash.all.js:11 [59735][scheduleController][video] Stalling Buffer
    dash.all.js:11 [59736][bufferController][video] Waiting for more buffer before starting playback.
    dash.all.js:11 [59738][scheduleController][audio] Stalling Buffer
    dash.all.js:11 [59739][bufferController][audio] Waiting for more buffer before starting playback.
    dash.all.js:11 [61695][playbackController] <video> ratechange:  0
    </video></video>