
Recherche avancée
Médias (2)
-
SPIP - plugins - embed code - Exemple
2 septembre 2013, par
Mis à jour : Septembre 2013
Langue : français
Type : Image
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (82)
-
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
Menus personnalisés
14 novembre 2010, parMediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
Menus créés à l’initialisation du site
Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...) -
Configuration spécifique pour PHP5
4 février 2011, parPHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
Modules spécifiques
Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)
Sur d’autres sites (4612)
-
Progress Bar findviewbyid returns null
1er avril 2017, par ziad kiwanHelp me please it’s getting frustrating !
i’m doing a chat application where i’m adding views to a linear layout programmatically each time a user press the send button the code is below :
public void appendToMessageHistory(String id,String uname, String messa,String messageType, final String filepath, String DownloadStatus,boolean internet,int type) {
//TextView tv=new TextView(Messaging.this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(Width, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 10, 0, 0);
View v = getLayoutInflater().inflate(R.layout.message_entity, null);
TextView mess;
TextView time;
final ImageView iv;
final ProgressBar progressBar;
ImageView statusiv;
if (friend.userName.equals(uname)) {
v = getLayoutInflater().inflate(R.layout.message_entity, null);
v.setId(Integer.parseInt(id));
mess = (TextView) v.findViewById(R.id.message_entity_message);
time = (TextView) v.findViewById(R.id.message_entity_time);
iv = (ImageView) v.findViewById(R.id.message_entity_imageview);
statusiv = (ImageView) v.findViewById(R.id.imageView);
progressBar = (ProgressBar) v.findViewById(R.id.message_entity_progressbar);
} else {
v = getLayoutInflater().inflate(R.layout.message_entity_right, null);
lp.gravity = Gravity.RIGHT;
v.setId(Integer.parseInt(id));
mess = (TextView) v.findViewById(R.id.message_entity_right_message);
time = (TextView) v.findViewById(R.id.message_entity_right_time);
iv = (ImageView) v.findViewById(R.id.message_entity_right_imageview);
statusiv = (ImageView)v.findViewById(R.id.imageViewleft);
progressBar = (ProgressBar) v.findViewById(R.id.message_entity_Right_progressbar);
}
try {
progressBar.setId(Integer.parseInt(id));
} catch (Exception e) {
e.printStackTrace();
}
if (messageType != null) {
if (messageType.equals(MessageInfo.MESSAGE_TYPE_PIC)) {
iv.setImageBitmap(ImageHandlet.GetBitmapFromPath(filepath));
progressBar.setVisibility(View.GONE);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + filepath), "image/png");
startActivity(intent);
Log.d("FIlePAth", filepath);
}
});
} else if (messageType.equals(MessageInfo.MESSAGE_TYPE_VIDEO)) {
if (DownloadStatus.equals(LocalStorageHandler.DOWNLOADED)) {
if(!(friend.userName.equals(uname))) {
if (type != 3) {
Bitmap bitTh = ThumbnailUtils.createVideoThumbnail(filepath, MediaStore.Images.Thumbnails.MINI_KIND);
iv.setImageBitmap(bitTh);
progressBar.setVisibility(View.GONE);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(filepath));
intent.setDataAndType(Uri.parse(filepath), "video/mp4");
startActivity(intent);
}
});
} else {
Log.w("Zipping","Progress Bar");
progressBar.setVisibility(View.VISIBLE);
}
} else {
Bitmap bitTh = ThumbnailUtils.createVideoThumbnail(filepath, MediaStore.Images.Thumbnails.MINI_KIND);
iv.setImageBitmap(bitTh);
progressBar.setVisibility(View.GONE);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(filepath));
intent.setDataAndType(Uri.parse(filepath), "video/mp4");
startActivity(intent);
}
});
}
} else if (DownloadStatus.equals(LocalStorageHandler.NotDOWNLOADED)) {
iv.setTag(id);
iv.setImageResource(R.drawable.download);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
progressBar.setVisibility(View.VISIBLE);
Cursor c = localstoragehandler.getIDnfo(iv.getTag().toString());
String filepath = "";
//Toast.makeText(getApplication(),iv.getTag().toString()+" iD " +iv.getId(),Toast.LENGTH_SHORT).show();
while (c.moveToNext()) {
String msg0 = c.getString(0);
String msg2 = c.getString(2);
String msg3 = c.getString(3);
String msg4 = c.getString(4);
String msg5 = c.getString(5);
String msg6 = c.getString(6);
filepath = msg5;
Log.d("-----------Vedio-----", "------------------");
Log.d("DATABASE---------", msg0);
Log.d("DATABASE-------", msg2);
Log.d("DATABASE---------", msg3);
Log.d("DATABASE-----", msg4 + "");
Log.d("DATABASE-------", msg5 + "");
Log.d("DATABASE----------", msg6 + "");
Log.d("--------END-------", "-------END-----------");
}
Toast.makeText(getApplicationContext(), filepath.toString() + iv.getTag().toString(), Toast.LENGTH_SHORT).show();
DownloadFileFromURL downloadFileFromURL = new DownloadFileFromURL(filepath, iv.getTag().toString());
downloadFileFromURL.execute("");
}
});
}
} else {
iv.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
}
}
if(!(messageType.equals(MessageInfo.MESSAGE_TYPE_VIDEO))) {
if (!internet) {
statusiv.setImageResource(R.drawable.noconnectionl);
}
}
mess.setText(messa);
//time.setText(sendt);
v.setLayoutParams(lp);
final View lastview = v;
runOnUiThread(new Runnable() {
@Override
public void run() {
mEssageBox.addView(lastview);
}
});
scrollView.post(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
messageText.requestFocus();
}
});
}and here is the XML of the dialogbox :
<?xml version="1.0" encoding="utf-8"?>
<relativelayout>
<imageview></imageview>
<relativelayout>
<textview></textview>
<textview></textview>
<imageview></imageview>
<progressbar style="?android:attr/progressBarStyleLarge"></progressbar>
</relativelayout>
</relativelayout>And here is the code to send the video message :
final String message = messageText.getText().toString();
final Long rowid = localstoragehandler.insert(imService.getUsername(), friend.userName, message, MessageInfo.MESSAGE_TYPE_VIDEO, ZippedVideoPath, LocalStorageHandler.DOWNLOADED); //insert data into db and get to chat_id
appendToMessageHistory(rowid + "", imService.getUsername(), message, MessageInfo.MESSAGE_TYPE_VIDEO, ZippedVideoPath, LocalStorageHandler.DOWNLOADED, internet,3);// append the video with type 3 to just display the progress
messageText.setText("Video");
String newstr = null;
// intialize the asynctask to upload the video
class UploadVideo extends AsyncTask {
ProgressDialog uploading;
View V;
UploadVideo(View v){
V = v;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
// uploading = ProgressDialog.show(Messaging.this, "Uploading File", "Please wait...", false, false);
}
@Override
protected String doInBackground(Void... params) {
return imService.sendVideoMessage(imService.getUsername(), friend.userName, message, MessageInfo.MESSAGE_TYPE_VIDEO, "", ZippedVideoPath);
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
// RelativeLayout v = (RelativeLayout) V.findViewById(rowid.intValue());
// Log.w("Zipping",v.toString());
// ProgressBar progressBar1 = (ProgressBar) V.findViewById(R.id.message_entity_Right_progressbar);
// Log.w("Zipping",progressBar1.toString());
// ImageView iv = (ImageView) v.findViewById(R.id.message_entity_right_imageview);
// progressBar1.setVisibility(View.GONE);
// Log.d("POST Execute", s + "");
//textViewResponse.setText(Html.fromHtml("<b>Uploaded at <a href="http://stackoverflow.com/feeds/tag/" + s + "">" + s + "</a></b>"));
//textViewResponse.setMovementMethod(LinkMovementMethod.getInstance());
// here i am preparing the path so when the compress is done to save into.
}
}
if (null != absolute && absolute.length() > 0) {
int endIndex = absolute.lastIndexOf("/");
if (endIndex != -1) {
newstr = absolute.substring(endIndex, absolute.length()); // not forgot to put check if(endIndex != -1)
}
}
Log.w("Zipping", newstr);
final File videosdir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/videos/");
if (!videosdir.exists()) {
videosdir.mkdirs();
}
ZippedVideoPath = videosdir.getAbsolutePath() + "/" + newstr;
Log.w("Zipping", ZippedVideoPath);
// here i got the ffmpeg library from the net to compress the video and i'm preparing the commands
String[] complexCommand = {"-y", "-i", absolute, "-strict", "experimental", "-r", "25", "-vcodec", "mpeg4", "-b:a", "150k", "-ab", "48000", "-ac", "2", "-ar", "22050", ZippedVideoPath};
FFmpeg ffmpeg = FFmpeg.getInstance(getBaseContext());
try {
// to execute "ffmpeg -version" command you just need to pass "-version"
ffmpeg.execute(complexCommand, new ExecuteBinaryResponseHandler() {
@Override
public void onStart() {
Log.w("Zipping", "started");
}
@Override
public void onProgress(String message) {
}
@Override
public void onFailure(String message) {
Log.w("Zipping", message);
}
@Override
public void onSuccess(String message1) {
Log.w("Zipping","Success");
RelativeLayout v = (RelativeLayout) mEssageBox.findViewById(rowid.intValue());
Log.w("VideoView",v.toString());
ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.message_entity_Right_progressbar);
ImageView iv = (ImageView) v.findViewById(R.id.message_entity_right_imageview);
// progressBar.setVisibility(View.GONE);
Bitmap bitTh = ThumbnailUtils.createVideoThumbnail(ZippedVideoPath, MediaStore.Images.Thumbnails.MINI_KIND);
iv.setImageBitmap(bitTh);
progressBar.setVisibility(View.GONE);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(ZippedVideoPath));
intent.setDataAndType(Uri.parse(ZippedVideoPath), "video/mp4");
startActivity(intent);
}
});
UploadVideo uv = new UploadVideo(v);
uv.execute();
}
@Override
public void onFinish() {
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
Log.w("Zipping", e.toString());
}
}okay now to the problem when i call the findviewbyid for the progress bar in sendvideomessage ffmpeg onsuccess callback it returns null even though the findviewbyid for the the imageview which is in the same layout it returns the view ! so please tell me what is the problem
public void onSuccess(String message1) {
Log.w("Zipping","Success");
RelativeLayout v = (RelativeLayout) mEssageBox.findViewById(rowid.intValue()); ;
ProgressBar progressBar = (ProgressBar) v.findViewById(R.id.message_entity_Right_progressbar); // this keeps returning null!
ImageView iv = (ImageView) v.findViewById(R.id.message_entity_right_imageview); // returns the view
// progressBar.setVisibility(View.GONE);
Bitmap bitTh = ThumbnailUtils.createVideoThumbnail(ZippedVideoPath, MediaStore.Images.Thumbnails.MINI_KIND);
iv.setImageBitmap(bitTh);
progressBar.setVisibility(View.GONE);
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(ZippedVideoPath));
intent.setDataAndType(Uri.parse(ZippedVideoPath), "video/mp4");
startActivity(intent);
}
});
UploadVideo uv = new UploadVideo(v);
uv.execute();
}Thank you !
-
Why process output reader returns null data ? When same code in other process works correct
26 août 2019, par Владимир ВодовI try to get output from ffmpeg process but cant get output.
In another processes and commands it works correctly but output returns immideately when start !using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo()
{
FileName = LinkHelper.IPFS_PATH,
Arguments = cmd,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true
};
process.ErrorDataReceived += FfmpegErrorRecieved;
process.Start();
using (StreamReader reader = process.StandardOutput)
{
string output = await reader.ReadToEndAsync();
Console.WriteLine(output);
}
process.WaitForExit();
}Update :
As szatmary said ffmpeg use output error instead standard output, so when you initialize process.StandartInfo don’t forget initialize property "RedirectStandardError" to TRUE !Here is correct code :
private async Task DetectFFmpegCamerasAsync()
{
var cmd = "-list_devices true -f dshow -i dummy";
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo()
{
FileName = LinkHelper.FFMPEG_PATH,
Arguments = cmd,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true
};
process.Start();
using (StreamReader reader = process.StandardError)
{
string output = await reader.ReadToEndAsync();
Console.WriteLine($"Camera detection output: \n {output}");
}
process.WaitForExit();
}
} -
subprocess.py returns a File Not Found error
7 avril 2021, par wasneeplusAs part of a video analysis script I wanted to find the duration of a video file. For this I found the script offered in the first answer to this question : How to get the duration of a video in Python ?


import subprocess

def get_length(filename):
 result = subprocess.run(["ffprobe", "-v", "error", "-show_entries",
 "format=duration", "-of",
 "default=noprint_wrappers=1:nokey=1", filename],
 stdout=subprocess.PIPE,
 stderr=subprocess.STDOUT)
 return float(result.stdout)



This code works fine when my friend runs it in a Jupyter server environment, but when I try it on my laptop the trouble starts.


When I imput the following filename into the function :


filename = "C:\\Users\\benja\\OneDrive - De Haagse Hogeschool\\Onderzoeken 3\\8V.mp4"



I get the following error :


Traceback (most recent call last):
 File "c:/Users/benja/OneDrive - De Haagse Hogeschool/Onderzoeken 3/python_script.py", line 9, in <module>
 num_of_frames = math.floor((pf.get_length(filename) - 1)) * 30
 File "c:\Users\benja\OneDrive - De Haagse Hogeschool\Onderzoeken 3\python_funcs.py", line 21, in get_length
 stderr=subprocess.STDOUT)
 File "C:\Users\benja\Anaconda3\lib\subprocess.py", line 466, in run
 with Popen(*popenargs, **kwargs) as process:
 File "C:\Users\benja\Anaconda3\lib\subprocess.py", line 769, in __init__
 restore_signals, start_new_session)
 File "C:\Users\benja\Anaconda3\lib\subprocess.py", line 1172, in _execute_child
 startupinfo)
FileNotFoundError: [WinError 2] Het systeem kan het opgegeven bestand niet vinden
</module>


I do realise that my problem is almost identical to that of several other questions on here. However, their solutions don't seem to work for me. I have tried to :


- 

- Add the location of ffmpeg-win64-4.2.2.exe to the Path system variable.
- Add the location of python.exe to the ComSpec system variable.
- Put the videofile in the same directory as the script.








I would be most grateful if someone could point me in the right direction. Thank you in advance.