Recherche avancée

Médias (0)

Mot : - Tags -/performance

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (60)

  • Pas question de marché, de cloud etc...

    10 avril 2011

    Le 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 2011

    Documentation 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, par

    The 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.N

    I 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 of Log.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 :
The video file has read access

    


  • FFmpeg Overwiting Playlist

    30 septembre 2024, par Program-Me-Rev

    I'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;&#xA;&#xA;    import android.app.Activity;&#xA;    import android.content.Context;&#xA;    import android.media.Image;&#xA;    import android.util.Log;&#xA;    import android.util.Size;&#xA;&#xA;    import androidx.annotation.NonNull;&#xA;    import androidx.camera.core.CameraSelector;&#xA;    import androidx.camera.core.ImageAnalysis;&#xA;    import androidx.camera.core.ImageProxy;&#xA;    import androidx.camera.core.Preview;&#xA;    import androidx.camera.lifecycle.ProcessCameraProvider;&#xA;    import androidx.camera.view.PreviewView;&#xA;    import androidx.core.content.ContextCompat;&#xA;    import androidx.lifecycle.LifecycleOwner;&#xA;&#xA;    import com.arthenica.ffmpegkit.FFmpegKit;&#xA;    import com.arthenica.ffmpegkit.ReturnCode;&#xA;    import com.google.common.util.concurrent.ListenableFuture;&#xA;&#xA;    import java.io.File;&#xA;    import java.io.FileOutputStream;&#xA;    import java.io.IOException;&#xA;    import java.nio.ByteBuffer;&#xA;    import java.util.concurrent.ExecutionException;&#xA;    import java.util.concurrent.ExecutorService;&#xA;    import java.util.concurrent.Executors;&#xA;&#xA;    public class RevCameraCapture {&#xA;        private static final String REV_TAG = "RevCameraCapture";&#xA;&#xA;        private final Context revContext;&#xA;        private final ExecutorService revExecutorService;&#xA;        private final String revOutDirPath = "/storage/emulated/0/Documents/Owki/rev_web_rtc_live_chat_temp_files/_abc_rev_uploads_temp";&#xA;        private boolean isRevRecording;&#xA;        private File revTempFile;&#xA;        private int revFrameCount = 0; // Counter for frames captured&#xA;&#xA;        public RevCameraCapture(Context revContext) {&#xA;            this.revContext = revContext;&#xA;&#xA;            revInitDir(revOutDirPath);&#xA;            revCheckOrCreatePlaylist();&#xA;&#xA;            revExecutorService = Executors.newSingleThreadExecutor();&#xA;        }&#xA;&#xA;        private void revInitDir(String revDirPath) {&#xA;            // Create a File object for the directory&#xA;            File revNestedDir = new File(revDirPath);&#xA;&#xA;            // Check if the directory exists, if not, create it&#xA;            if (!revNestedDir.exists()) {&#xA;                boolean revResult = revNestedDir.mkdirs();  // mkdirs() creates the whole path&#xA;                if (revResult) {&#xA;                    Log.e(REV_TAG, ">>> Directories created successfully.");&#xA;                } else {&#xA;                    Log.e(REV_TAG, ">>> Failed to create directories.");&#xA;                }&#xA;            } else {&#xA;                Log.e(REV_TAG, ">>> Directories already exist.");&#xA;            }&#xA;        }&#xA;&#xA;        private void revCheckOrCreatePlaylist() {&#xA;            File revPlaylistFile = new File(revOutDirPath, "rev_playlist.mpd");&#xA;            if (!revPlaylistFile.exists()) {&#xA;                // Create an empty playlist if it doesn&#x27;t exist&#xA;                try {&#xA;                    FileOutputStream revFos = new FileOutputStream(revPlaylistFile);&#xA;                    revFos.write("".getBytes());&#xA;                    revFos.close();&#xA;                } catch (IOException e) {&#xA;                    Log.e(REV_TAG, ">>> Error creating initial rev_playlist : ", e);&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;&#xA;        private void revStartFFmpegProcess() {&#xA;            // Ensure revTempFile exists before processing&#xA;            if (revTempFile == null || !revTempFile.exists()) {&#xA;                Log.e(REV_TAG, ">>> Temporary file does not exist for FFmpeg processing.");&#xA;                return;&#xA;            }&#xA;&#xA;            // FFmpeg command to convert the temp file to DASH format and append to the existing rev_playlist&#xA;            String ffmpegCommand = "-f rawvideo -pixel_format yuv420p -video_size 704x704 " &#x2B; "-i " &#x2B; revTempFile.getAbsolutePath() &#x2B; " -c:v mpeg4 -b:v 1M " &#x2B; "-f dash -seg_duration 1 -use_template 1 -use_timeline 1 " &#x2B; "-init_seg_name &#x27;init.m4s&#x27; -media_seg_name &#x27;$Number$.m4s&#x27; " &#x2B; revOutDirPath &#x2B; "/rev_playlist.mpd -loglevel debug";&#xA;&#xA;&#xA;            FFmpegKit.executeAsync(ffmpegCommand, session -> {&#xA;                ReturnCode returnCode = session.getReturnCode();&#xA;                if (ReturnCode.isSuccess(returnCode)) {&#xA;                    // Optionally handle success, e.g., log or notify that the process completed successfully&#xA;                } else {&#xA;                    Log.e(REV_TAG, ">>> FFmpeg process failed with return code : " &#x2B; returnCode);&#xA;                }&#xA;            });&#xA;        }&#xA;&#xA;&#xA;        public void revStartCamera() {&#xA;            isRevRecording = true;&#xA;&#xA;            ListenableFuture<processcameraprovider> revCameraProviderFuture = ProcessCameraProvider.getInstance(revContext);&#xA;&#xA;            revCameraProviderFuture.addListener(() -> {&#xA;                try {&#xA;                    ProcessCameraProvider revCameraProvider = revCameraProviderFuture.get();&#xA;                    revBindPreview(revCameraProvider);&#xA;                    revBindImageAnalysis(revCameraProvider);&#xA;                } catch (ExecutionException | InterruptedException e) {&#xA;                    Log.e(REV_TAG, ">>> Failed to start camera : ", e);&#xA;                }&#xA;            }, ContextCompat.getMainExecutor(revContext));&#xA;        }&#xA;&#xA;        private void revBindPreview(ProcessCameraProvider revCameraProvider) {&#xA;            CameraSelector revCameraSelector = new CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build();&#xA;&#xA;            PreviewView previewView = ((Activity) revContext).findViewById(R.id.previewView);&#xA;            Preview preview = new Preview.Builder().build();&#xA;            preview.setSurfaceProvider(previewView.getSurfaceProvider());&#xA;&#xA;            revCameraProvider.unbindAll();&#xA;            revCameraProvider.bindToLifecycle((LifecycleOwner) revContext, revCameraSelector, preview);&#xA;        }&#xA;&#xA;        private void revBindImageAnalysis(@NonNull ProcessCameraProvider revCameraProvider) {&#xA;            ImageAnalysis revImageAnalysis = new ImageAnalysis.Builder().setTargetResolution(new Size(640, 480)) // Lower the resolution to reduce memory consumption&#xA;                    .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST).build();&#xA;&#xA;            revImageAnalysis.setAnalyzer(ContextCompat.getMainExecutor(revContext), this::revAnalyze);&#xA;            CameraSelector revCameraSelector = new CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build();&#xA;&#xA;            revCameraProvider.bindToLifecycle((LifecycleOwner) revContext, revCameraSelector, revImageAnalysis);&#xA;        }&#xA;&#xA;        @androidx.annotation.OptIn(markerClass = androidx.camera.core.ExperimentalGetImage.class)&#xA;        private void revAnalyze(@NonNull ImageProxy revImageProxy) {&#xA;            try {&#xA;                revProcessImageFrame(revImageProxy);&#xA;            } catch (Exception e) {&#xA;                Log.e(REV_TAG, ">>> Error processing revImage frame", e);&#xA;            } finally {&#xA;                revImageProxy.close(); // Always close the revImageProxy&#xA;            }&#xA;        }&#xA;&#xA;        @androidx.annotation.OptIn(markerClass = androidx.camera.core.ExperimentalGetImage.class)&#xA;        private void revProcessImageFrame(@NonNull ImageProxy revImageProxy) {&#xA;            Image revImage = revImageProxy.getImage();&#xA;            if (revImage != null) {&#xA;                byte[] revImageBytes = revConvertYUV420888ToByteArray(revImage);&#xA;                revWriteFrameToTempFile(revImageBytes); // Write frame to a temporary file&#xA;            }&#xA;            revImageProxy.close(); // Close the ImageProxy to release the revImage buffer&#xA;        }&#xA;&#xA;        private byte[] revConvertYUV420888ToByteArray(Image revImage) {&#xA;            Image.Plane[] planes = revImage.getPlanes();&#xA;            ByteBuffer revBufferY = planes[0].getBuffer();&#xA;            ByteBuffer revBufferU = planes[1].getBuffer();&#xA;            ByteBuffer revBufferV = planes[2].getBuffer();&#xA;&#xA;            int revWidth = revImage.getWidth();&#xA;            int revHeight = revImage.getHeight();&#xA;&#xA;            int revSizeY = revWidth * revHeight;&#xA;            int revSizeUV = (revWidth / 2) * (revHeight / 2); // U and V sizes are half the Y size&#xA;&#xA;            // Total size = Y &#x2B; U &#x2B; V&#xA;            byte[] revData = new byte[revSizeY &#x2B; 2 * revSizeUV];&#xA;&#xA;            // Copy Y plane&#xA;            revBufferY.get(revData, 0, revSizeY);&#xA;&#xA;            // Copy U and V planes, accounting for row stride and pixel stride&#xA;            int revOffset = revSizeY;&#xA;            int revPixelStrideU = planes[1].getPixelStride();&#xA;            int rowStrideU = planes[1].getRowStride();&#xA;            int revPixelStrideV = planes[2].getPixelStride();&#xA;            int rowStrideV = planes[2].getRowStride();&#xA;&#xA;            // Copy U plane&#xA;            for (int row = 0; row &lt; revHeight / 2; row&#x2B;&#x2B;) {&#xA;                for (int col = 0; col &lt; revWidth / 2; col&#x2B;&#x2B;) {&#xA;                    revData[revOffset&#x2B;&#x2B;] = revBufferU.get(row * rowStrideU &#x2B; col * revPixelStrideU);&#xA;                }&#xA;            }&#xA;&#xA;            // Copy V plane&#xA;            for (int row = 0; row &lt; revHeight / 2; row&#x2B;&#x2B;) {&#xA;                for (int col = 0; col &lt; revWidth / 2; col&#x2B;&#x2B;) {&#xA;                    revData[revOffset&#x2B;&#x2B;] = revBufferV.get(row * rowStrideV &#x2B; col * revPixelStrideV);&#xA;                }&#xA;            }&#xA;&#xA;            return revData;&#xA;        }&#xA;&#xA;&#xA;        private void revWriteFrameToTempFile(byte[] revImageBytes) {&#xA;            revExecutorService.execute(() -> {&#xA;                try {&#xA;                    // Create a new temp file for each segment if needed&#xA;                    if (revTempFile == null || revFrameCount == 0) {&#xA;                        revTempFile = File.createTempFile("vid_segment_", ".yuv", new File(revOutDirPath));&#xA;                    }&#xA;&#xA;                    try (FileOutputStream revFos = new FileOutputStream(revTempFile, true)) {&#xA;                        revFos.write(revImageBytes);&#xA;                    }&#xA;&#xA;                    revFrameCount&#x2B;&#x2B;;&#xA;&#xA;                    // Process after 60 frames (2 second for 30 fps)&#xA;                    if (revFrameCount >= 60 &amp;&amp; isRevRecording) {&#xA;                        revStartFFmpegProcess();  // Process the segment with FFmpeg&#xA;                        revFrameCount = 0;  // Reset the frame count&#xA;                        revTempFile = null;  // Reset temp file for the next segment&#xA;                    }&#xA;&#xA;                } catch (IOException e) {&#xA;                    Log.e(REV_TAG, ">>> Error writing frame to temp file : ", e);&#xA;                }&#xA;            });&#xA;        }&#xA;&#xA;        public void revStopCamera() {&#xA;            isRevRecording = false;&#xA;            if (revTempFile != null &amp;&amp; revTempFile.exists()) {&#xA;                revTempFile.delete(); // Clean up the temporary file&#xA;                revTempFile = null; // Reset the temp file reference&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;&#xA;    package rev.ca.rev_media_dash_camera2;&#xA;&#xA;    import android.os.Bundle;&#xA;&#xA;    import androidx.appcompat.app.AppCompatActivity;&#xA;&#xA;    public class MainActivity extends AppCompatActivity {&#xA;        private RevCameraCapture revCameraCapture;&#xA;&#xA;        @Override&#xA;        protected void onCreate(Bundle savedInstanceState) {&#xA;            super.onCreate(savedInstanceState);&#xA;            setContentView(R.layout.activity_main);&#xA;&#xA;            revCameraCapture = new RevCameraCapture(this);&#xA;        }&#xA;&#xA;        @Override&#xA;        protected void onStart() {&#xA;            super.onStart();&#xA;            try {&#xA;                revCameraCapture.revStartCamera();&#xA;            } catch (Exception e) {&#xA;                e.printStackTrace();&#xA;            }&#xA;        }&#xA;&#xA;        @Override&#xA;        protected void onStop() {&#xA;            super.onStop();&#xA;            revCameraCapture.revStopCamera(); // Ensure camera is stopped when not in use&#xA;        }&#xA;    }&#xA;</processcameraprovider>

    &#xA;

  • docker discord.py ffmpeg.exe was not found

    7 mai 2022, par acidchu

    My 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

    &#xA;

    async def main_playing_loop(vc, ctx):&#xA;    global skip&#xA;    while len(queued[str(ctx.guild.id)]) > 0:&#xA;        try:&#xA;            print(vc.is_playing())&#xA;            while vc.is_playing() or vc.is_paused():&#xA;                await asyncio.sleep(2)&#xA;                skip_func(vc)&#xA;                pass&#xA;&#xA;        except AttributeError:&#xA;            pass&#xA;        try:&#xA;            url = str(queued[str(ctx.guild.id)][0])&#xA;            download_video(ctx, url)&#xA;            vc.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=str(ctx.guild.id) &#x2B; ".mp3"))&#xA;            del queued[str(ctx.guild.id)][0]&#xA;        except:&#xA;            break&#xA;

    &#xA;

    log of what its doing

    &#xA;

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

    &#xA;

    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.

    &#xA;