
Recherche avancée
Médias (16)
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#3 The Safest Place
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#4 Emo Creates
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#2 Typewriter Dance
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Autres articles (69)
-
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Gestion de la ferme
2 mars 2010, parLa ferme est gérée dans son ensemble par des "super admins".
Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
Dans un premier temps il utilise le plugin "Gestion de mutualisation"
Sur d’autres sites (8941)
-
MediaPlayer within TextureView not working as intended
15 mars 2016, par RussieeI’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 setUpon 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 !
-
Use FFMPEG mux flv and send rtmp on IOS
3 janvier 2017, par downlossI would like to use iphone camera & microphone to capture information pushed out through FFMPEG RTMP Streaming
The following Function capture information on IOS
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
{
if (connection == videoCaptureConnection)
{
[manager264 encoderToH264:sampleBuffer];
}
else if (connection == audioCaptureConnection)
{
[manager264 encoderToMP3:sampleBuffer];
}
}Initialization FFMPEG
- (int)setX264Resource
{
Global_Variables_VVV = (AppDelegate *)[[UIApplication sharedApplication] delegate];
avformat_network_init();
av_register_all();
pFormatCtx = avformat_alloc_context();
avformat_alloc_output_context2(&pFormatCtx, NULL, "flv", out_file);
fmt = pFormatCtx->oformat;
//Open output URL
if (avio_open(&pFormatCtx->pb, out_file, AVIO_FLAG_READ_WRITE) < 0)
{
printf("Failed to open output file! \n");
return -1;
}
/* Add the audio and video streams using the default format codecs
* and initialize the codecs. */
video_st = NULL;
audio_st = NULL;
if (fmt->video_codec != AV_CODEC_ID_NONE) {
video_st = add_stream(pFormatCtx, &pCodec, AV_CODEC_ID_H264);
}
if (fmt->audio_codec != AV_CODEC_ID_NONE) {
audio_st = add_stream(pFormatCtx, &aCodec, AV_CODEC_ID_MP3);
}
/* Now that all the parameters are set, we can open the audio and
* video codecs and allocate the necessary encode buffers. */
if (video_st)
[self open_video:pFormatCtx avcodec:pCodec avstream:video_st];
if (audio_st)
[self open_audio:pFormatCtx avcodec:aCodec avstream:audio_st];
// Show some Information
av_dump_format(pFormatCtx, 0, out_file, 1);
//Write File Header
avformat_write_header(pFormatCtx, NULL);
av_new_packet(&pkt, picture_size);
av_new_packet(&pkt2, picture_size);
AVCodecContext *c = video_st->codec;
y_size = c->width * c->height;
if (pFrame)
pFrame->pts = 0;
if(aFrame)
{
aFrame->pts = 0;
}
return 0;
}
static AVStream *add_stream(AVFormatContext *oc, AVCodec **codec, enum AVCodecID codec_id)
{
AVCodecContext *c;
AVStream *st;
/* find the encoder */
*codec = avcodec_find_encoder(codec_id);
if (!(*codec))
{
NSLog(@"Could not find encoder for '%s'\n",
avcodec_get_name(codec_id));
}
st = avformat_new_stream(oc, *codec);
if (!st)
{
NSLog(@"Could not allocate stream\n");
}
st->id = oc->nb_streams-1;
c = st->codec;
switch ((*codec)->type)
{
case AVMEDIA_TYPE_AUDIO:
c->codec_id = AV_CODEC_ID_MP3;
c->codec_type = AVMEDIA_TYPE_AUDIO;
c->channels = 1;
c->sample_fmt = AV_SAMPLE_FMT_S16P;
c->bit_rate = 128000;
c->sample_rate = 44100;
c->channel_layout = AV_CH_LAYOUT_MONO;
break;
case AVMEDIA_TYPE_VIDEO:
c->codec_id = AV_CODEC_ID_H264;
c->codec_type=AVMEDIA_TYPE_VIDEO;
/* Resolution must be a multiple of two. */
c->width = 720;
c->height = 1280;
/* timebase: This is the fundamental unit of time (in seconds) in terms
* of which frame timestamps are represented. For fixed-fps content,
* timebase should be 1/framerate and timestamp increments should be
* identical to 1. */
c->time_base.den = 30;
c->time_base.num = 1;
c->gop_size = 15; /* emit one intra frame every twelve frames at most */
c->pix_fmt = PIX_FMT_YUV420P;
c->max_b_frames = 0;
c->bit_rate = 3000000;
c->qmin = 10;
c->qmax = 51;
break;
default:
break;
}
/* Some formats want stream headers to be separate. */
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
return st;
}SampleBuffer will turn into H264 and pushed out RTMP Streaming
- (void)encoderToH264:(CMSampleBufferRef)sampleBuffer
{
CVPixelBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
if (CVPixelBufferLockBaseAddress(imageBuffer, 0) == kCVReturnSuccess)
{
UInt8 *bufferbasePtr = (UInt8 *)CVPixelBufferGetBaseAddress(imageBuffer);
UInt8 *bufferPtr = (UInt8 *)CVPixelBufferGetBaseAddressOfPlane(imageBuffer,0);
UInt8 *bufferPtr1 = (UInt8 *)CVPixelBufferGetBaseAddressOfPlane(imageBuffer,1);
size_t buffeSize = CVPixelBufferGetDataSize(imageBuffer);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t height = CVPixelBufferGetHeight(imageBuffer);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
size_t bytesrow0 = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer,0);
size_t bytesrow1 = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer,1);
size_t bytesrow2 = CVPixelBufferGetBytesPerRowOfPlane(imageBuffer,2);
UInt8 *yuv420_data = (UInt8 *)malloc(width * height *3/ 2); // buffer to store YUV with layout YYYYYYYYUUVV
/* convert NV12 data to YUV420*/
UInt8 *pY = bufferPtr ;
UInt8 *pUV = bufferPtr1;
UInt8 *pU = yuv420_data + width*height;
UInt8 *pV = pU + width*height/4;
for(int i =0;i/Read raw YUV data
picture_buf = yuv420_data;
pFrame->data[0] = picture_buf; // Y
pFrame->data[1] = picture_buf+ y_size; // U
pFrame->data[2] = picture_buf+ y_size*5/4; // V
int got_picture = 0;
// Encode
pFrame->width = 720;
pFrame->height = 1280;
pFrame->format = PIX_FMT_YUV420P;
AVCodecContext *c = video_st->codec;
int ret = avcodec_encode_video2(c, &pkt, pFrame, &got_picture);
if(ret < 0)
{
printf("Failed to encode! \n");
}
if (got_picture==1)
{
/* Compute current audio and video time. */
video_time = video_st ? video_st->pts.val * av_q2d(video_st->time_base) : 0.0;
pFrame->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base);
if(pkt.size != 0)
{
printf("Succeed to encode frame: %5lld\tsize:%5d\n", pFrame->pts, pkt.size);
pkt.stream_index = video_st->index;
ret = av_write_frame(pFormatCtx, &pkt);
av_free_packet(&pkt);
}
}
free(yuv420_data);
}
CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
}SampleBuffer will turn into MP3 and pushed out RTMP Streaming
-(void)encoderToMP3:(CMSampleBufferRef)sampleBuffer
{
CMSampleTimingInfo timing_info;
CMSampleBufferGetSampleTimingInfo(sampleBuffer, 0, &timing_info);
double pts=0;
double dts=0;
AVCodecContext *c;
int got_packet, ret;
c = audio_st->codec;
CMItemCount numSamples = CMSampleBufferGetNumSamples(sampleBuffer);
NSUInteger channelIndex = 0;
CMBlockBufferRef audioBlockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer);
size_t audioBlockBufferOffset = (channelIndex * numSamples * sizeof(SInt16));
size_t lengthAtOffset = 0;
size_t totalLength = 0;
SInt16 *samples = NULL;
CMBlockBufferGetDataPointer(audioBlockBuffer, audioBlockBufferOffset, &lengthAtOffset, &totalLength, (char **)(&samples));
const AudioStreamBasicDescription *audioDescription = CMAudioFormatDescriptionGetStreamBasicDescription(CMSampleBufferGetFormatDescription(sampleBuffer));
SwrContext *swr = swr_alloc();
int in_smprt = (int)audioDescription->mSampleRate;
av_opt_set_int(swr, "in_channel_layout", AV_CH_LAYOUT_MONO, 0);
av_opt_set_int(swr, "out_channel_layout", audio_st->codec->channel_layout, 0);
av_opt_set_int(swr, "in_channel_count", audioDescription->mChannelsPerFrame, 0);
av_opt_set_int(swr, "out_channel_count", 1, 0);
av_opt_set_int(swr, "out_channel_layout", audio_st->codec->channel_layout, 0);
av_opt_set_int(swr, "in_sample_rate", audioDescription->mSampleRate,0);
av_opt_set_int(swr, "out_sample_rate", audio_st->codec->sample_rate,0);
av_opt_set_sample_fmt(swr, "in_sample_fmt", AV_SAMPLE_FMT_S16, 0);
av_opt_set_sample_fmt(swr, "out_sample_fmt", audio_st->codec->sample_fmt, 0);
swr_init(swr);
uint8_t **input = NULL;
int src_linesize;
int in_samples = (int)numSamples;
ret = av_samples_alloc_array_and_samples(&input, &src_linesize, audioDescription->mChannelsPerFrame, in_samples, AV_SAMPLE_FMT_S16P, 0);
*input=(uint8_t*)samples;
uint8_t *output=NULL;
int out_samples = av_rescale_rnd(swr_get_delay(swr, in_smprt) +in_samples, (int)audio_st->codec->sample_rate, in_smprt, AV_ROUND_UP);
av_samples_alloc(&output, NULL, audio_st->codec->channels, out_samples, audio_st->codec->sample_fmt, 0);
in_samples = (int)numSamples;
out_samples = swr_convert(swr, &output, out_samples, (const uint8_t **)input, in_samples);
aFrame->nb_samples =(int) out_samples;
ret = avcodec_fill_audio_frame(aFrame, audio_st->codec->channels, audio_st->codec->sample_fmt,
(uint8_t *)output,
(int) out_samples *
av_get_bytes_per_sample(audio_st->codec->sample_fmt) *
audio_st->codec->channels, 1);
if (ret < 0)
{
fprintf(stderr, "Error fill audio frame: %s\n", av_err2str(ret));
}
aFrame->channel_layout = audio_st->codec->channel_layout;
aFrame->channels=audio_st->codec->channels;
aFrame->sample_rate= audio_st->codec->sample_rate;
if (timing_info.presentationTimeStamp.timescale!=0)
pts=(double) timing_info.presentationTimeStamp.value/timing_info.presentationTimeStamp.timescale;
aFrame->pts = pts*audio_st->time_base.den;
aFrame->pts = av_rescale_q(aFrame->pts, audio_st->time_base, audio_st->codec->time_base);
ret = avcodec_encode_audio2(c, &pkt2, aFrame, &got_packet);
if (ret < 0)
{
fprintf(stderr, "Error encoding audio frame: %s\n", av_err2str(ret));
}
swr_free(&swr);
if (got_packet)
{
pkt2.stream_index = audio_st->index;
// Write the compressed frame to the media file.
ret = av_interleaved_write_frame(pFormatCtx, &pkt2);
if (ret != 0)
{
fprintf(stderr, "Error while writing audio frame: %s\n", av_err2str(ret));
av_free_packet(&pkt2);
}
}
}Soon "Broken pipe" problem occurs after execution.
PTS is currently feeling is not adjusted, but do not know how to adjust the PTS.2016-03-09 16:57:41.058 PoliceCamPlayer[1004:193465] recordVideo....
[libx264 @ 0x12f8b6e00] using cpu capabilities: ARMv8 NEON
[libx264 @ 0x12f8b6e00] profile Constrained Baseline, level 3.1
[libx264 @ 0x12f8b6e00] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=2 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=2 lookahead_threads=2 sliced_threads=1 slices=2 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=15 keyint_min=1 scenecut=40 intra_refresh=0 rc=abr mbtree=0 bitrate=3000 ratetol=1.0 qcomp=0.60 qpmin=25 qpmax=51 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'rtmp://XXX.XX.XXX.XX/myapp/jackal':
Stream #0:0: Video: h264 (libx264), yuv420p, 720x1280, q=25-51, 3000 kb/s, 23 tbc
Stream #0:1: Audio: mp3 (libmp3lame), 44100 Hz, mono, s16p, 64 kb/s
[flv @ 0x12f8b5400] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[flv @ 0x12f8b5400] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[libx264 @ 0x12f8b6e00] Provided packet is too small, needs to be 33468
Failed to encode!
Audio_pts:4154432515 pts_time:4.15443e+06 dts:4154432515 dts_time:4.15443e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:43 pts_time:0.043 dts:43 dts_time:0.043 duration:0 duration_time:0 stream_index:0
Audio_pts:4154433667 pts_time:4.15443e+06 dts:4154433667 dts_time:4.15443e+06 duration:1152 duration_time:1.152 stream_index:1
Audio_pts:4154434854 pts_time:4.15443e+06 dts:4154434854 dts_time:4.15443e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:86 pts_time:0.086 dts:86 dts_time:0.086 duration:0 duration_time:0 stream_index:0
Audio_pts:4154435996 pts_time:4.15444e+06 dts:4154435996 dts_time:4.15444e+06 duration:1152 duration_time:1.152 stream_index:1
Audio_pts:4154437138 pts_time:4.15444e+06 dts:4154437138 dts_time:4.15444e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:129 pts_time:0.129 dts:129 dts_time:0.129 duration:0 duration_time:0 stream_index:0
Audio_pts:4154438281 pts_time:4.15444e+06 dts:4154438281 dts_time:4.15444e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:172 pts_time:0.172 dts:172 dts_time:0.172 duration:0 duration_time:0 stream_index:0
Audio_pts:4154439467 pts_time:4.15444e+06 dts:4154439467 dts_time:4.15444e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:215 pts_time:0.215 dts:215 dts_time:0.215 duration:0 duration_time:0 stream_index:0
Audio_pts:4154440609 pts_time:4.15444e+06 dts:4154440609 dts_time:4.15444e+06 duration:1152 duration_time:1.152 stream_index:1
Audio_pts:4154441752 pts_time:4.15444e+06 dts:4154441752 dts_time:4.15444e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:258 pts_time:0.258 dts:258 dts_time:0.258 duration:0 duration_time:0 stream_index:0
Audio_pts:4154442884 pts_time:4.15444e+06 dts:4154442884 dts_time:4.15444e+06 duration:1152 duration_time:1.152 stream_index:1
Audio_pts:4154444071 pts_time:4.15444e+06 dts:4154444071 dts_time:4.15444e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:301 pts_time:0.301 dts:301 dts_time:0.301 duration:0 duration_time:0 stream_index:0
Audio_pts:4154445213 pts_time:4.15445e+06 dts:4154445213 dts_time:4.15445e+06 duration:1152 duration_time:1.152 stream_index:1
Audio_pts:4154446355 pts_time:4.15445e+06 dts:4154446355 dts_time:4.15445e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:344 pts_time:0.344 dts:344 dts_time:0.344 duration:0 duration_time:0 stream_index:0
Audio_pts:4154447498 pts_time:4.15445e+06 dts:4154447498 dts_time:4.15445e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:387 pts_time:0.387 dts:387 dts_time:0.387 duration:0 duration_time:0 stream_index:0
Audio_pts:4154448640 pts_time:4.15445e+06 dts:4154448640 dts_time:4.15445e+06 duration:1152 duration_time:1.152 stream_index:1
Audio_pts:4154449826 pts_time:4.15445e+06 dts:4154449826 dts_time:4.15445e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:430 pts_time:0.43 dts:430 dts_time:0.43 duration:0 duration_time:0 stream_index:0
Audio_pts:4154450969 pts_time:4.15445e+06 dts:4154450969 dts_time:4.15445e+06 duration:1152 duration_time:1.152 stream_index:1
Audio_pts:4154452101 pts_time:4.15445e+06 dts:4154452101 dts_time:4.15445e+06 duration:1152 duration_time:1.152 stream_index:1
...................
...................
...................
Video_pts:4343 pts_time:4.343 dts:4343 dts_time:4.343 duration:0 duration_time:0 stream_index:0
Audio_pts:4154622619 pts_time:4.15462e+06 dts:4154622619 dts_time:4.15462e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:4386 pts_time:4.386 dts:4386 dts_time:4.386 duration:0 duration_time:0 stream_index:0
Audio_pts:4154623761 pts_time:4.15462e+06 dts:4154623761 dts_time:4.15462e+06 duration:1152 duration_time:1.152 stream_index:1
Audio_pts:4154624903 pts_time:4.15462e+06 dts:4154624903 dts_time:4.15462e+06 duration:1152 duration_time:1.152 stream_index:1
Audio_pts:4154626090 pts_time:4.15463e+06 dts:4154626090 dts_time:4.15463e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:4429 pts_time:4.429 dts:4429 dts_time:4.429 duration:0 duration_time:0 stream_index:0
Audio_pts:4154627222 pts_time:4.15463e+06 dts:4154627222 dts_time:4.15463e+06 duration:1152 duration_time:1.152 stream_index:1
Video_pts:4472 pts_time:4.472 dts:4472 dts_time:4.472 duration:0 duration_time:0 stream_index:0
Error while writing audio frame: Broken pipe
Audio_pts:4154628365 pts_time:4.15463e+06 dts:4154628365 dts_time:4.15463e+06 duration:1152 duration_time:1.152 stream_index:1
Error while writing audio frame: Broken pipe
Audio_pts:4154629507 pts_time:4.15463e+06 dts:4154629507 dts_time:4.15463e+06 duration:1152 duration_time:1.152 stream_index:1
Error while writing audio frame: Broken pipe
Audio_pts:4154630693 pts_time:4.15463e+06 dts:4154630693 dts_time:4.15463e+06 duration:1152 duration_time:1.152 stream_index:1
Error while writing audio frame: Broken pipe
Audio_pts:4154631836 pts_time:4.15463e+06 dts:4154631836 dts_time:4.15463e+06 duration:1152 duration_time:1.152 stream_index:1
Error while writing audio frame: Broken pipe
Audio_pts:4154632978 pts_time:4.15463e+06 dts:4154632978 dts_time:4.15463e+06 duration:1152 duration_time:1.152 stream_index:1
.......................
.......................
.......................
2016-03-09 16:57:49.345 PoliceCamPlayer[1004:193465] stopRecord!!!
Video_pts:7783 pts_time:7.783 dts:7783 dts_time:7.783 duration:0 duration_time:0 stream_index:0
[flv @ 0x12f8b5400] Failed to update header with correct duration.
[flv @ 0x12f8b5400] Failed to update header with correct filesize.
[libx264 @ 0x12f8b6e00] frame I:28 Avg QP:25.36 size: 24181
[libx264 @ 0x12f8b6e00] frame P:154 Avg QP:25.34 size: 6603
[libx264 @ 0x12f8b6e00] mb I I16..4: 80.9% 0.0% 19.1%
[libx264 @ 0x12f8b6e00] mb P I16..4: 5.9% 0.0% 0.2% P16..4: 28.2% 4.4% 1.0% 0.0% 0.0% skip:60.2%
[libx264 @ 0x12f8b6e00] final ratefactor: 16.70
[libx264 @ 0x12f8b6e00] coded y,uvDC,uvAC intra: 35.8% 9.3% 0.4% inter: 8.8% 1.6% 0.0%
[libx264 @ 0x12f8b6e00] i16 v,h,dc,p: 28% 26% 26% 21%
[libx264 @ 0x12f8b6e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 26% 25% 3% 7% 4% 5% 3% 13%
[libx264 @ 0x12f8b6e00] i8c dc,h,v,p: 85% 9% 5% 0%
[libx264 @ 0x12f8b6e00] kb/s:1712.63 -
Anomalie #3741 (Fermé) : Date de sortie de 3.1.0 erronée sur page web
6 mars 2016, par rpnpif-free-fr -La date de sortie de SPIP 3.1.0 est notée 6 janvier 2015 au lieu du 6 janvier 2016 sur http://www.spip.net/fr_download.