
Recherche avancée
Autres articles (13)
-
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
-
Keeping control of your media in your hands
13 avril 2011, parThe vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...) -
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 is the first MediaSPIP stable release.
Its official release date is June 21, 2013 and is announced here.
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)
Sur d’autres sites (3910)
-
How to manipulate a Uri as File in android
3 juin 2021, par Omid.NI am trying to use FFmpeg in android. As you know the framework no longer lets you to use absolute paths or open files freely even with WRITE_EXTERNAL_STORAGE permission :|

So, using the SAF, I get the file as an Uri, then I need to put it as an argument to ffmpeg to encode it but it only accepts file paths.

How can i achieve this ?


Note : There are some bad practices in my code but I hope we can ignore them for now because that's not the problem here :)


public class MainActivity extends AppCompatActivity {

 private static final int PICK_VIDEO_FILE = 2;

 private static final String TAG = "MainActivity";
 
 File theFile;
 TextView textView;

 @Override
 protected void onCreate(Bundle savedInstanceState) {


 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);

 textView = (TextView) findViewById(R.id.text_view);

 
 if (theFile == null) {
 openFile(Uri.fromFile(new File("/storage/emulated/0/")));
 }


 }

 @Override
 protected void onResume() {
 super.onResume();
 if (theFile !=null) {

 FFmpegSession fFmpegSession = FFmpegKit.executeAsync("-i " + theFile.getAbsolutePath()
 + " -c:v mpeg4 file:///storage/emulated/0/out.mp4",
 new ExecuteCallback() {
 @Override
 public void apply(Session session) {

 }
 });
 try {
 Thread.sleep(5000);
 } catch (InterruptedException e) {
 e.printStackTrace();
 }
 textView.setText("" + fFmpegSession.getState().name() + " " + fFmpegSession.getOutput());
 }
 }

 private void openFile(Uri pickerInitialUri) {
 Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
 intent.addCategory(Intent.CATEGORY_OPENABLE);
 intent.setType("video/mp4");
 
 // Optionally, specify a URI for the file that should appear in the
 // system file picker when it loads.
 intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, pickerInitialUri);

 startActivityForResult(intent, PICK_VIDEO_FILE);
 }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {

 super.onActivityResult(requestCode, resultCode, data);
 if (requestCode == PICK_VIDEO_FILE) {
 if (resultCode == RESULT_OK) {
 theFile = new File(data.getData().getPath());
 }
 }

 }




-
How to get a file converted by ffmpeg in Android : permission denied
2 juin 2021, par Omid.NI am trying to use FFmpeg in my android app. So I want to test it if it works before moving on. I use an external library : github link

The code looks like this :

package net.omidn.aslanmediaconverter;

import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.arthenica.ffmpegkit.ExecuteCallback;
import com.arthenica.ffmpegkit.FFmpegKit;
import com.arthenica.ffmpegkit.FFmpegSession;
import com.arthenica.ffmpegkit.Session;

import net.bramp.ffmpeg.job.FFmpegJob;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;


public class MainActivity extends AppCompatActivity {
 
 private static final String TAG = "MainActivity";
 FFmpegJob myjob;

 @Override
 protected void onCreate(Bundle savedInstanceState) {


 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);

 TextView textView = (TextView) findViewById(R.id.text_view);


 FFmpegJob job = null;

 File inFile = new File("/storage/emulated/0/video_2021-05-29_17-50-20.mp4");
 String inputName = Uri.fromFile(inFile).toString();
 Log.d(TAG, inputName);
 Log.d(TAG,"file exists : " + String.valueOf(inFile.exists()));
 Log.d(TAG,"file canRead : " + String.valueOf(inFile.canRead()));

 FFmpegSession fFmpegSession = FFmpegKit.executeAsync("-i file:///storage/emulated/0/video_2021-05-29_17-50-20.mp4 -c:v mpeg4 file:///storage/emulated/0/out.mp4",
 new ExecuteCallback() {
 @Override
 public void apply(Session session) {

 }
 });
 try {
 Thread.sleep(5000);
 } catch (InterruptedException e) {
 e.printStackTrace();
 }
 textView.setText("" + fFmpegSession.getState().name() + " " + fFmpegSession.getOutput());
 }

}




As you can see I give the files with
file:///
protocol. If I don't use that the resault is the same. The three lines ofLog.d(...)
will print :

2021-06-03 00:58:08.869 8376-8376/net.omidn.aslanmediaconverter D/MainActivity: file:///storage/emulated/0/video_2021-05-29_17-50-20.mp4
2021-06-03 00:58:08.869 8376-8376/net.omidn.aslanmediaconverter D/MainActivity: file exists : true
2021-06-03 00:58:08.869 8376-8376/net.omidn.aslanmediaconverter D/MainActivity: file canRead : false



The video file has read access on the storage :



-
Live555 Multicast RTSP Server - Display in FFMPEG
31 mai 2021, par BanBI made a multicast RTSP server using the Live555 library.

It is displayed by VLC but not from VMS (NX Witness) or FFMPEG.

If I use the Unicast, I can display it, but I do not know how to change the file that is streaming in the Unicast.

Is there a way to change the streaming file in Unicast or make it viewable in FFMPEG with Multicast ?

This is my code.




Header




#include <iostream>
#include <string>
#include <filesystem>
#include <fstream>
#include <ctime>
#include 
#include 
#include 
#include <opencv2></opencv2>videoio.hpp>
#include <opencv2></opencv2>imgcodecs.hpp>

void Start(const char* streamPath, int port);
void AddDataL(BYTE* data, int length);
AddDataHW(BYTE* data, int height, int width);

void Play();
void AfterPlaying(void*);

void EncodeToH264(cv::Mat image);
long long GetTimeMs();
int GetFileCount();
const char* GetFirstFilePath();

const int fourcc = cv::VideoWriter::fourcc('x', '2', '6', '4');

UsageEnvironment* env;
H264ServerMediaSubsession* h264;
H264VideoStreamFramer* videoSource;
RTPSink* videoSink;

const char* dataPath = "data/";
const char* extension = ".h264";
</ctime></fstream></filesystem></string></iostream>




CPP




void Start()
{
 askScheduler *scheduler = BasicTaskScheduler::createNew();
 env = BasicUsageEnvironment::createNew(*scheduler);

 RTSPServer *rtspServer = RTSPServer::createNew(*env, 8554);

 if (rtspServer == NULL)
 throw;

 struct sockaddr_storage destinationAddress;
 destinationAddress.ss_family = AF_INET;
 ((struct sockaddr_in &)destinationAddress).sin_addr.s_addr = chooseRandomIPv4SSMAddress(*env);

 const unsigned short rtpPortNum = 18888;
 const unsigned short rtcpPortNum = rtpPortNum + 1;
 const unsigned char ttl = 255;

 const Port rtpPort(rtpPortNum);
 const Port rtcpPort(rtcpPortNum);

 Groupsock rtpGroupsock(*env, destinationAddress, rtpPort, ttl);
 rtpGroupsock.multicastSendOnly();
 Groupsock rtcpGroupsock(*env, destinationAddress, rtcpPort, ttl);
 rtcpGroupsock.multicastSendOnly();

 OutPacketBuffer::maxSize = 300000;
 videoSink = H264VideoRTPSink::createNew(*env, &rtpGroupsock, 96);

 const unsigned estimatedSessionBandwidth = 5000;
 const unsigned maxCNAMElen = 100;
 unsigned char CNAME[maxCNAMElen + 1];
 gethostname((char *)CNAME, maxCNAMElen);
 CNAME[maxCNAMElen] = '\0';

 RTCPInstance *rtcp = RTCPInstance::createNew(*env, &rtcpGroupsock, estimatedSessionBandwidth, CNAME, videoSink, NULL, True);

 ServerMediaSession *sms = ServerMediaSession::createNew(*env, "live", "live", "Session streamed by \"Test Server\"", True);
 sms->addSubsession(PassiveServerMediaSubsession::createNew(*videoSink, rtcp));
 rtspServer->addServerMediaSession(sms);

 *env << "Start > " << rtspServer->rtspURL(sms) << "\n";

 Play();

 env->taskScheduler().doEventLoop();
}

void AddData(BYTE* data, int length)
{
 EncodeToH264(cv::imdecode(cv::Mat(1, length, CV_8UC3, data), 1));
}

void EncodeToH264(cv::Mat image)
{
 std::string fileName = dataPath + std::to_string(GetTimeMs()) + extension;
 cv::VideoWriter writer(fileName.c_str(), fourcc, 1, image.size());
 writer.write(image);
 writer.write(image);
 writer.release();
}

void Play()
{
 while (GetFileCount() == 0);

 const char* fileName = GetFirstFilePath();

 ByteStreamFileSource* fileSource;
 while ((fileSource = ByteStreamFileSource::createNew(*env, fileName)) == NULL);

 FramedSource* videoES = fileSource;

 videoSource = H264VideoStreamFramer::createNew(*env, videoES);

 videoSink->startPlaying(*videoSource, AfterPlaying, videoSink);
}

void AfterPlaying(void*)
{
 videoSink->stopPlaying();
 Medium::close(videoSource);

 if (GetFileCount() > 1)
 std::filesystem::remove(GetFirstFilePath());

 Play();
}

long long GetTimeMs()
{
 return std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count();
}

int GetFileCount() 
{
 return std::distance(std::filesystem::directory_iterator(dataPath), std::filesystem::directory_iterator());
}

const char* GetFirstFilePath()
{
 for (const auto& entry : std::filesystem::directory_iterator(dataPath))
 return entry.path().string().c_str();
}