Recherche avancée

Médias (0)

Mot : - Tags -/alertes

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

Autres articles (8)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The 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 (...)

  • Other interesting software

    13 avril 2011, par

    We don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
    The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
    We don’t know them, we didn’t try them, but you can take a peek.
    Videopress
    Website : http://videopress.com/
    License : GNU/GPL v2
    Source code : (...)

Sur d’autres sites (3448)

  • How to Record Video of a Dynamic Div Containing Multiple Media Elements in React Konva ?

    14 septembre 2024, par Humayoun Saeed

    I'm working on a React application where I need to record a video of a specific div with the class name "layout." This div contains multiple media elements (such as images and videos) that are dynamically rendered inside divisions. I've tried several approaches, including using MediaRecorder, canvas-based recording with html2canvas, RecordRTC, and even ffmpeg, but none seem to capture the entire div along with its dynamic content effectively.

    


    What would be the best approach to achieve this ? How can I record a video of this dynamically rendered div including all its media elements, ensuring a smooth capture of the transitions ?

    


    What I’ve Tried :
MediaRecorder API : Didn't work effectively for capturing the entire div and its elements.
html2canvas : Captures snapshots but struggles with smooth transitions between media elements.
RecordRTC HTML Element Recording : Attempts to capture the canvas, but the output video size is 0 bytes.
CanvasRecorder, FFmpeg, and various other libraries also didn't provide the desired result.

    


    import React, { useEffect, useState, useRef } from "react";&#xA;&#xA;const Preview = ({ layout, onClose }) => {&#xA;  const [currentContent, setCurrentContent] = useState([]);&#xA;  const totalDuration = useRef(0);&#xA;  const videoRefs = useRef([]); // Store refs to each video element&#xA;  const [totalTime, setTotalTime] = useState(0); // Add this line&#xA;  const [elapsedTime, setElapsedTime] = useState(0); // Track elapsed time in seconds&#xA;&#xA;  // video recording variable and state declaration&#xA;  //  video recorder end&#xA;  // for video record useffect&#xA;  // Function to capture the renderDivision content&#xA;&#xA;  const handleDownload = async () => {&#xA;    console.log("video downlaod function in developing mode.");&#xA;  };&#xA;&#xA;  // end video record useffect&#xA;&#xA;  // to apply motion and swtich in media of division start&#xA;  useEffect(() => {&#xA;    if (layout &amp;&amp; layout.divisions) {&#xA;      const content = layout.divisions.map((division) => {&#xA;        let divisionDuration = 0;&#xA;&#xA;        division.imageSrcs.forEach((src, index) => {&#xA;          const mediaDuration = division.durations[index]&#xA;            ? division.durations[index] * 1000 // Convert to milliseconds&#xA;            : 5000; // Fallback to 5 seconds if duration is missing&#xA;          divisionDuration &#x2B;= mediaDuration;&#xA;        });&#xA;&#xA;        return {&#xA;          division,&#xA;          contentIndex: 0,&#xA;          divisionDuration,&#xA;        };&#xA;      });&#xA;&#xA;      // Find the maximum duration&#xA;      const maxDuration = Math.max(...content.map((c) => c.divisionDuration));&#xA;&#xA;      // Filter divisions that have the max duration&#xA;      const maxDurationDivisions = content.filter(&#xA;        (c) => c.divisionDuration === maxDuration&#xA;      );&#xA;&#xA;      // Select the first one if there are multiple with the same max duration&#xA;      const selectedMaxDurationDivision = maxDurationDivisions[0];&#xA;&#xA;      totalDuration.current = selectedMaxDurationDivision.divisionDuration; // Update the total duration in milliseconds&#xA;&#xA;      setTotalTime(Math.floor(totalDuration.current / 1000000)); // Convert to seconds and set in state&#xA;&#xA;      // console.log(&#xA;      //   "Division with max duration (including ties):",&#xA;      //   selectedMaxDurationDivision&#xA;      // );&#xA;&#xA;      setCurrentContent(content);&#xA;    }&#xA;  }, [layout]);&#xA;&#xA;  useEffect(() => {&#xA;    if (currentContent.length > 0) {&#xA;      const timers = currentContent.map(({ division, contentIndex }, i) => {&#xA;        const duration = division.durations[contentIndex]&#xA;          ? division.durations[contentIndex] // Duration is already in ms&#xA;          : 5000; // Default to 5000ms if no duration is defined&#xA;&#xA;        const mediaElement = videoRefs.current[i];&#xA;        if (mediaElement &amp;&amp; mediaElement.pause) {&#xA;          mediaElement.pause();&#xA;        }&#xA;&#xA;        // Set up a timeout for each division to move to the next media after duration&#xA;        const timeoutId = setTimeout(() => {&#xA;          // Update content for each division independently&#xA;          updateContent(i, division, contentIndex, duration); // Move to the next content after duration&#xA;&#xA;          // Ensure proper cleanup&#xA;          if (contentIndex &#x2B; 1 >= division.imageSrcs.length) {&#xA;            clearTimeout(timeoutId); // Clear timeout to stop looping&#xA;          }&#xA;        }, duration);&#xA;&#xA;        // Cleanup timers on component unmount&#xA;        return timeoutId;&#xA;      });&#xA;&#xA;      // Return cleanup function to clear all timeouts&#xA;      return () => timers.forEach((timer) => clearTimeout(timer));&#xA;    }&#xA;  }, [currentContent]);&#xA;  // to apply motion and swtich in media of division end&#xA;&#xA;  // Handle video updates when the duration is changed or a new video starts&#xA;  const updateContent = (i, division, contentIndex, duration) => {&#xA;    const newContent = [...currentContent];&#xA;&#xA;    // Check if we are on the last media item&#xA;    if (contentIndex &#x2B; 1 &lt; division.imageSrcs.length) {&#xA;      // Move to next media if not the last one&#xA;      newContent[i].contentIndex = contentIndex &#x2B; 1;&#xA;    } else {&#xA;      // If this is the last media item, pause here&#xA;      newContent[i].contentIndex = contentIndex; // Keep it at the last item&#xA;      setCurrentContent(newContent);&#xA;&#xA;      // Handle video pause if the last media is a video&#xA;      const mediaElement = videoRefs.current[i];&#xA;      if (mediaElement &amp;&amp; mediaElement.tagName === "VIDEO") {&#xA;        mediaElement.pause();&#xA;        mediaElement.currentTime = mediaElement.duration; // Pause at the end of the video&#xA;      }&#xA;      return; // Exit the function as we don&#x27;t want to loop anymore&#xA;    }&#xA;&#xA;    // Update state to trigger rendering of the next media&#xA;    setCurrentContent(newContent);&#xA;&#xA;    // Handle video playback for the next media item&#xA;    const mediaElement = videoRefs.current[i];&#xA;    if (mediaElement) {&#xA;      mediaElement.pause();&#xA;      mediaElement.currentTime = 0;&#xA;      mediaElement&#xA;        .play()&#xA;        .catch((error) => console.error("Error playing video:", error));&#xA;    }&#xA;  };&#xA;&#xA;  const renderDivision = (division, contentIndex, index) => {&#xA;    const mediaSrc = division.imageSrcs[contentIndex];&#xA;&#xA;    if (!division || !division.imageSrcs || division.imageSrcs.length === 0) {&#xA;      return (&#xA;        &#xA;          <p>No media available</p>&#xA;        &#xA;      );&#xA;    }&#xA;&#xA;    if (!mediaSrc) {&#xA;      return (&#xA;        &#xA;          <p>No media available</p>&#xA;        &#xA;      );&#xA;    }&#xA;&#xA;    if (mediaSrc.endsWith(".mp4")) {&#xA;      return (&#xA;        > (videoRefs.current[index] = el)}&#xA;          src={mediaSrc}&#xA;          autoPlay&#xA;          controls={false}&#xA;          style={{&#xA;            width: "100%",&#xA;            height: "100%",&#xA;            objectFit: "cover",&#xA;            pointerEvents: "none",&#xA;          }}&#xA;          onLoadedData={() => {&#xA;            // Ensure video is properly loaded&#xA;            const mediaElement = videoRefs.current[index];&#xA;            if (mediaElement &amp;&amp; mediaElement.readyState >= 3) {&#xA;              mediaElement.play().catch((error) => {&#xA;                console.error("Error attempting to play the video:", error);&#xA;              });&#xA;            }&#xA;          }}&#xA;        />&#xA;      );&#xA;    } else {&#xA;      return (&#xA;        &#xA;      );&#xA;    }&#xA;  };&#xA;&#xA;  // progress bar code start&#xA;  useEffect(() => {&#xA;    if (totalDuration.current > 0) {&#xA;      // Reset elapsed time at the start&#xA;      setElapsedTime(0);&#xA;&#xA;      const interval = setInterval(() => {&#xA;        setElapsedTime((prevTime) => {&#xA;          // Increment the elapsed time by 1 second if it&#x27;s less than the total time&#xA;          if (prevTime &lt; totalTime) {&#xA;            return prevTime &#x2B; 1;&#xA;          } else {&#xA;            clearInterval(interval); // Clear the interval when totalTime is reached&#xA;            return prevTime;&#xA;          }&#xA;        });&#xA;      }, 1000); // Update every second&#xA;&#xA;      // Clean up the interval on component unmount&#xA;      return () => clearInterval(interval);&#xA;    }&#xA;  }, [totalTime]);&#xA;&#xA;  // progress bar code end&#xA;&#xA;  return (&#xA;    &#xA;      &#xA;        &#xA;          Close&#xA;        &#xA;        <h2>Preview Layout: {layout.name}</h2>&#xA;        &#xA;          {currentContent.map(({ division, contentIndex }, i) => (&#xA;            &#xA;              {renderDivision(division, contentIndex, i)}&#xA;            &#xA;          ))}&#xA;          {/* canvas code for video start */}&#xA;          {/* canvas code for video end */}&#xA;          {/* Progress Bar and Time */}&#xA;          / Background color for progress bar track&#xA;              display: "flex",&#xA;              justifyContent: "space-between",&#xA;              alignItems: "center",&#xA;            }}&#xA;          >&#xA;             totalTime) * 100}%)`,&#xA;                backgroundColor: "#28a745", // Green color for progress bar&#xA;                transition: "width 0.5s linear", // Smooth transition&#xA;              }}&#xA;            >&#xA;&#xA;            {/* Time display */}&#xA;            {/* / Fixed right margin&#xA;                zIndex: 1, // Ensure it&#x27;s above the progress bar&#xA;                padding: "5px",&#xA;                fontSize: "18px",&#xA;                fontWeight: "600",&#xA;                color: "#333",&#xA;                // backgroundColor: "rgba(255, 255, 255, 0.8)", // Add a subtle background for readability&#xA;              }}&#xA;            >&#xA;              {elapsedTime} / {totalTime}s&#xA;             */}&#xA;          &#xA;        &#xA;&#xA;        {/* Download button */}&#xA;        > (e.target.style.backgroundColor = "#218838")}&#xA;          onMouseOut={(e) => (e.target.style.backgroundColor = "#28a745")}&#xA;        >&#xA;          Download Video&#xA;        &#xA;        {/* {recording &amp;&amp; <p>Recording in progress...</p>} */}&#xA;      &#xA;    &#xA;  );&#xA;};&#xA;&#xA;export default Preview;&#xA;&#xA;

    &#xA;

    I tried several methods to record the content of the div with the class "layout," which contains dynamic media elements such as images and videos. The approaches I attempted include :

    &#xA;

    MediaRecorder API : I expected this API to capture the entire div and its contents, but it didn't handle the rendering of all dynamic media elements properly.

    &#xA;

    html2canvas : I used this to capture the layout as a canvas and then attempted to convert it into a video stream. However, it could not capture smooth transitions between media elements, leading to a choppy or incomplete video output.

    &#xA;

    RecordRTC : I integrated RecordRTC to capture the canvas stream of the div. Despite setting up the recorder, the resulting video file either had a 0-byte size or only captured parts of the content inconsistently.

    &#xA;

    FFmpeg and other libraries : I explored these tools hoping they would provide a seamless capture of the dynamic content, but they also failed to capture the full media elements, including videos playing within the layout.

    &#xA;

    In all cases, I expected to get a complete video recording of the div, including all media transitions, but the results were incomplete or not functional.

    &#xA;

    Now, I’m seeking an approach or best practice to record the entire div with its dynamic content and media playback.

    &#xA;

  • Video streamign with FFMpeg and Nest.js+Next.js

    17 septembre 2024, par Aizen

    Here is my problem : I have one video src 1080p (on the frontend). On the frontend, I send this video-route to the backend :

    &#xA;

    const req = async()=>{try{const res = await axios.get(&#x27;/catalog/item&#x27;,{params:{SeriesName:seriesName}});return {data:res.data};}catch(err){console.log(err);return false;}}const fetchedData = await req();-On the backend i return seriesName.Now i can make a full path,what the video is,and where it is,code:&#xA;

    &#xA;

    const videoUrl = &#x27;C:/Users/arMori/Desktop/RedditClone/reddit/public/videos&#x27;;console.log(&#x27;IT VideoURL&#x27;,videoUrl);&#xA;

    &#xA;

    const selectedFile = `${videoUrl}/${fetchedData.data.VideoSource}/${seriesName}-1080p.mp4`&#xA;console.log(`ITS&#x27;S SELECTED FILE: ${selectedFile}`);&#xA;

    &#xA;

    Ok, I have my src 1080p, now is the time to send it to the backend :

    &#xA;

    const response = await axios.post(&#x27;/videoFormat&#x27;, {videoUrl:selectedFile})console.log(&#x27;Это консоль лог путей: &#x27;,response.data);const videoPaths = response.data;&#xA;

    &#xA;

    Backend takes it and FFMpqg makes two types of resolution,720p and 480p,save it to the temp storage on backend, and then returns two routes where these videos stores

    &#xA;

    async videoUpload(videoUrl:string){try{const tempDir = C:/Users/arMori/Desktop/RedditClone/reddit_back/src/video/temp;const inputFile = videoUrl;console.log(&#x27;VIDEOURL: &#x27;,videoUrl);&#xA;

    &#xA;

            const outputFiles = [];&#xA;        &#xA;        await this.createDirectories(tempDir);        &#xA;        outputFiles.push(await this.convertVideo(inputFile, &#x27;1280x720&#x27;, &#x27;720p.mp4&#x27;));&#xA;        outputFiles.push(await this.convertVideo(inputFile, &#x27;854x480&#x27;, &#x27;480p.mp4&#x27;));&#xA;        console.log(&#x27;OUTUPT FILES SERVICE: &#x27;,outputFiles);&#xA;        &#xA;        return outputFiles;&#xA;&#xA;    }catch(err){&#xA;        console.error(&#x27;VideoFormatterService Error: &#x27;,err);&#xA;        &#xA;    }&#xA;}&#xA;&#xA;private convertVideo(inputPath:string,resolution:string,outputFileName:string):Promise<string>{&#xA;    const temp = `C:/Users/arMori/Desktop/RedditClone/reddit_back/src/video/temp`;&#xA;    return new Promise(async(resolve,reject)=>{&#xA;        const height = resolution.split(&#x27;x&#x27;)[1];&#xA;        console.log(&#x27;HIEGHT: &#x27;,height);&#xA;        &#xA;        const outputDir = `C:/Users/arMori/Desktop/RedditClone/reddit_back/src/video/temp/${height}p`;&#xA;        const outputPath = join(outputDir, outputFileName);&#xA;        const isExists = await fs.access(outputPath).then(() => true).catch(() => false);&#xA;        if(isExists){ &#xA;            console.log(`File already exists: ${outputPath}`);&#xA;            return resolve(outputPath)&#xA;        };&#xA;        ffmpeg(inputPath)&#xA;        .size(`${resolution}`)&#xA;        .videoCodec(&#x27;libx264&#x27;) // Кодек H.264&#xA;        .audioCodec(&#x27;aac&#x27;) &#xA;        .output(outputPath)&#xA;        .on(&#x27;end&#x27;,()=>resolve(outputPath))&#xA;        .on(&#x27;error&#x27;,(err)=>reject(err))&#xA;        .run()&#xA;            &#xA;    })&#xA;}&#xA;&#xA;private async createDirectories(temp:string){&#xA;    try{&#xA;        const dir720p = `${temp}/720p`;&#xA;        const dir480p = `${temp}/480p`;&#xA;        const dir720pExists = await fs.access(dir720p).then(() => true).catch(() => false);&#xA;        const dir480pExists = await fs.access(dir480p).then(() => true).catch(() => false);&#xA;        if(dir720pExists &amp;&amp; dir480pExists){&#xA;            console.log(&#x27;FILES ALIVE&#x27;);&#xA;            return;&#xA;        }&#xA;        if (!dir720pExists) {&#xA;            await fs.mkdir(dir720p, { recursive: true });&#xA;            console.log(&#x27;Папка 720p создана&#x27;);&#xA;        }&#xA;        &#xA;        if (!dir480pExists) {&#xA;            await fs.mkdir(dir480p, { recursive: true });&#xA;            console.log(&#x27;Папка 480p создана&#x27;);&#xA;        }&#xA;    } catch (err) {&#xA;        console.error(&#x27;Ошибка при создании директорий:&#x27;, err);&#xA;    }&#xA;}&#xA;</string>

    &#xA;

    Continue frontentd code :

    &#xA;

    let videoPath;&#xA;&#xA;if (quality === &#x27;720p&#x27;) {&#xA;        videoPath = videoPaths[0];&#xA;} else if (quality === &#x27;480p&#x27;) {&#xA;        videoPath = videoPaths[1];&#xA;}&#xA;&#xA;if (!videoPath) {&#xA;        console.error(&#x27;Video path not found!&#x27;);&#xA;        return;&#xA;}&#xA;&#xA;// Получаем видео по его пути&#xA;console.log(&#x27;VIDEOPATH LOG: &#x27;,videoPath);&#xA;    &#xA;const videoRes = await axios.get(&#x27;/videoFormat/getVideo&#x27;, { &#xA;        params: { path: videoPath } ,&#xA;        headers: { Range: &#x27;bytes=0-&#x27; },&#xA;        responseType: &#x27;blob&#x27;&#xA;    });&#xA;    console.log(&#x27;Video fetched: &#x27;, videoRes);&#xA;    const videoBlob = new Blob([videoRes.data], { type: &#x27;video/mp4&#x27; });&#xA;    const videoURL = URL.createObjectURL(videoBlob);&#xA;    return videoURL;&#xA;    /* console.log(&#x27;Видео успешно загружено:&#x27;, response.data); */&#xA;    } catch (error) {&#xA;    console.error(&#x27;Ошибка при загрузке видео:&#x27;, error);&#xA;    }&#xA;}&#xA;

    &#xA;

    Here I just choose one of the route and make a new GET request (VideoRes), now in the controller in the backend, I'm trying to do a video streaming :

    &#xA;

    @Public()&#xA;    @Get(&#x27;/getVideo&#x27;)&#xA;    async getVideo(@Query(&#x27;path&#x27;) videoPath:string,@Req() req:Request,@Res() res:Response){&#xA;        try {&#xA;            console.log(&#x27;PATH ARGUMENT: &#x27;,videoPath);&#xA;            console.log(&#x27;VIDEOPATH IN SERVICE: &#x27;,videoPath);&#xA;        const videoSize = (await fs.stat(videoPath)).size;&#xA;        const CHUNK_SIZE = 10 ** 6;&#xA;        const range = req.headers[&#x27;range&#x27;] as string | undefined;&#xA;        if (!range) {&#xA;            return new ForbiddenException(&#x27;Range не найденно&#x27;);&#xA;        }&#xA;        const start = Number(range.replace(/\D/g,""));&#xA;        const end = Math.min(start &#x2B; CHUNK_SIZE,videoSize - 1);&#xA;&#xA;        const contentLength = end - start &#x2B; 1;&#xA;        const videoStream = fsSync.createReadStream(videoPath, { start, end });&#xA;        const headers = {&#xA;            &#x27;Content-Range&#x27;:`bytes ${start}-${end}/${videoSize}`,&#xA;            &#x27;Accept-Ranges&#x27;:&#x27;bytes&#x27;,&#xA;            &#x27;Content-Length&#x27;:contentLength,&#xA;            &#x27;Content-Type&#x27;:&#x27;video/mp4&#x27;&#xA;        }&#xA;        &#xA;        res.writeHead(206,headers);&#xA;&#xA;        // Передаем поток в ответ&#xA;        videoStream.pipe(res);&#xA;        &#xA;&#xA;        // Если возникнет ошибка при стриминге, логируем ошибку&#xA;        videoStream.on(&#x27;error&#x27;, (error) => {&#xA;            console.error(&#x27;Ошибка при чтении видео:&#x27;, error);&#xA;            res.status(500).send(&#x27;Ошибка при чтении видео&#x27;);&#xA;        });&#xA;        } catch (error) {&#xA;            console.error(&#x27;Ошибка при обработке запросов:&#x27;, error);&#xA;            return res.status(400).json({ message: &#x27;Ошибка при обработке getVideo запросов&#x27; });&#xA;        }&#xA;    }&#xA;

    &#xA;

    Send to the frontend

    &#xA;

    res.writeHead(206,headers);&#xA;

    &#xA;

    In the frontend, I make blob url for video src and return it

    &#xA;

    const videoBlob = new Blob([videoRes.data], { type: &#x27;video/mp4&#x27; });const videoURL = URL.createObjectURL(videoBlob);return videoURL;&#xA;

    &#xA;

    And assign src to the video :

    &#xA;

    useVideo(seriesName,quality).then(src => {&#xA;                if (src) {&#xA;                    console.log(&#x27;ITS VIDEOLOGISC GOIDA!&#x27;);&#xA;                    if(!playRef.current) return;&#xA;                    &#xA;                    const oldURL = playRef.current.src;&#xA;                    if (oldURL &amp;&amp; oldURL.startsWith(&#x27;blob:&#x27;)) {&#xA;                        URL.revokeObjectURL(oldURL);&#xA;                    }&#xA;                    playRef.current.pause();&#xA;                    playRef.current.src = &#x27;&#x27;;&#xA;                    setQuality(quality);&#xA;                    console.log(&#x27;SRC: &#x27;,src);&#xA;                    &#xA;                    playRef.current.src = src;&#xA;                    playRef.current.load();&#xA;                    console.log(&#x27;ITS VIDEOURL GOIDA!&#x27;);&#xA;                    togglePlayPause();&#xA;                }&#xA;            })&#xA;            .catch(err => console.error(&#x27;Failed to fetch video&#x27;, err));&#xA;

    &#xA;

    But the problem is :

    &#xA;

    &#xA;

    Vinland-Saga:1 Uncaught (in promise) NotSupportedError : Failed to load because no supported source was found

    &#xA;

    &#xA;

    And I don't know why...

    &#xA;

    I tried everything, but I don't understand why src is incorrect..

    &#xA;

  • How to get a mp4 stream from a mp4 file using java ?

    16 décembre 2015, par Vishnu
    <video class="video-js vjs-default-skin embed-responsive-item" controls="controls" preload="auto" width="640" height="264" responsive="true" poster="http://video-js.zencoder.com/oceans-clip.png" data-setup="{&quot;example_option&quot;:true}">
            <source src="http://video-js.zencoder.com/oceans-clip.mp4" type="video/mp4"></source>
            <p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>
           </video>

    The above would play stream video from the specified src.

    How can a similar streaming url be generated from a mp4 file using java so that the streaming url can be used in the "src" to play the video.