Recherche avancée

Médias (91)

Autres articles (41)

  • (Dés)Activation de fonctionnalités (plugins)

    18 février 2011, par

    Pour gérer l’ajout et la suppression de fonctionnalités supplémentaires (ou plugins), MediaSPIP utilise à partir de la version 0.2 SVP.
    SVP permet l’activation facile de plugins depuis l’espace de configuration de MediaSPIP.
    Pour y accéder, il suffit de se rendre dans l’espace de configuration puis de se rendre sur la page "Gestion des plugins".
    MediaSPIP est fourni par défaut avec l’ensemble des plugins dits "compatibles", ils ont été testés et intégrés afin de fonctionner parfaitement avec chaque (...)

  • Le plugin : Podcasts.

    14 juillet 2010, par

    Le problème du podcasting est à nouveau un problème révélateur de la normalisation des transports de données sur Internet.
    Deux formats intéressants existent : Celui développé par Apple, très axé sur l’utilisation d’iTunes dont la SPEC est ici ; Le format "Media RSS Module" qui est plus "libre" notamment soutenu par Yahoo et le logiciel Miro ;
    Types de fichiers supportés dans les flux
    Le format d’Apple n’autorise que les formats suivants dans ses flux : .mp3 audio/mpeg .m4a audio/x-m4a .mp4 (...)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

Sur d’autres sites (7625)

  • 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;

  • RTSP to HLS via FFMPEG, latency issues

    28 juin 2024, par Pabl0

    The following are all the steps that I took to render a RTSP stream in my web app :

    &#xA;

    How to display RTSP stream in browser using HLS

    &#xA;

    Situation and Problem&#xA;You have an RTSP stream that you want to display in a browser using HLS (HTTP Live Streaming). However, when you try to play the RTSP stream in the browser using hls.js, you encounter the error "Unsupported HEVC in M2TS found." This error indicates that the HLS stream uses the HEVC (H.265) codec, which is not widely supported by many browsers and HLS players, including hls.js.

    &#xA;

    The most reliable solution is to transcode the stream from H.265 to H.264 using FFmpeg, which is more broadly supported. Here's how to transcode the stream :

    &#xA;

    Step 1 : Transcode the Stream Using FFmpeg

    &#xA;

    Run the following FFmpeg command to transcode the RTSP stream from H.265 to H.264 and generate the HLS segments :

    &#xA;

    ffmpeg -i rtsp://192.168.144.25:8554/main.264 -c:v libx264 -c:a aac -strict -2 -hls_time 10 -hls_list_size 0 -f hls C:\path\to\output\index.m3u8&#xA;

    &#xA;

    c:v libx264 sets the video codec to H.264.

    &#xA;

    c:a aac sets the audio codec to AAC.

    &#xA;

    hls_time 10 sets the duration of each segment to 10 seconds.

    &#xA;

    hls_list_size 0 tells FFmpeg to include all segments in the playlist.

    &#xA;

    f hls specifies the output format as HLS.

    &#xA;

    C :\path\to\output\ is the directory where the HLS files will be saved. Ensure that C :\path\to\output\ is the directory where you want to save the HLS files.

    &#xA;

    Step 2 : Verify the HLS Files

    &#xA;

    After running the FFmpeg command, verify that the following files are generated in the output directory :

    &#xA;

    index.m3u8 (HLS playlist file)

    &#xA;

    Multiple .ts segment files (e.g., index0.ts, index1.ts, etc.)

    &#xA;

    Step 3 : Serve the HLS Files with an HTTP Server

    &#xA;

    Navigate to the directory containing the HLS files and start the HTTP server :

    &#xA;

    cd C :\path\to\output&#xA;python -m http.server 8000&#xA;Step 4 : Update and Test the HTML File&#xA;Ensure that hls_test.html file is in the same directory as the HLS files and update it as needed :

    &#xA;

    hls_test.html :

    &#xA;

    &#xA;&#xA;    &#xA;        &#xA;        &#xA;        &#xA;    &#xA;    &#xA;        <h1>HLS Stream Test</h1>&#xA;        <button>Play Stream</button>&#xA;        <video controls="controls" style="width: 100%; height: auto;"></video>&#xA;        <code class="echappe-js">&lt;script src=&quot;https://cdn.jsdelivr.net/npm/hls.js@latest&quot;&gt;&lt;/script&gt;&#xA;        &lt;script&gt;&amp;#xA;            document&amp;#xA;                .getElementById(&amp;#x27;playButton&amp;#x27;)&amp;#xA;                .addEventListener(&amp;#x27;click&amp;#x27;, () =&gt; {&amp;#xA;                    const video = document.getElementById(&amp;#x27;video&amp;#x27;);&amp;#xA;                    if (Hls.isSupported()) {&amp;#xA;                        const hls = new Hls();&amp;#xA;                        hls.loadSource(&amp;#x27;http://localhost:8000/index.m3u8&amp;#x27;);&amp;#xA;                        hls.attachMedia(video);&amp;#xA;                        hls.on(Hls.Events.MANIFEST_PARSED, function () {&amp;#xA;                            video.play().catch((error) =&gt; {&amp;#xA;                                console.error(&amp;#xA;                                    &amp;#x27;Error attempting to play:&amp;#x27;,&amp;#xA;                                    error,&amp;#xA;                                );&amp;#xA;                            });&amp;#xA;                        });&amp;#xA;                        hls.on(Hls.Events.ERROR, function (event, data) {&amp;#xA;                            console.error(&amp;#x27;HLS Error:&amp;#x27;, data);&amp;#xA;                        });&amp;#xA;                    } else if (&amp;#xA;                        video.canPlayType(&amp;#x27;application/vnd.apple.mpegurl&amp;#x27;)&amp;#xA;                    ) {&amp;#xA;                        video.src = &amp;#x27;http://localhost:8000/index.m3u8&amp;#x27;;&amp;#xA;                        video.addEventListener(&amp;#x27;canplay&amp;#x27;, function () {&amp;#xA;                            video.play().catch((error) =&gt; {&amp;#xA;                                console.error(&amp;#xA;                                    &amp;#x27;Error attempting to play:&amp;#x27;,&amp;#xA;                                    error,&amp;#xA;                                );&amp;#xA;                            });&amp;#xA;                        });&amp;#xA;                    } else {&amp;#xA;                        console.error(&amp;#x27;HLS not supported in this browser.&amp;#x27;);&amp;#xA;                    }&amp;#xA;                });&amp;#xA;        &lt;/script&gt;&#xA;    &#xA;&#xA;

    &#xA;

    Step 5 : Open the HTML File in Your Browser

    &#xA;

    Open your browser and navigate to :

    &#xA;

    http://localhost:8000/hls_test.html&#xA;

    &#xA;

    Click the "Play Stream" button to start playing the HLS stream. If everything is set up correctly, you should see the video playing in the browser.

    &#xA;

    Conclusion

    &#xA;

    By transcoding the RTSP stream from H.265 to H.264 and serving it as an HLS stream, you can display the video in a browser using hls.js. This approach ensures broader compatibility with browsers and HLS players, allowing you to stream video content seamlessly.

    &#xA;

    PART 2 : Add this method to the react app

    &#xA;

    We are assuming that the ffmpeg command is running in the background and generating the HLS stream. Now, we will create a React component that plays the HLS stream in the browser using the video.js library.

    &#xA;

    If not, please refer to the previous steps to generate the HLS stream using FFmpeg. (steps 1-3 of the previous section)

    &#xA;

    Step 1 : Create the Camera Component

    &#xA;

    import { useRef } from &#x27;react&#x27;;&#xA;import videojs from &#x27;video.js&#x27;;&#xA;import &#x27;video.js/dist/video-js.css&#x27;;&#xA;&#xA;const Camera = ({ streamUrl }) => {&#xA;    const videoRef = useRef(null);&#xA;    const playerRef = useRef(null);&#xA;&#xA;    const handlePlayClick = () => {&#xA;        const videoElement = videoRef.current;&#xA;        if (videoElement) {&#xA;            playerRef.current = videojs(videoElement, {&#xA;                controls: true,&#xA;                autoplay: false,&#xA;                preload: &#x27;auto&#x27;,&#xA;                sources: [&#xA;                    {&#xA;                        src: streamUrl,&#xA;                        type: &#x27;application/x-mpegURL&#x27;,&#xA;                    },&#xA;                ],&#xA;            });&#xA;&#xA;            playerRef.current.on(&#x27;error&#x27;, () => {&#xA;                const error = playerRef.current.error();&#xA;                console.error(&#x27;VideoJS Error:&#x27;, error);&#xA;            });&#xA;&#xA;            playerRef.current.play().catch((error) => {&#xA;                console.error(&#x27;Error attempting to play:&#x27;, error);&#xA;            });&#xA;        }&#xA;    };&#xA;&#xA;    return (&#xA;        &#xA;            <button>Play Stream</button>&#xA;            &#xA;        &#xA;    );&#xA;};&#xA;&#xA;export default Camera;&#xA;

    &#xA;

    Note : This component uses the video.js library to play the HLS stream. Make sure to install video.js using npm or yarn :

    &#xA;

    npm install video.js

    &#xA;

    Step 2 : Use the Camera Component in Your App

    &#xA;

    Now, you can use the Camera component in your React app to display the HLS stream. Here's an example of how to use the Camera component :

    &#xA;

    <camera streamurl="http://localhost:8000/index.m3u8"></camera>

    &#xA;

    Note : see we are pointing to the HLS stream URL generated by FFmpeg in the previous steps.

    &#xA;

    Step 3 : Create the Cors Proxy Server and place it where the HLS files are being stored.

    &#xA;

    from http.server import HTTPServer, SimpleHTTPRequestHandler&#xA;import socketserver&#xA;import os&#xA;&#xA;class CORSRequestHandler(SimpleHTTPRequestHandler):&#xA;    def end_headers(self):&#xA;        if self.path.endswith(&#x27;.m3u8&#x27;):&#xA;            self.send_header(&#x27;Content-Type&#x27;, &#x27;application/vnd.apple.mpegurl&#x27;)&#xA;        elif self.path.endswith(&#x27;.ts&#x27;):&#xA;            self.send_header(&#x27;Content-Type&#x27;, &#x27;video/MP2T&#x27;)&#xA;        super().end_headers()&#xA;&#xA;if __name__ == &#x27;__main__&#x27;:&#xA;    port = 8000&#xA;    handler = CORSRequestHandler&#xA;    web_dir = r&#x27;C:\Video_cam_usv&#x27;&#xA;    os.chdir(web_dir)&#xA;    httpd = socketserver.TCPServer((&#x27;&#x27;, port), handler)&#xA;    print(f"Serving HTTP on port {port}")&#xA;    httpd.serve_forever()&#xA;

    &#xA;

    Note : Change the web_dir to the directory where the HLS files are stored.

    &#xA;

    Also, note that the server is sending the correct MIME types for .m3u8 and .ts files. For example :

    &#xA;

    .m3u8 should be application/vnd.apple.mpegurl or application/x-mpegURL.&#xA;.ts should be video/MP2T.&#xA;

    &#xA;

    Step 4 : Start the CORS Proxy Server

    &#xA;

    Open a terminal, navigate to the directory where the CORS proxy server script is located (same as the HLS files are being saved), and run the following command :

    &#xA;

    python cors_proxy_server.py&#xA;

    &#xA;

    This will start the CORS proxy server on port 8000 and serve the HLS files with the correct MIME types.

    &#xA;

    Step 5 : Start the React App&#xA;Start your React app using the following command :

    &#xA;

    npm run dev

    &#xA;

    I have tried everything above (it´s my own doc to keep with the steps Ive taken so far) and I get the stream to render on my web app but the latency is very high, at least of 5-10 secs, how can i make it be real time or close to that ?

    &#xA;

  • 9 Form Optimisation Tips to Convert More Visitors

    15 février 2024, par Erin

    Forms might seem boring — that is, until you realise how powerful they are.

    No forms mean no leads.

    No leads mean no sales.

    No sales means you’ll run out of business.

    So, what do you do ?

    Optimise forms to land more leads.

    They’re a critical part of the sales funnel.

    Forms have many different purposes and can be used to :

    • Contact a company
    • Sign up for a newsletter
    • Request a demo
    • Start a free trial
    • And more

    If you want to get more leads (and ultimately more sales), then you need to optimise your forms.

    This guide will show you exactly how to do that (so you can start getting more conversions today). 

    What is form optimisation ?

    Before we dive into form optimisation, let’s back up a bit.

    Form conversion is our primary focus.

    Your form conversion rate is the percentage of visitors who submit a form divided by the total number of visitors who started the form times one hundred.

    For example, if 5,000 people started filling out your form this month and 350 submitted the form, the conversion rate would be : 

    350 / 5,000 x 100 = 7%

    So, what’s form optimisation ?

    What is form optimisation?

    It’s simply improving your forms to increase conversion rates.

    For most people, form conversion is all about increasing leads.

    Before you begin optimising your forms, it’s important you understand what’s good (and what’s not good) when it comes to form conversions.

    The average form conversion rate across all industries is 2.9%.

    This means you should expect about 3 out of every 100 visitors who start your form to submit it.

    If your form conversion is lower — or hovering around this number — then it’s important to start optimising now.

    With Matomo, you can track your form conversions with Matomo Form Analytics. Gain powerful insights into how your visitors interact with your forms with our intuitive dashboard.

    Why it’s important to optimise your forms

    Most people hear the word “forms” and think it’s boring.

    But forms are the doorway to leads.

    If you want to generate more sales, then you need to generate great forms.

    Here are five reasons you need to optimise your forms today :

    1. Improve conversions

    Form optimisation is really just conversion optimisation.

    But, instead of optimising and improving your site to directly improve sales conversions, you’re increasing lead conversions.

    Every smart website owner uses forms to draw people in further.

    The reality is that most of your website visitors will never return to your site.

    This means you need to do everything you can to grab their contact information so you can continue marketing to them day in and day out.

    Otherwise, you’ll lose them forever.

    When you know how to optimise your forms, you’ll be able to get a higher percentage of form viewers to fill it out.

    Higher conversions mean you get more leads, more customers, and ultimately more revenue.

    2. Capture more leads

    When you can increase your form conversion rate from 1% to 2%, it may seem insignificant.

    What’s a measly percentage point in conversions ?

    It’s a lot.

    When you’re dealing with traffic in the tens or hundreds of thousands each month, an increase in conversion rate by a whole percentile is massive.

    Let’s say you take your conversion rate from 2% to 3% on your form, and you have 70,000 visitors view the form each month.

    Well, if 1,400 people used to sign up to your email list each month at a 2% conversion rate, then at a 3% conversion rate, you’d get 2,100 new email signups every month.

    That’s a major difference.

    When you can improve your signup forms, you improve your lead generation (which is conversion rate optimisation). And the more leads you have, the more sales you’ll make in the long run.

    3. Get the most out of your traffic

    If your forms don’t perform well, then you’re wasting your time (and your traffic).

    By analysing your form data, you can quickly see what’s working and what’s not so you can optimise and improve the user experience (and your forms).

    For most people, this means getting more form viewers to fill out the form with their email and name.

    If 50,000 people visit your site each month, but only 1% of them fill out your form, you’re only getting 500 email signups per month.

    Rather than paying money to generate more traffic, why not just work on improving your website by implementing a better form ?

    If you can increase your form conversion rate to 2%, you will immediately go from 500 new subscribers per month to 1,000 per month.

    4. Spend less on acquisition

    If you’re able to get more form signups without having to generate more traffic, you just solved a pricey problem : acquisition costs.

    If you can now get 1,000 of your 50,000 visitors to sign up to your email list through a better form, then you doubled your signups.

    But that’s not all. You just cut your acquisition costs in half.

    If you spend $2,000 per month on acquisition but you’re able to get twice as many leads, then your acquisition costs are at 50% of what they used to be.

    This means you can pay the same amount but get twice as many leads.

    Or, you can pour even more money into acquisition since it’s now twice as effective so you can fuel growth even more.

    5. Grow revenue

    Forms generate revenue. It may not be direct (although, in some cases, it is). 

    But, forms will lead to sales.

    By placing optimised forms throughout your website at the right places, you will be able to capture a percentage of your visitors as leads, which means you’ll eventually make more sales.

    13 tips to optimise your forms for more conversions

    Now that you know what forms can do and why they’re important to grow your business, it’s time to dive into the best practices.

    Follow these 13 tips to ensure you’re getting the most out of your forms :

    1. Set form goals

    Your forms are hopeless without a goal.

    Before you set up a form on your website, ask yourself, “What am I trying to accomplish with this form ?”

    It could be :

    • Encouraging customers to reach out through a contact form
    • To get visitors to leave feedback on your product/service
    • Convert visitors into leads by giving you their email

    No matter what your goal is, make sure you’re clear on it ; otherwise, you won’t be as targeted and specific with your forms.

    Matomo Goals helps you set specific objectives for your marketing campaigns so you’re able to easily track conversions. Whether you’re looking to capture feedback or generate leads, you can leverage Matomo to see what’s working and what’s not in seconds.

    2. Remove or improve fields with high average time spent and high drop-off rates

    Delving into your Form Analytics provides invaluable insights into individual field performance. A crucial metric to focus on is the Average Time Spent. 

    If a field stands out with a significantly higher average time spent and experiences a high drop-off rate compared to others in the form, it’s a clear indicator that it’s causing frustration or confusion for your visitors.

    To address this, consider improving the field by converting it into a dropdown menu for easier completion or providing helpful text prompts. Alternatively, if the field isn’t essential, you might opt to remove it altogether.

    When you cut down on time spent and drop-offs, you’ll see your conversion rates go up.

    Matomo's Form Analytics dashboard displaying field timings

    Here’s a standout example from Matomo’s Form Analytics feature : the “Overview of your needs” field is taking on average 1 minute and 37 seconds to complete. 

    To streamline this, we might want to consider a simple fix like converting it into a dropdown menu. This change would offer visitors a clearer and quicker way to select from options.

    Screenshot of drop-off fields report in Matomo's Form Analytics feature

    Likewise, we observe that the “Overview of your needs” field experiences the highest drop-off rate, totaling 1,732 drop-offs. 

    With Form Analytics, it becomes clear what is needed to optimise forms and increase conversions.

    Try Matomo for Free

    Get the web insights you need, without compromising data accuracy.

    No credit card required

    3. Start with the CTA

    When crafting and optimising your forms, you need to start with the end in mind. That’s why you need to start with your business goals.

    What are you trying to do with this form ? If you want to capture more emails, then make sure that’s very clear with the call to action (CTA).

    Start building your form by beginning with the CTA.

    For example : “Sign Up Now.”

    Once you have the action you want your potential customers to take, place it on the form. Then, you can work towards crafting the rest of the form.

    4. Put it above the fold

    If your visitors can’t find your form, they won’t fill it out. It’s plain and simple.

    You need to make sure your form is visible above the fold. This is the part of the screen that’s visible to your visitors once they land on your site (without needing to scroll down).

    Always remember to test this out on both desktop and mobile to ensure anyone (using laptops or a mobile device) will see your form upon landing on your site or page.

    Don’t forget about your mobile users. More people view mobile forms than desktop forms. 

    5. Put a CTA in the headline

    Your form needs to be clear.

    You have 1-3 seconds to communicate with your site visitors what your form is all about.

    For example, if you’re trying to get email signups with a lead magnet, then tell them the benefit quickly and concisely with a CTA in the headline, like this one :

    “Subscribe to Save 10% On Your Next Order”

    This is a great example of a headline-CTA combo that tells the visitor what to do and what they get out of it.

    Matomo’s behaviour analytics features like Session Recordings let you see where visitors are clicking and spending time. For example, if people are reading the headline, but not scrolling down to read the form, it’s probably a sign you need to test a different headline.

    6. Ensure you have the right fields

    Your form fields matter.

    What information are you trying to capture from your audience ?

    One beginner mistake people make is requiring too much information and including many fields in a form.

    You want to get as much data on your audience as possible, right ? Wrong.

    If you ask for too much information, people won’t fill it out, and it will harm the user experience. You need to make it super easy.

    If you want more emails to grow your list, then stick with someone’s email (and possibly their name as well). One line for a name. One line for an email address. Keep it simple.

    If you’re after SMS as well, don’t include it on the form. Instead, create a two-step form that pops up an SMS form after someone fills out the email form.

    Multi-step forms enable you to capture those emails easily (and still get a percentage to fill out the second form) without making it seem like too much work for your audience.

    Another path is to include optional fields (that users don’t have to fill out to click submit).

    Just keep in mind that shorter forms perform better than longer ones.

    If you make them too long, it feels like work for the user and will lead to lower completion rates.

    7. Always capture email address

    If you’re unsure of what information to capture (i.e. name, number, email, occupation, age, etc.), always stick to email.

    Email is used by over 4 billion people every single day, and it’s not going away anytime soon.

    When determining which fields to include, start with email.

    Capture more leads with quality forms.

    8. Test different buttons and copy

    You need to track your form performance if you want to get the best conversions.

    One of the best form elements to start testing is your button copy.

    In most cases, form completion buttons will have the word “submit” on them.

    But you don’t have to stick with this word.

    You can (and should) experiment with different submit button copy.

    Here are a few examples of replacement words for your action button :

    • Complete
    • Sign Up
    • Join now
    • Get started

    Remember to experiment with your action button. Try a different copy. Just keep it short.

    You can also try A/B testing your form by experimenting with different colours, copy, and more.

    Matomo's A/B testing dashboard displaying results of CTA experiment

    In the example above from Matomo’s A/B testing feature, we found that changing the wording of our call to action made a big difference. The new “Apply Now” button performed much better, with a 3.6% conversion rate compared to just 1.7% for the original one.

    Try Matomo for Free

    Get the web insights you need, without compromising data accuracy.

    No credit card required

    9. Test static vs. popup

    There are various types of online forms.

    The most common is the static form that just sits in one place and is always there.

    Another popular form type is the popup.

    This is where a form will appear based on a certain trigger like :

    • A certain amount of time on page
    • A certain distance scrolling down the page
    • If someone is a new or returning visitor

    Depending on the form software you use, you may be able to add conditional logic.

    Start tracking your form conversions

    Form optimisation is all about conversion rate optimisation.

    If you want to increase your conversions and generate more revenue, then you need to test out different forms and know how to optimise them.

    With Matomo, you can easily track, manage, and A/B test your forms so you can improve your conversions. 

    Try Matomo free for 21 days. No credit card required.