
Recherche avancée
Autres articles (28)
-
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page. -
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 ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)
Sur d’autres sites (6075)
-
Spotlight : Alwaysdata.com the company behind Piwik.org web hosting [Interview]
Piwik is the result of the work of many talented individuals and companies. Today we’d like to showcase Alwaysdata.com, the awesome web hosting company providing managed hosting for all Piwik.org websites and services.
I recently met and asked a few questions to Cyril, co-founder of Alwaysdata.com and Piwik core developer. Learn more in the interview below !
What is Alwaysdata ?
We are a French web hosting company created in 2006. If you need to host a website — a Piwik installation, for example — or even your domains/emails, we provide infrastructure and maintenance services.
Who are your customers and what kind of work do you do ?
We have several types of clients :
- Individuals who need hosting for their personal site and who benefit from storage space with direct SSH access.
- Web agencies who need hosting for their clients’ sites.
- The largest customers, often on dedicated servers, for hosting their site/infrastructure.
Our work falls into three categories :
- Support (via administration, telephone, Twitter, IRC, etc.)
- Development (in Python), primarily to add new features
- System administration, either for maintenance (e.g. adding servers), or for preparing new features
What sets Alwaysdata apart from the large web hosting competition ?
Two things :
- Availability. We are a small team and often know our customers quite well. We are all on IRC, so you can contact us directly if you need any assistance.
- Features. We are halfway between traditional web hosting and the cloud, combining the advantages of both.
Are you using Piwik internally or with customers ? If so, how are you using Piwik ?
All of our customers can view statistics for their sites via our global Piwik installation, without having to configure anything.
To provide these analytics reports to our customers, we implemented import of the raw access logs in Piwik. The Log import toolkit is now a feature included in Piwik.
What is the next big thing for Alwaysdata ?
We are going to upgrade our pricing : instead of fixed costs, each of our clients will now pay exactly what they consume. This allows our clients the benefit of a very high quality service for the lowest possible price.
We are also going to add native support for more technologies : Java, Node.js, ZeroMQ, etc.
Thank you for your time and all the best to Alwaysdata for the future !
—
Note from Matt, Piwik founder : Cyril and the team at Alwaysdata.com have been consistently great in their system administration work for Piwik.org services, providing a fast and reliable web hosting experience with top notch support and security practises. They also handled the migration of all services from our old servers with total piece of mind.
Alwaysdata contributed to Piwik the popular Log Analytics toolkit. They are great software developers and system administrators with a passion for their work. Since 2006, they have been maintaining optimized hosting services for the entire web infrastructure (websites, domains, emails, databases, etc.), from the simplest to the most exotic. We do recommend their managed hosting services.
Learn more
- Visit their website at Alwaysdata.com
- Learn more about their Managed hosting on dedicated servers
- Learn more about other companies and individuals who make a difference in Piwik.
-
Uploading video to Twitter sometimes doesn't work
22 juillet 2021, par K-s S-kI have a very difficult situation. I've already spent 2 days and couldn't find a solution. Project on Laravel. I want to upload videos to Twitter using the Twitter API endpoints. But sometimes I am getting this error :




file is currently unsupported




I did everything as recommended in the official documentation Video specifications and recommendations. I get an error when I set an audio codec is aac in my video file, despite the fact that it is recommended in the official documentation, but when I set the audio codec to mp3, the video is uploaded, but the sound quality is very poor, and sometimes there is no sound at all. Please forgive me if this is awkward to read, but I want to provide all of my code. Because I don't know how to solve this anymore and I think it might help.


<?php

namespace App\Jobs;

use App\Models\PublishedContent;
use Atymic\Twitter\Facades\Twitter;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\File;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Str;


class PublishToTwitter implements ShouldQueue
{
 use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

 /**
 * @var
 */
 protected $publishingData;

 /**
 * Create a new job instance.
 *
 * @param $publishingData
 */
 public function __construct($publishingData)
 {
 $this->publishingData = $publishingData;
 }

 /**
 * Execute the job.
 *
 * @return void
 */
 public function handle()
 {
 $publishingData = $this->publishingData;

 if (is_array($publishingData)) {
 $publishingResult = $this->publishing(...array_values($publishingData));
 sendNotification($publishingResult['message'], $publishingResult['status'], 'Twitter', $publishingResult['link'], $publishingData['post_name'], $publishingData['user']);
 } else {
 $scheduledData = processingScheduledPost($publishingData);
 $postName = $scheduledData['scheduleData']['post_name'];
 $postContent = $scheduledData['scheduleData']['post_content'];
 $userToken = json_decode($publishingData->user_token,true);
 $requestToken = [
 'token' => $userToken['oauth_token'],
 'secret' => $userToken['oauth_token_secret'],
 ];
 $publishingResult = $this->publishing($scheduledData['file'], $postName, $postContent, $requestToken);
 $publishingResult['status'] && PublishedContent::add($scheduledData['craft'], $scheduledData['file'], "twitter_share");
 sendResultToUser($publishingData, $scheduledData['user'], $publishingResult['message'], $postName, $publishingResult['link'], $publishingResult['publishing_status'], $scheduledData['social_media']);
 sendNotification($publishingResult['message'], $publishingResult['status'], 'Twitter', $publishingResult['link'], $postName, $scheduledData['user']);
 }
 }

 /**
 * @param $file
 * @param $postName
 * @param $postContent
 * @param $requestToken
 * @return array
 */
 private function publishing($file, $postName, $postContent, $requestToken): array
 {
 $result = [
 'status' => false,
 'link' => null,
 'message' => 'Your content can\'t successfully published on Twitter. This file is not supported for publishing.',
 'publishing_status' => 'error'
 ];

 if ((($file->refe_type !== 'text') || $file->refe_file_path) && !checkIfFileExist($file->refe_file_path)) {
 $result['message'] = 'Missing or invalid file.';
 return $result;
 }

 $filePath = $file->refe_file_path;
 $fileSize = $file->content_length;
 $tempFileName = 'temp-' . $file->refe_file_name;
 $ext = $file->file_type;
 $mediaCategory = 'tweet_' . $file->refe_type;
 $mediaType = $file->refe_type . '/' . $ext;
 $remoteFile = file_get_contents($filePath);
 $tempFolder = public_path('/storage/uploads/temp');

 if (!file_exists($tempFolder)) {
 mkdir($tempFolder, 0777, true);
 }

 $tempFile = public_path('/storage/uploads/temp/' . $tempFileName);
 File::put($tempFile, $remoteFile);
 $convertedFileName = 'converted-' . $file->refe_file_name;
 $convertedFile = public_path('/storage/uploads/temp/' . $convertedFileName);
 $command = 'ffmpeg -y -i '.$tempFile.' -b:v 5000k -b:a 380k -c:a aac -profile:a aac_low -threads 1 '.$convertedFile.'';
 exec($command);
 @File::delete($tempFile);

 try {
 $twitter = Twitter::usingCredentials($requestToken['token'], $requestToken['secret']);
 if ($file->refe_type === 'text') {
 $twitter->postTweet([
 'status' => urldecode($postContent),
 'format' => 'json',
 ]);

 $result['link'] = 'https://twitter.com/home';
 $result['status'] = true;
 $result['message'] = 'Your content successfully published on Twitter. You can visit to Twitter and check it.';
 $result['publishing_status'] = 'done';
 } else if ($file->refe_type === 'video' || $file->refe_type === 'image') {
 if ($file->refe_type === 'video') {
 $duration = getVideoDuration($file->refe_file_path);

 if ($duration > config('constant.sharing_configs.max_video_duration.twitter')) {
 throw new \Exception('The duration of the video file must not exceed 140 seconds.');
 }
 }

 $isFileTypeSupported = checkPublishedFileType('twitter', $file->refe_type, strtolower($ext));
 $isFileSizeSupported = checkPublishedFileSize('twitter', $file->refe_type, $fileSize, strtolower($ext));

 if (!$isFileTypeSupported) {
 throw new \Exception('Your content can\'t successfully published on Twitter. This file type is not supported for publishing.');
 }

 if (!$isFileSizeSupported) {
 throw new \Exception('Your content can\'t successfully published on Twitter. The file size is exceeded.');
 }

 if ($file->refe_type === 'video') $fileSize = filesize($convertedFile);

 if (strtolower($ext) === 'gif') {
 $initMedia = $twitter->uploadMedia([
 'command' => 'INIT',
 'total_bytes' => (int)$fileSize
 ]);
 } else {
 $initMedia = $twitter->uploadMedia([
 'command' => 'INIT',
 'media_type' => $mediaType,
 'media_category' => $mediaCategory,
 'total_bytes' => (int)$fileSize
 ]);
 }

 $mediaId = (int)$initMedia->media_id_string;

 $fp = fopen($convertedFile, 'r');
 $segmentId = 0;

 while (!feof($fp)) {
 $chunk = fread($fp, 1048576);

 $twitter->uploadMedia([
 'media_data' => base64_encode($chunk),
 'command' => 'APPEND',
 'segment_index' => $segmentId,
 'media_id' => $mediaId
 ]);

 $segmentId++;
 }

 fclose($fp);

 $twitter->uploadMedia([
 'command' => 'FINALIZE',
 'media_id' => $mediaId
 ]);

 if ($file->refe_type === 'video') {
 $waits = 0;

 while ($waits <= 4) {
 // Authorizing header for Twitter API
 $oauth = [
 'command' => 'STATUS',
 'media_id' => $mediaId,
 'oauth_consumer_key' => config('twitter.consumer_key'),
 'oauth_nonce' => Str::random(42),
 'oauth_signature_method' => 'HMAC-SHA1',
 'oauth_timestamp' => time(),
 'oauth_token' => $requestToken['token'],
 'oauth_version' => '1.0'
 ];

 // Generate an OAuth 1.0a HMAC-SHA1 signature for an HTTP request
 $baseInfo = $this->buildBaseString('https://upload.twitter.com/1.1/media/upload.json', 'GET', $oauth);
 // Getting a signing key
 $compositeKey = rawurlencode(config('twitter.consumer_secret')) . '&' . rawurlencode($requestToken['secret']);
 // Calculating the signature
 $oauthSignature = base64_encode(hash_hmac('sha1', $baseInfo, $compositeKey, true));
 $oauth['oauth_signature'] = $oauthSignature;
 $headers['Authorization'] = $this->buildAuthorizationHeader($oauth);

 try {
 $guzzle = new GuzzleClient([
 'headers' => $headers
 ]);
 $response = $guzzle->request( 'GET', 'https://upload.twitter.com/1.1/media/upload.json?command=STATUS&media_id=' . $mediaId);
 $uploadStatus = json_decode($response->getBody()->getContents());
 } catch (\Exception | GuzzleException $e) {
 dd($e->getMessage(), $e->getLine(), $e->getFile());
 }

 if (isset($uploadStatus->processing_info->state)) {
 switch ($uploadStatus->processing_info->state) {
 case 'succeeded':
 $waits = 5; // break out of the while loop
 break;
 case 'failed':
 File::delete($tempFile);
 Log::error('File processing failed: ' . $uploadStatus->processing_info->error->message);
 throw new \Exception('File processing failed: ' . $uploadStatus->processing_info->error->message);
 default:
 sleep($uploadStatus->processing_info->check_after_secs);
 $waits++;
 }
 } else {
 throw new \Exception('There was an unknown error uploading your file');
 }
 }
 }

 $twitter->postTweet(['status' => urldecode($postContent), 'media_ids' => $initMedia->media_id_string]);
 @File::delete($convertedFile);
 $result['link'] = 'https://twitter.com/home';
 $result['status'] = true;
 $result['message'] = 'Your content successfully published on Twitter. You can visit to Twitter and check it.';
 $result['publishing_status'] = 'done';
 }
 } catch (\Exception $e) {
 dd($e->getMessage());
 $result['message'] = $e->getMessage();
 return $result;
 }

 return $result;
 }

 /**
 * @param $baseURI
 * @param $method
 * @param $params
 * @return string
 *
 * Creating the signature base string
 */
 protected function buildBaseString($baseURI, $method, $params): string
 {
 $r = array();
 ksort($params);
 foreach($params as $key=>$value){
 $r[] = "$key=" . rawurlencode($value);
 }
 return $method . "&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $r));
 }

 /**
 * @param $oauth
 * @return string
 *
 * Collecting parameters
 */
 protected function buildAuthorizationHeader($oauth): string
 {
 $r = 'OAuth ';
 $values = array();
 foreach($oauth as $key=>$value)
 $values[] = "$key=\"" . rawurlencode($value) . "\"";
 $r .= implode(', ', $values);
 return $r;
 }
}




I would be very grateful if someone would help me.


-
Manage multipe IP cameras at the same time
4 juin 2015, par AlessioHow I can manage multiple GoPro cameras at the same time ? I want to stream three videos of three GoPro cameras at the same time and record the videos on the hard disk.
I have written a tool in Java for one GoPro and it works correctly.
Help me please !
This is the code :
public class GoProStreamer extends JFrame {
private static final String CAMERA_IP = "10.5.5.9";
private static int PORT = 8080;
private static DatagramSocket mOutgoingUdpSocket;
private Process streamingProcess;
private Process writeVideoProcess;
private KeepAliveThread mKeepAliveThread;
private JPanel contentPane;
public GoProStreamer() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(800, 10, 525, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JButton btnStop = new JButton("Stop stream");
JButton btnStart = new JButton("Start stream");
JButton btnRec = new JButton("Rec");
JButton btnStopRec = new JButton("Stop Rec");
// JButton btnZoomIn = new JButton("Zoom In sincrono");
// JButton btnZoomOut = new JButton("Zoom out sincrono");
// JButton btnZoomIn1 = new JButton("Zoom In Camera 1");
// JButton btnZoomOut1 = new JButton("Zoom out Camera 1");
// JButton btnZoomIn2 = new JButton("Zoom in Camera 2");
// JButton btnZoomOut2 = new JButton("Zoom out Camera 2");
// JButton btnZoomIn3 = new JButton("Zoom in camera 3");
// JButton btnZoomOut3 = new JButton("Zoom out Camera 3");
btnStop.setEnabled(false);
btnRec.setEnabled(false);
btnStopRec.setEnabled(false);
// btnZoomIn.setEnabled(false);
// btnZoomOut.setEnabled(false);
// btnZoomIn1.setEnabled(false);
// btnZoomOut1.setEnabled(false);
// btnZoomIn2.setEnabled(false);
// btnZoomOut2.setEnabled(false);
// btnZoomIn3.setEnabled(false);
// btnZoomOut3.setEnabled(false);
JPanel panel = new JPanel();
// JPanel panel2 = new JPanel();
// JPanel panel3 = new JPanel();
// JPanel panel4 = new JPanel();
panel.add(btnStart);
panel.add(btnStop);
panel.add(btnRec);
panel.add(btnStopRec);
// panel2.add(btnZoomIn1);
// panel3.add(btnZoomOut1);
// panel2.add(btnZoomIn2);
// panel3.add(btnZoomOut2);
// panel2.add(btnZoomIn3);
// panel3.add(btnZoomOut3);
// panel4.add(btnZoomIn);
// panel4.add(btnZoomOut);
contentPane.add(panel, BorderLayout.SOUTH);
// contentPane.add(panel2, BorderLayout.NORTH);
// contentPane.add(panel3, BorderLayout.CENTER);
btnStart.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
startStreamService();
keepAlive();
startStreaming();
btnStart.setEnabled(false);
btnStop.setEnabled(true);
btnRec.setEnabled(true);
btnStopRec.setEnabled(false);
// btnZoomIn.setEnabled(true);
// btnZoomOut.setEnabled(true);
// btnZoomIn1.setEnabled(true);
// btnZoomOut1.setEnabled(true);
// btnZoomIn2.setEnabled(true);
// btnZoomOut2.setEnabled(true);
// btnZoomIn3.setEnabled(true);
// btnZoomOut3.setEnabled(true);
}
});
btnStop.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
stopStreaming();
stopKeepalive();
btnStart.setEnabled(true);
btnStop.setEnabled(false);
btnRec.setEnabled(false);
btnStopRec.setEnabled(false);
}
});
btnRec.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
startRec();
btnStart.setEnabled(false);
btnStop.setEnabled(false);
btnRec.setEnabled(false);
btnStopRec.setEnabled(true);
}
});
btnStopRec.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
stopRec();
btnStart.setEnabled(false);
btnStop.setEnabled(true);
btnRec.setEnabled(true);
btnStopRec.setEnabled(false);
}
});
}
private void startStreamService() {
HttpURLConnection localConnection = null;
try {
String str = "http://" + CAMERA_IP + "/gp/gpExec?p1=gpStreamA9&c1=restart";
localConnection = (HttpURLConnection) new URL(str).openConnection();
localConnection.addRequestProperty("Cache-Control", "no-cache");
localConnection.setConnectTimeout(5000);
localConnection.setReadTimeout(5000);
int i = localConnection.getResponseCode();
if (i >= 400) {
throw new IOException("sendGET HTTP error " + i);
}
}
catch (Exception e) {
}
if (localConnection != null) {
localConnection.disconnect();
}
}
@SuppressWarnings("static-access")
private void sendUdpCommand(int paramInt) throws SocketException, IOException {
Locale localLocale = Locale.US;
Object[] arrayOfObject = new Object[4];
arrayOfObject[0] = Integer.valueOf(0);
arrayOfObject[1] = Integer.valueOf(0);
arrayOfObject[2] = Integer.valueOf(paramInt);
arrayOfObject[3] = Double.valueOf(0.0D);
byte[] arrayOfByte = String.format(localLocale, "_GPHD_:%d:%d:%d:%1f\n", arrayOfObject).getBytes();
String str = CAMERA_IP;
int i = PORT;
DatagramPacket localDatagramPacket = new DatagramPacket(arrayOfByte, arrayOfByte.length, new InetSocketAddress(str, i));
this.mOutgoingUdpSocket.send(localDatagramPacket);
}
private void startStreaming() {
Thread threadStream = new Thread() {
@Override
public void run() {
try {
streamingProcess = Runtime.getRuntime().exec("ffmpeg-20150318-git-0f16dfd-win64-static\\bin\\ffplay -i http://10.5.5.9:8080/live/amba.m3u8");
InputStream errorStream = streamingProcess.getErrorStream();
byte[] data = new byte[1024];
int length = 0;
while ((length = errorStream.read(data, 0, data.length)) > 0) {
System.out.println(new String(data, 0, length));
System.out.println(System.currentTimeMillis());
}
} catch (IOException e) {
}
}
};
threadStream.start();
}
private void startRec() {
Thread threadRec = new Thread() {
@Override
public void run() {
try {
writeVideoProcess = Runtime.getRuntime().exec("ffmpeg-20150318-git-0f16dfd-win64-static\\bin\\ffmpeg -re -i http://10.5.5.9:8080/live/amba.m3u8 -c copy -an Video_GoPro_" + Math.random() + ".avi");
InputStream errorRec = writeVideoProcess.getErrorStream();
byte[] dataRec = new byte[1024];
int lengthRec = 0;
while ((lengthRec = errorRec.read(dataRec, 0, dataRec.length)) > 0) {
System.out.println(new String(dataRec, 0, lengthRec));
System.out.println(System.currentTimeMillis());
}
} catch (IOException e) {
}
}
};
threadRec.start();
}
private void keepAlive() {
mKeepAliveThread = new KeepAliveThread();
mKeepAliveThread.start();
}
class KeepAliveThread extends Thread {
public void run() {
try {
Thread.currentThread().setName("gopro");
if (mOutgoingUdpSocket == null) {
mOutgoingUdpSocket = new DatagramSocket();
}
while ((!Thread.currentThread().isInterrupted()) && (mOutgoingUdpSocket != null)) {
sendUdpCommand(2);
Thread.sleep(2500L);
}
}
catch (SocketException e) {
}
catch (InterruptedException e) {
}
catch (Exception e) {
}
}
}
private void stopStreaming() {
if (streamingProcess != null) {
streamingProcess.destroy();
streamingProcess = null;
}
stopKeepalive();
mOutgoingUdpSocket.disconnect();
mOutgoingUdpSocket.close();
}
private void stopRec() {
writeVideoProcess.destroy();
writeVideoProcess = null;
}
private void stopKeepalive() {
if (mKeepAliveThread != null) {
mKeepAliveThread.interrupt();
try {
mKeepAliveThread.join(10L);
mKeepAliveThread = null;
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
public static void main(String[] args) {
GoProStreamer streamer = new GoProStreamer();
streamer.setVisible(true);
streamer.setTitle("Pannello di controllo");
}}