Recherche avancée

Médias (0)

Mot : - Tags -/utilisateurs

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

Autres articles (80)

  • Gestion des droits de création et d’édition des objets

    8 février 2011, par

    Par défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

Sur d’autres sites (4503)

  • avcodec/lossless_videoencdsp : Fix unaligned access

    13 mars 2024, par Andreas Rheinhardt
    avcodec/lossless_videoencdsp : Fix unaligned access
    

    HAVE_FAST_UNALIGNED being true does not imply that
    one can simply read from any pointer via *(long*).
    It is undefined behaviour in case the pointer is not
    sufficiently aligned ; and even if it is, it is (likely)
    a violation of the effective-type rules. Fix both
    of these by using the appropriate AV_[RW]N macros.

    Also, the current code used sizeof(long) as if this
    were the CPU's native arithmetic size, but this is
    not true on 64bit Windows. This has been fixed, too.

    This affected huffyuv FATE-tests.

    Tested-by : Sean McGovern <gseanmcg@gmail.com>
    Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

    • [DH] libavcodec/lossless_videoencdsp.c
  • Adding audio to video without re encoding [migrated]

    4 mars 2015, par user1503606

    I am looking to add audio to a video without having to re encode the two pieces.

    I have looked at a few questions on stack overflow followed the answers and i still cant seemed to get it to work, if anyone can spot what i am missing please help.

    I am running this code.

    ffmpeg -i DJ_Mes_Rescue-Some_Day-Guesthouse_Music.mp3 -i output.mp4 -map 0:0 -map 1:0 -acodec copy -vcodec copy -shortest edit2.mp4

    Now from what i understand ffmpeg is mapping the stream over the top ffmpeg info for the audio track is.

    Input #0, mp3, from 'DJ_Mes_Rescue-Some_Day-Guesthouse_Music.mp3':
     Metadata:
       encoder         : LAME 64bits version 3.98.4 (http://www.mp3dev.org/)
       title           : Some Day
       artist          : DJ Mes, Rescue
       TLEN            : 378750
       genre           : House
       track           : 1/0
       date            : 2015
     Duration: 00:06:18.80, start: 0.025056, bitrate: 320 kb/s
       Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
       Metadata:
         encoder         : LAME3.98r
       Side data:
         replaygain: track gain - -10.100000, track peak - unknown, album gain - unknown, album peak - unknown,
       Stream #0:1: Video: png, rgb24, 225x225, 90k tbr, 90k tbn, 90k tbc
       Metadata:
         title           :
         comment         : Other

    And for the video it is.

    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf56.15.102
     Duration: 00:00:49.46, start: 0.046440, bitrate: 566 kb/s
       Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 568x320, 462 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         rotate          : 90
         handler_name    : VideoHandler
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
       Metadata:
         handler_name    : SoundHandler

    So i am mapping the stream 0:0 from the audio file to 1:0 from the video file, but all i seem to get is a video with no audio.

    Can someone help ?

    UPDATE whole output added

    ffmpeg -i Saison-Please_Don%27t_Go-Guesthouse_Music.mp3 -i output.mp4 -c copy -map 0:0 -map 1:0 -shortest mixed.mp4
    ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers
     built on Jan 12 2015 10:15:06 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
     configuration: --prefix=/usr/local/Cellar/ffmpeg/2.5.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1_1/include/openjpeg-1.5 ' --enable-nonfree --enable-vda
     libavutil      54. 15.100 / 54. 15.100
     libavcodec     56. 13.100 / 56. 13.100
     libavformat    56. 15.102 / 56. 15.102
     libavdevice    56.  3.100 / 56.  3.100
     libavfilter     5.  2.103 /  5.  2.103
     libavresample   2.  1.  0 /  2.  1.  0
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  3.100 / 53.  3.100
    Input #0, mp3, from 'Saison-Please_Don%27t_Go-Guesthouse_Music.mp3':
     Metadata:
       encoder         : LAME 64bits version 3.98.4 (http://www.mp3dev.org/)
       title           : Please Donât Go
       artist          : Saison
       TLEN            : 408492
       genre           : House
       track           : 1/0
       date            : 2015
     Duration: 00:06:48.53, start: 0.025056, bitrate: 320 kb/s
       Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
       Metadata:
         encoder         : LAME3.98r
       Side data:
         replaygain: track gain - -8.400000, track peak - unknown, album gain - unknown, album peak - unknown,
       Stream #0:1: Video: png, rgb24, 225x225, 90k tbr, 90k tbn, 90k tbc
       Metadata:
         title           :
         comment         : Other
    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf56.15.102
     Duration: 00:00:49.46, start: 0.046440, bitrate: 566 kb/s
       Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 568x320, 462 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         rotate          : 90
         handler_name    : VideoHandler
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
    Output #0, mp4, to 'mixed.mp4':
     Metadata:
       date            : 2015
       title           : Please Donât Go
       artist          : Saison
       TLEN            : 408492
       genre           : House
       track           : 1/0
       encoder         : Lavf56.15.102
       Stream #0:0: Audio: mp3 (i[0][0][0] / 0x0069), 44100 Hz, stereo, 320 kb/s
       Metadata:
         encoder         : LAME3.98r
       Side data:
         replaygain: track gain - -8.400000, track peak - unknown, album gain - unknown, album peak - unknown,
       Stream #0:1(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 568x320, q=2-31, 462 kb/s, 30 fps, 15360 tbn, 15360 tbc (default)
       Metadata:
         rotate          : 90
         handler_name    : VideoHandler
       Side data:
         displaymatrix: rotation of -90.00 degrees
    Stream mapping:
     Stream #0:0 -> #0:0 (copy)
     Stream #1:0 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    frame= 1481 fps=0.0 q=-1.0 Lsize=    4759kB time=00:00:49.34 bitrate= 790.0kbits/s    
    video:2785kB audio:1929kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.960839%

    ANOTHER UPDATE :

    So i have tried the following

    ffmpeg -i 3.mp4 -i Saison-Please_Don%27t_Go-Guesthouse_Music.mp3 -i Saison-Please_Don%27t_Go-Guesthouse_Music.mp3 -map 0:0 -map 0:1 -map 1:0 -map 2:0 -c:v copy -c:a copy 23.mp4

    and if i run.

    ffmpeg -i 23.mp4

    You can see the streams/audio has been added but it is not playing ?

    Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf56.15.102
     Duration: 00:06:48.53, start: 0.025057, bitrate: 713 kb/s
       Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 568x320, 462 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
       Metadata:
         rotate          : 90
         handler_name    : VideoHandler
       Side data:
         displaymatrix: rotation of -90.00 degrees
       Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
       Metadata:
         handler_name    : SoundHandler
       Stream #0:2(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 319 kb/s
       Metadata:
         handler_name    : SoundHandler
       Stream #0:3(und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 319 kb/s
       Metadata:
         handler_name    : SoundHandler

    ONE MORE UPDATE THIS SEEMS TO WORK :

    ffmpeg -i 3.mp4 -i Saison-Please_Don%27t_Go-Guesthouse_Music.mp3 -map 0:0 -map 0:1 -map 1:0  -c:v copy -c:a copy 234.mp4 &amp;&amp; ffmpeg -i 234.mp4 -map 0:0 -map 0:2 -acodec copy -vcodec copy new_file3.mp4
  • Segments not loading in HLS Stream encoded with FFMPEG

    9 novembre 2023, par myfoxit

    I'm currently facing a significant issue with my transcoding pipeline. Some video files produce a corrupted m3u8 playlist, wherein a few segments load but then the process halts. Even jumping to different segments in the video player doesn't resolve the issue. However, the file in question works fine when I use third-party transcoding services that utilize ffmpeg in the background, so the problem is definitely with my FFMPEG code.

    &#xA;

    To diagnose the issue, I've tried the following steps :

    &#xA;

      &#xA;
    • Simplifying the FFMPEG command.
    • &#xA;

    • Testing across different browsers, but the problem persists in every browser.
    • &#xA;

    • Using various video players (It works with VLC, Bitmovin, Video.js) but not with Plyr, which I usually use. This could be because they ignore the error or are less sensitive to errors.
    • &#xA;

    • My files are hosted on AWS S3, but I also tried streaming them via the Next.js public folder and a custom web server, so the issue is not related to hosting.
    • &#xA;

    • Ruled out CORS as the issue.
    • &#xA;

    • Attempted to detect errors using ffprobe, but found no results.
    • &#xA;

    • Modified the bitrate in the playlist.
    • &#xA;

    • Changed the viewing device.
    • &#xA;

    • Altered the segment length, but the issue persists : with 10s segments, it's segment 2 that causes the problem ; with 5s segments, then segment 4.
    • &#xA;

    • No error output is visible in ffmpeg, even when using verbose mode.
    • &#xA;

    &#xA;

    mediastreamvalidator on Apple prints out error with provided bitrate and used bitrate but changing that also did not help.

    &#xA;

    HLS Analyzer shows a buffer stalled error.

    &#xA;

    const fs = require(&#x27;fs&#x27;);&#xA;const path = require(&#x27;path&#x27;);&#xA;const { v4: uuidv4 } = require(&#x27;uuid&#x27;);&#xA;require(&#x27;dotenv&#x27;).config();&#xA;const { processVideo } = require("./ffmpegHandler");&#xA;&#xA;&#xA;const VIDEO_PATH = process.env.VIDEO_PATH; &#xA;const VIDEO_STATE = JSON.parse(process.env.VIDEO_STATE);&#xA;const VIDEO_SIZE = JSON.parse(process.env.VIDEO_SIZE);&#xA;const VIDEO_DURATION = process.env.VIDEO_DURATION;&#xA;&#xA;const OUTPUT_DIRECTORY = &#x27;/tmp/output&#x27;;&#xA;&#xA;console.log("Video Path: " &#x2B; VIDEO_PATH)&#xA;console.log("Video State: " &#x2B; VIDEO_STATE)&#xA;console.log("Video Size: " &#x2B; VIDEO_SIZE)&#xA;console.log("Video Duration: " &#x2B; VIDEO_DURATION)&#xA;&#xA;async function processLocalVideo(localPath) {&#xA;    const uniqueFolderName = uuidv4();  &#xA;    const localOutputDirectory = path.join(OUTPUT_DIRECTORY, uniqueFolderName);&#xA;&#xA;    // Ensure the output directory exists&#xA;    if (!fs.existsSync(localOutputDirectory)) {&#xA;        fs.mkdirSync(localOutputDirectory, { recursive: true });&#xA;    }&#xA;&#xA;    // Process the video locally&#xA;    processVideo(localPath, VIDEO_STATE, VIDEO_SIZE, VIDEO_DURATION, (err, message) => {&#xA;        if (err) {&#xA;            console.error(&#x27;Error processing video:&#x27;, err);&#xA;            return;&#xA;        }&#xA;        console.log(&#x27;Video processing complete. HLS files are located at:&#x27;, localOutputDirectory);&#xA;    });&#xA;}&#xA;&#xA;// Start the processing&#xA;processLocalVideo(VIDEO_PATH).catch((error) => {&#xA;    console.error(&#x27;An error occurred during video processing:&#x27;, error);&#xA;});&#xA;&#xA;&#xA;

    &#xA;

    const {exec} = require("child_process");&#xA;const ffmpegPath = require("ffmpeg-static");&#xA;const fs = require("fs");&#xA;const path = require("path");&#xA;const {spawn} = require("child_process");&#xA;const {generateArgs} = require("./generateArgs");&#xA;const {getResolutions, printDirectoryStructure, createMasterPlaylistContent} = require("./utility");&#xA;&#xA;&#xA;const OUTPUT_DIR = &#x27;/tmp/output&#x27;;&#xA;&#xA;&#xA;function processVideo(filePath, imageState, size, duration, callback) {&#xA;&#xA;&#xA;    if (!fs.existsSync(OUTPUT_DIR)) {&#xA;        fs.mkdirSync(OUTPUT_DIR, {recursive: true});&#xA;    }&#xA;&#xA;    const resolutions = getResolutions(size);&#xA;    const outputHLSPath = path.join(OUTPUT_DIR, &#x27;dest.m3u8&#x27;);&#xA;    const segmentPattern = &#x27;segment_%03d.ts&#x27;;&#xA;    const outputSegmentPath = path.join(OUTPUT_DIR, segmentPattern);&#xA;&#xA;    const ffmpegPromises = resolutions.map(resolution => {&#xA;        return new Promise((resolve, reject) => {&#xA;            const scaleFilter = `scale=w=${resolution.width}:h=${resolution.height}`;&#xA;            const outputHLSPath = path.join(OUTPUT_DIR, resolution.label, &#x27;dest.m3u8&#x27;);&#xA;            const segmentPattern = `segment_%03d.ts`;&#xA;            const outputSegmentPath = path.join(OUTPUT_DIR, resolution.label, segmentPattern);&#xA;&#xA;            // Ensure resolution-specific directory exists&#xA;            if (!fs.existsSync(path.join(OUTPUT_DIR, resolution.label))) {&#xA;                fs.mkdirSync(path.join(OUTPUT_DIR, resolution.label), {recursive: true});&#xA;            }&#xA;&#xA;            const args = generateArgs(filePath, imageState, size, duration, resolution);&#xA;&#xA;&#xA;            const resolutionArgs = [&#xA;                ...args,&#xA;                &#x27;-hls_segment_filename&#x27;, outputSegmentPath,&#xA;                outputHLSPath&#xA;            ];&#xA;&#xA;            console.log(resolutionArgs)&#xA;&#xA;            const command = `${ffmpegPath} ${resolutionArgs.join(" ")}`;&#xA;&#xA;&#xA;            const ffmpeg = spawn(ffmpegPath, resolutionArgs);&#xA;&#xA;&#xA;            ffmpeg.on(&#x27;error&#x27;, (error) => {&#xA;                console.error(`Error with FFmpeg process: ${error.message}`);&#xA;                reject(error);&#xA;            });&#xA;&#xA;            ffmpeg.stderr.on(&#x27;data&#x27;, (data) => {&#xA;                console.error(`FFmpeg stderr: ${data}`);&#xA;            });&#xA;&#xA;            ffmpeg.on(&#x27;close&#x27;, (code) => {&#xA;                if (code !== 0) {&#xA;                    reject(new Error(`FFmpeg process exited with code ${code}`));&#xA;                } else {&#xA;                    resolve();&#xA;                }&#xA;            });&#xA;        });&#xA;    });&#xA;&#xA;&#xA;    Promise.all(ffmpegPromises)&#xA;        .then(() => {&#xA;            const masterPlaylistContent = createMasterPlaylistContent(resolutions, OUTPUT_DIR);&#xA;            const masterPlaylistPath = path.join(OUTPUT_DIR, &#x27;master.m3u8&#x27;);&#xA;            fs.writeFileSync(masterPlaylistPath, masterPlaylistContent);&#xA;&#xA;            printDirectoryStructure(&#x27;/tmp/output&#x27;, (err) => {&#xA;                if (err) {&#xA;                    console.error(err);&#xA;                    callback(err);&#xA;                } else {&#xA;                    console.log(&#x27;Directory structure printed successfully.&#x27;);&#xA;                    callback(null, &#x27;All files processed successfully!&#x27;);&#xA;                }&#xA;            });&#xA;        })&#xA;        .catch((error) => {&#xA;            callback(error);&#xA;        });&#xA;}&#xA;&#xA;&#xA;module.exports = {&#xA;    processVideo,&#xA;};&#xA;&#xA;&#xA;&#xA;&#xA;

    &#xA;

    &#xA;const {getColorMatrixFromColorMatrices, isNumber} = require("./utility");&#xA;&#xA;function generateArgs(filePath, imageState, size, duration, resolution){&#xA;    const args = [];&#xA;    const filters = [];&#xA;&#xA;    args.push("-i", filePath);&#xA;&#xA;&#xA;    const {&#xA;        flipX,&#xA;        flipY,&#xA;        rotation,&#xA;        crop,&#xA;        trim,&#xA;        gamma,&#xA;        colorMatrix,&#xA;        convolutionMatrix,&#xA;    } = imageState;&#xA;&#xA;    console.log(crop);&#xA;&#xA;    // 1. Flip&#xA;    if (flipX || flipY) {&#xA;        flipX &amp;&amp; filters.push(`hflip`);&#xA;        flipY &amp;&amp; filters.push(`vflip`);&#xA;    }&#xA;&#xA;    // 2. Rotate&#xA;    if (rotation) {&#xA;        const width =&#xA;            Math.abs(size.width * Math.sin(rotation)) &#x2B;&#xA;            Math.abs(size.height * Math.cos(rotation));&#xA;&#xA;        const height =&#xA;            Math.abs(size.width * Math.cos(rotation)) &#x2B;&#xA;            Math.abs(size.height * Math.sin(rotation));&#xA;&#xA;        filters.push(&#xA;            `rotate=&#x27;${rotation}:ow=${Math.floor(width)}:oh=${Math.floor(height)}&#x27;`&#xA;        );&#xA;    }&#xA;&#xA;    // 3. Crop&#xA;    if (&#xA;        !(&#xA;            crop.x === 0 &amp;&amp;&#xA;            crop.y === 0 &amp;&amp;&#xA;            crop.width === size.width &amp;&amp;&#xA;            crop.height === size.height&#xA;        )&#xA;    ) {&#xA;        filters.push(`crop=${crop.width}:${crop.height}:${crop.x}:${crop.y}`);&#xA;    }&#xA;&#xA;&#xA;    // 5. Convolution Matrix&#xA;    if (convolutionMatrix &amp;&amp; convolutionMatrix.clarity) {&#xA;        filters.push(`convolution=&#x27;${convolutionMatrix.clarity.join(" ")}&#x27;`);&#xA;    }&#xA;&#xA;    // 6. Gamma&#xA;    if (gamma > 0) {&#xA;        filters.push(`eq=gamma=${gamma}:gamma_weight=0.85`);&#xA;    }&#xA;&#xA;    // 7. Color Matrix&#xA;    const colorMatrices = Object.values(colorMatrix || {}).filter(Boolean);&#xA;    if (colorMatrices.length) {&#xA;        // See helper section below for the getColorMatrixFromColorMatrices function definition&#xA;        const colorMatrix = getColorMatrixFromColorMatrices(colorMatrices);&#xA;        const skip = [4, 9, 14, 19];&#xA;        const cl = colorMatrix;&#xA;        const ccm = colorMatrix.filter((v, i) => !skip.includes(i));&#xA;        const [ro, go, bo] = [cl[4] &#x2B; cl[3], cl[9] &#x2B; cl[8], cl[14] &#x2B; cl[13]];&#xA;        filters.push(&#xA;            `colorchannelmixer=${ccm.join(":")}`,&#xA;            `lutrgb=r=val&#x2B;(${ro * 255}):g=val&#x2B;(${go * 255}):b=val&#x2B;(${bo * 255})`&#xA;        );&#xA;    }&#xA;&#xA;&#xA;    if (resolution) {&#xA;        const scaleFilter = `scale=w=${resolution.width}:h=${resolution.height}`;&#xA;        filters.push(scaleFilter);&#xA;    }&#xA;&#xA;&#xA;    // 8. Trim&#xA;    if (trim) {&#xA;        const inputRanges = (&#xA;            Array.isArray(trim) &amp;&amp; isNumber(trim[0]) ? [trim] : trim&#xA;        )&#xA;            .map((range, index) => {&#xA;                const from = range[0] * duration;&#xA;                const to = range[1] * duration;&#xA;                const v = `[0:v]trim=start=${from}:end=${to},setpts=PTS-STARTPTS${filters&#xA;                    .map((filter) => "," &#x2B; filter)&#xA;                    .join("")}[${index}v];`;&#xA;                const a = `[0:a]atrim=start=${from}:end=${to},asetpts=PTS-STARTPTS[${index}a];`;&#xA;                return v &#x2B; a;&#xA;            })&#xA;            .join("");&#xA;&#xA;&#xA;        filters.length = 0;&#xA;&#xA;        const inputRangesKeys = trim&#xA;            .map((_, index) => `[${index}v][${index}a]`)&#xA;            .join("");&#xA;&#xA;        const concatOutput = `${inputRangesKeys}concat=n=${trim.length}:v=1:a=1[outv][outa]`;&#xA;&#xA;        args.push("-filter_complex", `${inputRanges}${concatOutput}`);&#xA;        args.push("-map", "[outv]", "-map", "[outa]");&#xA;    } else {&#xA;        filters.length &amp;&amp; args.push("-filter_complex", `${filters.join(",")}`);&#xA;    }&#xA;&#xA;&#xA;    // Add output file&#xA;    args.push(&#xA;        "-codec:v",&#xA;        "libx264",&#xA;        "-crf",&#xA;        "21",&#xA;        "-preset",&#xA;        "veryfast",&#xA;        "-g",&#xA;        "30",&#xA;        "-sc_threshold",&#xA;        "0",&#xA;        "-hls_time",&#xA;        "10",&#xA;        "-hls_list_size",&#xA;        "0",&#xA;&#xA;    );&#xA;&#xA;    return args&#xA;}&#xA;&#xA;module.exports = {&#xA;    generateArgs,&#xA;};&#xA;&#xA;&#xA;&#xA;

    &#xA;

    const {exec} = require("child_process");&#xA;&#xA;&#xA;function isNumber(value) {&#xA;    return typeof value === "number" &amp;&amp; !isNaN(value);&#xA;}&#xA;&#xA;function getColorMatrixFromColorMatrices(colorMatrices) {&#xA;    return colorMatrices.length&#xA;        ? colorMatrices.reduce(&#xA;            (previous, current) => dotColorMatrix([...previous], current),&#xA;            colorMatrices.shift()&#xA;        )&#xA;        : [];&#xA;}&#xA;&#xA;function dotColorMatrix(a, b) {&#xA;    const res = new Array(20);&#xA;&#xA;    // R&#xA;    res[0] = a[0] * b[0] &#x2B; a[1] * b[5] &#x2B; a[2] * b[10] &#x2B; a[3] * b[15];&#xA;    res[1] = a[0] * b[1] &#x2B; a[1] * b[6] &#x2B; a[2] * b[11] &#x2B; a[3] * b[16];&#xA;    res[2] = a[0] * b[2] &#x2B; a[1] * b[7] &#x2B; a[2] * b[12] &#x2B; a[3] * b[17];&#xA;    res[3] = a[0] * b[3] &#x2B; a[1] * b[8] &#x2B; a[2] * b[13] &#x2B; a[3] * b[18];&#xA;    res[4] = a[0] * b[4] &#x2B; a[1] * b[9] &#x2B; a[2] * b[14] &#x2B; a[3] * b[19] &#x2B; a[4];&#xA;&#xA;    // G&#xA;    res[5] = a[5] * b[0] &#x2B; a[6] * b[5] &#x2B; a[7] * b[10] &#x2B; a[8] * b[15];&#xA;    res[6] = a[5] * b[1] &#x2B; a[6] * b[6] &#x2B; a[7] * b[11] &#x2B; a[8] * b[16];&#xA;    res[7] = a[5] * b[2] &#x2B; a[6] * b[7] &#x2B; a[7] * b[12] &#x2B; a[8] * b[17];&#xA;    res[8] = a[5] * b[3] &#x2B; a[6] * b[8] &#x2B; a[7] * b[13] &#x2B; a[8] * b[18];&#xA;    res[9] = a[5] * b[4] &#x2B; a[6] * b[9] &#x2B; a[7] * b[14] &#x2B; a[8] * b[19] &#x2B; a[9];&#xA;&#xA;    // B&#xA;    res[10] = a[10] * b[0] &#x2B; a[11] * b[5] &#x2B; a[12] * b[10] &#x2B; a[13] * b[15];&#xA;    res[11] = a[10] * b[1] &#x2B; a[11] * b[6] &#x2B; a[12] * b[11] &#x2B; a[13] * b[16];&#xA;    res[12] = a[10] * b[2] &#x2B; a[11] * b[7] &#x2B; a[12] * b[12] &#x2B; a[13] * b[17];&#xA;    res[13] = a[10] * b[3] &#x2B; a[11] * b[8] &#x2B; a[12] * b[13] &#x2B; a[13] * b[18];&#xA;    res[14] = a[10] * b[4] &#x2B; a[11] * b[9] &#x2B; a[12] * b[14] &#x2B; a[13] * b[19] &#x2B; a[14];&#xA;&#xA;    // A&#xA;    res[15] = a[15] * b[0] &#x2B; a[16] * b[5] &#x2B; a[17] * b[10] &#x2B; a[18] * b[15];&#xA;    res[16] = a[15] * b[1] &#x2B; a[16] * b[6] &#x2B; a[17] * b[11] &#x2B; a[18] * b[16];&#xA;    res[17] = a[15] * b[2] &#x2B; a[16] * b[7] &#x2B; a[17] * b[12] &#x2B; a[18] * b[17];&#xA;    res[18] = a[15] * b[3] &#x2B; a[16] * b[8] &#x2B; a[17] * b[13] &#x2B; a[18] * b[18];&#xA;    res[19] = a[15] * b[4] &#x2B; a[16] * b[9] &#x2B; a[17] * b[14] &#x2B; a[18] * b[19] &#x2B; a[19];&#xA;&#xA;    return res;&#xA;}&#xA;&#xA;function getResolutions(videoSize) {&#xA;    // Define the resolutions&#xA;    const resolutions = [&#xA;        {width: 1280, height: 720, label: "720p", bandwidth: "1400000"},&#xA;        {width: 854, height: 480, label: "480p", bandwidth: "800000"},&#xA;        {width: 426, height: 240, label: "240p", bandwidth: "600000"}&#xA;    ];&#xA;&#xA;    // Filter out resolutions that are larger than the video&#x27;s original size&#xA;    return resolutions.filter(res => res.width &lt;= videoSize.width);&#xA;}&#xA;&#xA;&#xA;function printDirectoryStructure(directory, callback) {&#xA;    exec(`find &#x27;${directory}&#x27; -print`, (error, stdout, stderr) => {&#xA;        if (error) {&#xA;            console.error(`exec error: ${error}`);&#xA;            return callback(error);&#xA;        }&#xA;        if (stderr) {&#xA;            console.error(`stderr: ${stderr}`);&#xA;            return callback(stderr);&#xA;        }&#xA;        console.log(`Directory structure of ${directory}:\n${stdout}`);&#xA;        callback(null);&#xA;    });&#xA;}&#xA;&#xA;&#xA;function createMasterPlaylistContent(resolutions, outputDir) {&#xA;    let content = &#x27;#EXTM3U\n#EXT-X-VERSION:3\n&#x27;;&#xA;    resolutions.forEach((resolution) => {&#xA;        content &#x2B;= `#EXT-X-STREAM-INF:BANDWIDTH=${resolution.bandwidth},RESOLUTION=${resolution.width}x${resolution.height}\n`;&#xA;        content &#x2B;= `${resolution.label}/dest.m3u8\n`;&#xA;    });&#xA;    return content;&#xA;}&#xA;&#xA;&#xA;function getKeyFromUrl(url) {&#xA;    const urlParts = new URL(url);&#xA;    return urlParts.pathname.substring(1);&#xA;}&#xA;&#xA;&#xA;module.exports = {&#xA;    getResolutions,&#xA;    getColorMatrixFromColorMatrices,&#xA;    isNumber,&#xA;    printDirectoryStructure,&#xA;    createMasterPlaylistContent,&#xA;    getKeyFromUrl&#xA;};&#xA;&#xA;

    &#xA;