
Recherche avancée
Autres articles (60)
-
Pas question de marché, de cloud etc...
10 avril 2011Le vocabulaire utilisé sur ce site essaie d’éviter toute référence à la mode qui fleurit allègrement
sur le web 2.0 et dans les entreprises qui en vivent.
Vous êtes donc invité à bannir l’utilisation des termes "Brand", "Cloud", "Marché" etc...
Notre motivation est avant tout de créer un outil simple, accessible à pour tout le monde, favorisant
le partage de créations sur Internet et permettant aux auteurs de garder une autonomie optimale.
Aucun "contrat Gold ou Premium" n’est donc prévu, aucun (...) -
Contribute to documentation
13 avril 2011Documentation 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 (...) -
Selection of projects using MediaSPIP
2 mai 2011, parThe examples below are representative elements of MediaSPIP specific uses for specific projects.
MediaSPIP farm @ Infini
The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)
Sur d’autres sites (5784)
-
How to manipulate files by ffmpeg in Android 31 : permission denied
17 septembre 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 :



-
FFmpeg Overwiting Playlist
30 septembre 2024, par Program-Me-RevI'm working on an implementation where I aim to generate a DASH Playlist from Raw Camera2 data in Android Java using FFmpeg


However , the current implementation only produces Three .m4s files regardless of how long the recording lasts . My goal is to create a playlist with 1-second .m4s Segments , but the output only includes the following files , and the video length doesn't exceed 2 seconds :


- playlist.mpd
- init.m4s
- 1.m4s
- 2.m4s



While the temporary files are created as expected , the .m4s files stop after these two segments . Additionally , only the last 2 seconds of the recording are retained , no matter how long the recording runs


The FFmpeg output indicates that FFmpeg is repeatedly overwriting the previously generated playlist , which may explain why the recording doesn't extend beyond 2 seconds


FFmpeg version : 6.0


package rev.ca.rev_media_dash_camera2;

 import android.app.Activity;
 import android.content.Context;
 import android.media.Image;
 import android.util.Log;
 import android.util.Size;

 import androidx.annotation.NonNull;
 import androidx.camera.core.CameraSelector;
 import androidx.camera.core.ImageAnalysis;
 import androidx.camera.core.ImageProxy;
 import androidx.camera.core.Preview;
 import androidx.camera.lifecycle.ProcessCameraProvider;
 import androidx.camera.view.PreviewView;
 import androidx.core.content.ContextCompat;
 import androidx.lifecycle.LifecycleOwner;

 import com.arthenica.ffmpegkit.FFmpegKit;
 import com.arthenica.ffmpegkit.ReturnCode;
 import com.google.common.util.concurrent.ListenableFuture;

 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;

 public class RevCameraCapture {
 private static final String REV_TAG = "RevCameraCapture";

 private final Context revContext;
 private final ExecutorService revExecutorService;
 private final String revOutDirPath = "/storage/emulated/0/Documents/Owki/rev_web_rtc_live_chat_temp_files/_abc_rev_uploads_temp";
 private boolean isRevRecording;
 private File revTempFile;
 private int revFrameCount = 0; // Counter for frames captured

 public RevCameraCapture(Context revContext) {
 this.revContext = revContext;

 revInitDir(revOutDirPath);
 revCheckOrCreatePlaylist();

 revExecutorService = Executors.newSingleThreadExecutor();
 }

 private void revInitDir(String revDirPath) {
 // Create a File object for the directory
 File revNestedDir = new File(revDirPath);

 // Check if the directory exists, if not, create it
 if (!revNestedDir.exists()) {
 boolean revResult = revNestedDir.mkdirs(); // mkdirs() creates the whole path
 if (revResult) {
 Log.e(REV_TAG, ">>> Directories created successfully.");
 } else {
 Log.e(REV_TAG, ">>> Failed to create directories.");
 }
 } else {
 Log.e(REV_TAG, ">>> Directories already exist.");
 }
 }

 private void revCheckOrCreatePlaylist() {
 File revPlaylistFile = new File(revOutDirPath, "rev_playlist.mpd");
 if (!revPlaylistFile.exists()) {
 // Create an empty playlist if it doesn't exist
 try {
 FileOutputStream revFos = new FileOutputStream(revPlaylistFile);
 revFos.write("".getBytes());
 revFos.close();
 } catch (IOException e) {
 Log.e(REV_TAG, ">>> Error creating initial rev_playlist : ", e);
 }
 }
 }


 private void revStartFFmpegProcess() {
 // Ensure revTempFile exists before processing
 if (revTempFile == null || !revTempFile.exists()) {
 Log.e(REV_TAG, ">>> Temporary file does not exist for FFmpeg processing.");
 return;
 }

 // FFmpeg command to convert the temp file to DASH format and append to the existing rev_playlist
 String ffmpegCommand = "-f rawvideo -pixel_format yuv420p -video_size 704x704 " + "-i " + revTempFile.getAbsolutePath() + " -c:v mpeg4 -b:v 1M " + "-f dash -seg_duration 1 -use_template 1 -use_timeline 1 " + "-init_seg_name 'init.m4s' -media_seg_name '$Number$.m4s' " + revOutDirPath + "/rev_playlist.mpd -loglevel debug";


 FFmpegKit.executeAsync(ffmpegCommand, session -> {
 ReturnCode returnCode = session.getReturnCode();
 if (ReturnCode.isSuccess(returnCode)) {
 // Optionally handle success, e.g., log or notify that the process completed successfully
 } else {
 Log.e(REV_TAG, ">>> FFmpeg process failed with return code : " + returnCode);
 }
 });
 }


 public void revStartCamera() {
 isRevRecording = true;

 ListenableFuture<processcameraprovider> revCameraProviderFuture = ProcessCameraProvider.getInstance(revContext);

 revCameraProviderFuture.addListener(() -> {
 try {
 ProcessCameraProvider revCameraProvider = revCameraProviderFuture.get();
 revBindPreview(revCameraProvider);
 revBindImageAnalysis(revCameraProvider);
 } catch (ExecutionException | InterruptedException e) {
 Log.e(REV_TAG, ">>> Failed to start camera : ", e);
 }
 }, ContextCompat.getMainExecutor(revContext));
 }

 private void revBindPreview(ProcessCameraProvider revCameraProvider) {
 CameraSelector revCameraSelector = new CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build();

 PreviewView previewView = ((Activity) revContext).findViewById(R.id.previewView);
 Preview preview = new Preview.Builder().build();
 preview.setSurfaceProvider(previewView.getSurfaceProvider());

 revCameraProvider.unbindAll();
 revCameraProvider.bindToLifecycle((LifecycleOwner) revContext, revCameraSelector, preview);
 }

 private void revBindImageAnalysis(@NonNull ProcessCameraProvider revCameraProvider) {
 ImageAnalysis revImageAnalysis = new ImageAnalysis.Builder().setTargetResolution(new Size(640, 480)) // Lower the resolution to reduce memory consumption
 .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST).build();

 revImageAnalysis.setAnalyzer(ContextCompat.getMainExecutor(revContext), this::revAnalyze);
 CameraSelector revCameraSelector = new CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build();

 revCameraProvider.bindToLifecycle((LifecycleOwner) revContext, revCameraSelector, revImageAnalysis);
 }

 @androidx.annotation.OptIn(markerClass = androidx.camera.core.ExperimentalGetImage.class)
 private void revAnalyze(@NonNull ImageProxy revImageProxy) {
 try {
 revProcessImageFrame(revImageProxy);
 } catch (Exception e) {
 Log.e(REV_TAG, ">>> Error processing revImage frame", e);
 } finally {
 revImageProxy.close(); // Always close the revImageProxy
 }
 }

 @androidx.annotation.OptIn(markerClass = androidx.camera.core.ExperimentalGetImage.class)
 private void revProcessImageFrame(@NonNull ImageProxy revImageProxy) {
 Image revImage = revImageProxy.getImage();
 if (revImage != null) {
 byte[] revImageBytes = revConvertYUV420888ToByteArray(revImage);
 revWriteFrameToTempFile(revImageBytes); // Write frame to a temporary file
 }
 revImageProxy.close(); // Close the ImageProxy to release the revImage buffer
 }

 private byte[] revConvertYUV420888ToByteArray(Image revImage) {
 Image.Plane[] planes = revImage.getPlanes();
 ByteBuffer revBufferY = planes[0].getBuffer();
 ByteBuffer revBufferU = planes[1].getBuffer();
 ByteBuffer revBufferV = planes[2].getBuffer();

 int revWidth = revImage.getWidth();
 int revHeight = revImage.getHeight();

 int revSizeY = revWidth * revHeight;
 int revSizeUV = (revWidth / 2) * (revHeight / 2); // U and V sizes are half the Y size

 // Total size = Y + U + V
 byte[] revData = new byte[revSizeY + 2 * revSizeUV];

 // Copy Y plane
 revBufferY.get(revData, 0, revSizeY);

 // Copy U and V planes, accounting for row stride and pixel stride
 int revOffset = revSizeY;
 int revPixelStrideU = planes[1].getPixelStride();
 int rowStrideU = planes[1].getRowStride();
 int revPixelStrideV = planes[2].getPixelStride();
 int rowStrideV = planes[2].getRowStride();

 // Copy U plane
 for (int row = 0; row < revHeight / 2; row++) {
 for (int col = 0; col < revWidth / 2; col++) {
 revData[revOffset++] = revBufferU.get(row * rowStrideU + col * revPixelStrideU);
 }
 }

 // Copy V plane
 for (int row = 0; row < revHeight / 2; row++) {
 for (int col = 0; col < revWidth / 2; col++) {
 revData[revOffset++] = revBufferV.get(row * rowStrideV + col * revPixelStrideV);
 }
 }

 return revData;
 }


 private void revWriteFrameToTempFile(byte[] revImageBytes) {
 revExecutorService.execute(() -> {
 try {
 // Create a new temp file for each segment if needed
 if (revTempFile == null || revFrameCount == 0) {
 revTempFile = File.createTempFile("vid_segment_", ".yuv", new File(revOutDirPath));
 }

 try (FileOutputStream revFos = new FileOutputStream(revTempFile, true)) {
 revFos.write(revImageBytes);
 }

 revFrameCount++;

 // Process after 60 frames (2 second for 30 fps)
 if (revFrameCount >= 60 && isRevRecording) {
 revStartFFmpegProcess(); // Process the segment with FFmpeg
 revFrameCount = 0; // Reset the frame count
 revTempFile = null; // Reset temp file for the next segment
 }

 } catch (IOException e) {
 Log.e(REV_TAG, ">>> Error writing frame to temp file : ", e);
 }
 });
 }

 public void revStopCamera() {
 isRevRecording = false;
 if (revTempFile != null && revTempFile.exists()) {
 revTempFile.delete(); // Clean up the temporary file
 revTempFile = null; // Reset the temp file reference
 }
 }
 }


 package rev.ca.rev_media_dash_camera2;

 import android.os.Bundle;

 import androidx.appcompat.app.AppCompatActivity;

 public class MainActivity extends AppCompatActivity {
 private RevCameraCapture revCameraCapture;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);

 revCameraCapture = new RevCameraCapture(this);
 }

 @Override
 protected void onStart() {
 super.onStart();
 try {
 revCameraCapture.revStartCamera();
 } catch (Exception e) {
 e.printStackTrace();
 }
 }

 @Override
 protected void onStop() {
 super.onStop();
 revCameraCapture.revStopCamera(); // Ensure camera is stopped when not in use
 }
 }
</processcameraprovider>


-
docker discord.py ffmpeg.exe was not found
7 mai 2022, par acidchuMy code works on windows fine I'm just stumped on how to migrate it to my docker server for stability reasons and my old vm shit the bed. bellow is my main playing loop


async def main_playing_loop(vc, ctx):
 global skip
 while len(queued[str(ctx.guild.id)]) > 0:
 try:
 print(vc.is_playing())
 while vc.is_playing() or vc.is_paused():
 await asyncio.sleep(2)
 skip_func(vc)
 pass

 except AttributeError:
 pass
 try:
 url = str(queued[str(ctx.guild.id)][0])
 download_video(ctx, url)
 vc.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=str(ctx.guild.id) + ".mp3"))
 del queued[str(ctx.guild.id)][0]
 except:
 break



log of what its doing


discord_main_1 | [youtube] dQw4w9WgXcQ: Downloading android player API JSON
discord_main_1 | [youtube] dQw4w9WgXcQ: Downloading webpage
discord_main_1 | stoping
discord_main_1 | [youtube] dQw4w9WgXcQ: Downloading android player API JSON
discord_main_1 | [info] dQw4w9WgXcQ: Downloading 1 format(s): 251
discord_main_1 | [download] Destination: 866270239342460930.mp3
[download] 100% of 3.28MiB in 00:00 
discord_main_1 | Ignoring exception in command play:
discord_main_1 | Traceback (most recent call last):
discord_main_1 | File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 85, in wrapped
discord_main_1 | ret = await coro(*args, **kwargs)
discord_main_1 | File "/usr/src/bot/main.py", line 125, in play
discord_main_1 | vc.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=str(ctx.guild.id) + ".mp3"))
discord_main_1 | File "/usr/local/lib/python3.10/site-packages/discord/player.py", line 225, in __init__
discord_main_1 | super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
discord_main_1 | File "/usr/local/lib/python3.10/site-packages/discord/player.py", line 138, in __init__
discord_main_1 | self._process = self._spawn_process(args, **kwargs)
discord_main_1 | File "/usr/local/lib/python3.10/site-packages/discord/player.py", line 147, in _spawn_process
discord_main_1 | raise ClientException(executable + ' was not found.') from None
discord_main_1 | discord.errors.ClientException: ffmpeg.exe was not found.
discord_main_1 | 
discord_main_1 | The above exception was the direct cause of the following exception:
discord_main_1 | 
discord_main_1 | Traceback (most recent call last):
discord_main_1 | File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 939, in invoke
discord_main_1 | await ctx.command.invoke(ctx)
discord_main_1 | File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 863, in invoke
discord_main_1 | await injected(*ctx.args, **ctx.kwargs)
discord_main_1 | File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/core.py", line 94, in wrapped
discord_main_1 | raise CommandInvokeError(exc) from exc
discord_main_1 | discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: ffmpeg.exe was not found.



i have still got the old exe for ffmpeg i was using on win but that doesn't work on Ubuntu. any help is appreciated thanks.