Recherche avancée

Médias (91)

Autres articles (60)

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

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (10849)

  • What permission ffmpeg-static need in AWS Lambda ?

    17 février 2023, par János

    I have this code. It download a image, made a video from it and upload it to S3. It runs on Lambda. Added packages, intalled, zipped, uploaded.

    


    npm install --production
zip -r my-lambda-function.zip ./


    


    But get an error code 126

    


    2023-02-17T09:27:55.236Z    5c845bb6-02c1-41b0-8759-4459591b57b0    INFO    Error: ffmpeg exited with code 126&#xA;    at ChildProcess.<anonymous> (/var/task/node_modules/fluent-ffmpeg/lib/processor.js:182:22)&#xA;    at ChildProcess.emit (node:events:513:28)&#xA;    at ChildProcess._handle.onexit (node:internal/child_process:291:12)&#xA;2023-02-17T09:27:55.236Z 5c845bb6-02c1-41b0-8759-4459591b57b0 INFO Error: ffmpeg exited with code 126 at ChildProcess.<anonymous> (/var/task/node_modules/fluent-ffmpeg/lib/processor.js:182:22) at ChildProcess.emit (node:events:513:28) at ChildProcess._handle.onexit (node:internal/child_process:291:12)&#xA;</anonymous></anonymous>

    &#xA;

    Do I need to set a specific premission for ffmpeg ?

    &#xA;

    import { PutObjectCommand, S3Client } from &#x27;@aws-sdk/client-s3&#x27;&#xA;import { fromNodeProviderChain } from &#x27;@aws-sdk/credential-providers&#x27;&#xA;import axios from &#x27;axios&#x27;&#xA;import pathToFfmpeg from &#x27;ffmpeg-static&#x27;&#xA;import ffmpeg from &#x27;fluent-ffmpeg&#x27;&#xA;import fs from &#x27;fs&#x27;&#xA;ffmpeg.setFfmpegPath(pathToFfmpeg)&#xA;const credentials = fromNodeProviderChain({&#xA;    clientConfig: {&#xA;        region: &#x27;eu-central-1&#x27;,&#xA;    },&#xA;})&#xA;const client = new S3Client({ credentials })&#xA;&#xA;export const handler = async (event, context) => {&#xA;    try {&#xA;        let body&#xA;        let statusCode = 200&#xA;        const query = event?.queryStringParameters&#xA;        if (!query?.imgId &amp;&amp; !query?.video1Id &amp;&amp; !query?.video2Id) {&#xA;            return&#xA;        }&#xA;&#xA;        const imgId = query?.imgId&#xA;        const video1Id = query?.video1Id&#xA;        const video2Id = query?.video2Id&#xA;        console.log(&#xA;            `Parameters received, imgId: ${imgId}, video1Id: ${video1Id}, video2Id: ${video2Id}`&#xA;        )&#xA;        const imgURL = getFileURL(imgId)&#xA;        const video1URL = getFileURL(`${video1Id}.mp4`)&#xA;        const video2URL = getFileURL(`${video2Id}.mp4`)&#xA;        const imagePath = `/tmp/${imgId}`&#xA;        const video1Path = `/tmp/${video1Id}.mp4`&#xA;        const video2Path = `/tmp/${video2Id}.mp4`&#xA;        const outputPath = `/tmp/${imgId}.mp4`&#xA;        await Promise.all([&#xA;            downloadFile(imgURL, imagePath),&#xA;            downloadFile(video1URL, video1Path),&#xA;            downloadFile(video2URL, video2Path),&#xA;        ])&#xA;        await new Promise((resolve, reject) => {&#xA;            console.log(&#x27;Input files downloaded&#x27;)&#xA;            ffmpeg()&#xA;                .input(imagePath)&#xA;                .inputFormat(&#x27;image2&#x27;)&#xA;                .inputFPS(30)&#xA;                .loop(1)&#xA;                .size(&#x27;1080x1080&#x27;)&#xA;                .videoCodec(&#x27;libx264&#x27;)&#xA;                .format(&#x27;mp4&#x27;)&#xA;                .outputOptions([&#xA;                    &#x27;-tune animation&#x27;,&#xA;                    &#x27;-pix_fmt yuv420p&#x27;,&#xA;                    &#x27;-profile:v baseline&#x27;,&#xA;                    &#x27;-level 3.0&#x27;,&#xA;                    &#x27;-preset medium&#x27;,&#xA;                    &#x27;-crf 23&#x27;,&#xA;                    &#x27;-movflags &#x2B;faststart&#x27;,&#xA;                    &#x27;-y&#x27;,&#xA;                ])&#xA;                .output(outputPath)&#xA;                .on(&#x27;end&#x27;, () => {&#xA;                    console.log(&#x27;Output file generated&#x27;)&#xA;                    resolve()&#xA;                })&#xA;                .on(&#x27;error&#x27;, (e) => {&#xA;                    console.log(e)&#xA;                    reject()&#xA;                })&#xA;                .run()&#xA;            &#xA;        })&#xA;        await uploadFile(outputPath, imgId &#x2B; &#x27;.mp4&#x27;)&#xA;            .then((url) => {&#xA;                body = JSON.stringify({&#xA;                    url,&#xA;                })&#xA;            })&#xA;            .catch((error) => {&#xA;                console.error(error)&#xA;                statusCode = 400&#xA;                body = error?.message ?? error&#xA;            })&#xA;        console.log(`File uploaded to S3`)&#xA;        const headers = {&#xA;            &#x27;Content-Type&#x27;: &#x27;application/json&#x27;,&#xA;            &#x27;Access-Control-Allow-Headers&#x27;: &#x27;Content-Type&#x27;,&#xA;            &#x27;Access-Control-Allow-Origin&#x27;: &#x27;https://tikex.com, https://borespiac.hu&#x27;,&#xA;            &#x27;Access-Control-Allow-Methods&#x27;: &#x27;GET&#x27;,&#xA;        }&#xA;        return {&#xA;            statusCode,&#xA;            body,&#xA;            headers,&#xA;        }&#xA;    } catch (error) {&#xA;        console.error(error)&#xA;        return {&#xA;            statusCode: 500,&#xA;            body: JSON.stringify(&#x27;Error fetching data&#x27;),&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;const downloadFile = async (url, path) => {&#xA;    try {&#xA;        console.log(`Download will start: ${url}`)&#xA;        const response = await axios(url, {&#xA;            responseType: &#x27;stream&#x27;,&#xA;        })&#xA;        if (response.status !== 200) {&#xA;            throw new Error(&#xA;                `Failed to download file, status code: ${response.status}`&#xA;            )&#xA;        }&#xA;        response.data&#xA;            .pipe(fs.createWriteStream(path))&#xA;            .on(&#x27;finish&#x27;, () => console.log(`File downloaded to ${path}`))&#xA;            .on(&#x27;error&#x27;, (e) => {&#xA;                throw new Error(`Failed to save file: ${e}`)&#xA;            })&#xA;    } catch (e) {&#xA;        console.error(`Error downloading file: ${e}`)&#xA;    }&#xA;}&#xA;const uploadFile = async (path, id) => {&#xA;    const buffer = fs.readFileSync(path)&#xA;    const params = {&#xA;        Bucket: &#x27;t44-post-cover&#x27;,&#xA;        ACL: &#x27;public-read&#x27;,&#xA;        Key: id,&#xA;        ContentType: &#x27;video/mp4&#x27;,&#xA;        Body: buffer,&#xA;    }&#xA;    await client.send(new PutObjectCommand(params))&#xA;    return getFileURL(id)&#xA;}&#xA;const getFileURL = (id) => {&#xA;    const bucket = &#x27;t44-post-cover&#x27;&#xA;    const url = `https://${bucket}.s3.eu-central-1.amazonaws.com/${id}`&#xA;    return url&#xA;}&#xA;

    &#xA;

    Added AWSLambdaBasicExecutionRole-16e770c8-05fa-4c42-9819-12c468cb5b49 permission, with policy :

    &#xA;

    {&#xA;    "Version": "2012-10-17",&#xA;    "Statement": [&#xA;        {&#xA;            "Effect": "Allow",&#xA;            "Action": "logs:CreateLogGroup",&#xA;            "Resource": "arn:aws:logs:eu-central-1:634617701827:*"&#xA;        },&#xA;        {&#xA;            "Effect": "Allow",&#xA;            "Action": [&#xA;                "logs:CreateLogStream",&#xA;                "logs:PutLogEvents"&#xA;            ],&#xA;            "Resource": [&#xA;                "arn:aws:logs:eu-central-1:634617701827:log-group:/aws/lambda/promo-video-composer-2:*"&#xA;            ]&#xA;        },&#xA;        {&#xA;            "Effect": "Allow",&#xA;            "Action": [&#xA;                "s3:GetObject",&#xA;                "s3:PutObject",&#xA;                "s3:ListBucket"&#xA;            ],&#xA;            "Resource": [&#xA;                "arn:aws:s3:::example-bucket",&#xA;                "arn:aws:s3:::example-bucket/*"&#xA;            ]&#xA;        },&#xA;        {&#xA;            "Effect": "Allow",&#xA;            "Action": [&#xA;                "logs:CreateLogGroup",&#xA;                "logs:CreateLogStream",&#xA;                "logs:PutLogEvents"&#xA;            ],&#xA;            "Resource": [&#xA;                "arn:aws:logs:*:*:*"&#xA;            ]&#xA;        },&#xA;        {&#xA;            "Effect": "Allow",&#xA;            "Action": [&#xA;                "ec2:DescribeNetworkInterfaces"&#xA;            ],&#xA;            "Resource": [&#xA;                "*"&#xA;            ]&#xA;        },&#xA;        {&#xA;            "Effect": "Allow",&#xA;            "Action": [&#xA;                "sns:*"&#xA;            ],&#xA;            "Resource": [&#xA;                "*"&#xA;            ]&#xA;        },&#xA;        {&#xA;            "Effect": "Allow",&#xA;            "Action": [&#xA;                "cloudwatch:*"&#xA;            ],&#xA;            "Resource": [&#xA;                "*"&#xA;            ]&#xA;        },&#xA;        {&#xA;            "Effect": "Allow",&#xA;            "Action": [&#xA;                "kms:Decrypt"&#xA;            ],&#xA;            "Resource": [&#xA;                "*"&#xA;            ]&#xA;        }&#xA;    ]&#xA;}&#xA;

    &#xA;

    What do I miss ?

    &#xA;

    janoskukoda@Janoss-MacBook-Pro promo-video-composer-2 % ls -l $(which ffmpeg)&#xA;lrwxr-xr-x  1 janoskukoda  admin  35 Feb 10 12:50 /opt/homebrew/bin/ffmpeg -> ../Cellar/ffmpeg/5.1.2_4/bin/ffmpeg&#xA;

    &#xA;

  • Node.js readable maximize throughput/performance for compute intense readable - Writable doesn't pull data fast enough

    31 décembre 2022, par flohall

    General setup

    &#xA;

    I developed an application using AWS Lambda node.js 14.&#xA;I use a custom Readable implementation FrameCreationStream that uses node-canvas to draw images, svgs and more on a canvas. This result is then extracted as a raw image buffer in BGRA. A single image buffer contains 1920 * 1080 * 4 Bytes = 8294400 Bytes 8 MB.&#xA;This is then piped to stdin of a child_process running ffmpeg.&#xA;The highWaterMark of my Readable in objectMode:true is set to 25 so that the internal buffer can use up to 8 MB * 25 = 200 MB.

    &#xA;

    All this works fine and also doesn't contain too much RAM. But I noticed after some time, that the performance is not ideally.

    &#xA;

    Performance not optimal

    &#xA;

    I have an example input that generates a video of 315 frames. If I set highWaterMark to a value above 25 the performance increases to the point, when I set to a value of 315 or above.

    &#xA;

    For some reason ffmpeg doesn't start to pull any data until highWaterMark is reached. Obviously thats not what I want. ffmpeg should always consume data if minimum 1 frame is cached in the Readable and if it has finished processing the frame before. And the Readable should produce more frames as long highWaterMark isn't reached or the last frame has been reached. So ideally the Readable and the Writeable are busy all the time.

    &#xA;

    I found another way to improve the speed. If I add a timeout in the _read() method of the Readable after let's say every tenth frame for 100 ms. Then the ffmpeg-Writable will use this timeout to write some frames to ffmpeg.

    &#xA;

    It seems like frames aren't passed to ffmpeg during frame creation because some node.js main thread is busy ?

    &#xA;

    The fastest result I have if I increase highWaterMark above the amount of frames - which doesn't work for longer videos as this would make the AWS Lambda RAM explode. And this makes the whole streaming idea useless. Using timeouts always gives me stomach pain. Also depending on the execution on different environments a good fitting timeout might differ. Any ideas ?

    &#xA;

    FrameCreationStream

    &#xA;

    import canvas from &#x27;canvas&#x27;;&#xA;import {Readable} from &#x27;stream&#x27;;&#xA;import {IMAGE_STREAM_BUFFER_SIZE, PerformanceUtil, RenderingLibraryError, VideoRendererInput} from &#x27;vm-rendering-backend-commons&#x27;;&#xA;import {AnimationAssets, BufferType, DrawingService, FullAnimationData} from &#x27;vm-rendering-library&#x27;;&#xA;&#xA;/**&#xA; * This is a proper back pressure compatible implementation of readable for a having a stream to read single frames from.&#xA; * Whenever read() is called a new frame is created and added to the stream.&#xA; * read() will be called internally until options.highWaterMark has been reached.&#xA; * then calling read will be paused until one frame is read from the stream.&#xA; */&#xA;export class FrameCreationStream extends Readable {&#xA;&#xA;    drawingService: DrawingService;&#xA;    endFrameIndex: number;&#xA;    currentFrameIndex: number = 0;&#xA;    startFrameIndex: number;&#xA;    frameTimer: [number, number];&#xA;    readTimer: [number, number];&#xA;    fullAnimationData: FullAnimationData;&#xA;&#xA;    constructor(animationAssets: AnimationAssets, fullAnimationData: FullAnimationData, videoRenderingInput: VideoRendererInput, frameTimer: [number, number]) {&#xA;        super({highWaterMark: IMAGE_STREAM_BUFFER_SIZE, objectMode: true});&#xA;&#xA;        this.frameTimer = frameTimer;&#xA;        this.readTimer = PerformanceUtil.startTimer();&#xA;&#xA;        this.fullAnimationData = fullAnimationData;&#xA;&#xA;        this.startFrameIndex = Math.floor(videoRenderingInput.startFrameId);&#xA;        this.currentFrameIndex = this.startFrameIndex;&#xA;        this.endFrameIndex = Math.floor(videoRenderingInput.endFrameId);&#xA;&#xA;        this.drawingService = new DrawingService(animationAssets, fullAnimationData, videoRenderingInput, canvas);&#xA;        console.time("read");&#xA;    }&#xA;&#xA;    /**&#xA;     * this method is only overwritten for debugging&#xA;     * @param size&#xA;     */&#xA;    read(size?: number): string | Buffer {&#xA;&#xA;        console.log("read("&#x2B;size&#x2B;")");&#xA;        const buffer = super.read(size);&#xA;        console.log(buffer);&#xA;        console.log(buffer?.length);&#xA;        if(buffer) {&#xA;            console.timeLog("read");&#xA;        }&#xA;        return buffer;&#xA;    }&#xA;&#xA;    // _read() will be called when the stream wants to pull more data in.&#xA;    // _read() will be called again after each call to this.push(dataChunk) once the stream is ready to accept more data. https://nodejs.org/api/stream.html#readable_readsize&#xA;    // this way it is ensured, that even though this.createImageBuffer() is async, only one frame is created at a time and the order is kept&#xA;    _read(): void {&#xA;        // as frame numbers are consecutive and unique, we have to draw each frame number (also the first and the last one)&#xA;        if (this.currentFrameIndex &lt;= this.endFrameIndex) {&#xA;            PerformanceUtil.logTimer(this.readTimer, &#x27;WAIT   -> READ\t&#x27;);&#xA;            this.createImageBuffer()&#xA;                 .then(buffer => this.optionalTimeout(buffer))&#xA;                // push means adding a buffered raw frame to the stream&#xA;                .then((buffer: Buffer) => {&#xA;                    this.readTimer = PerformanceUtil.startTimer();&#xA;                    // the following two frame numbers start with 1 as first value&#xA;                    const processedFrameNumberOfScene = 1 &#x2B; this.currentFrameIndex - this.startFrameIndex;&#xA;                    const totalFrameNumberOfScene = 1 &#x2B; this.endFrameIndex - this.startFrameIndex;&#xA;                    // the overall frameId or frameIndex starts with frameId 0&#xA;                    const processedFrameIndex = this.currentFrameIndex;&#xA;                    this.currentFrameIndex&#x2B;&#x2B;;&#xA;                    this.push(buffer); // nothing besides logging should happen after calling this.push(buffer)&#xA;                    console.log(processedFrameNumberOfScene &#x2B; &#x27; of &#x27; &#x2B; totalFrameNumberOfScene &#x2B; &#x27; processed - full video frameId: &#x27; &#x2B; processedFrameIndex &#x2B; &#x27; - buffered frames: &#x27; &#x2B; this.readableLength);&#xA;                })&#xA;                .catch(err => {&#xA;                    // errors will be finally handled, when subscribing to frameCreation stream in ffmpeg service&#xA;                    // this log is just generated for tracing errors and if for some reason the handling in ffmpeg service doesn&#x27;t work&#xA;                    console.log("createImageBuffer: ", err);&#xA;                    this.emit("error", err);&#xA;                });&#xA;        } else {&#xA;            // push(null) makes clear that this stream has ended&#xA;            this.push(null);&#xA;            PerformanceUtil.logTimer(this.frameTimer, &#x27;FRAME_STREAM&#x27;);&#xA;        }&#xA;    }&#xA;&#xA;    private optionalTimeout(buffer: Buffer): Promise<buffer> {&#xA;        if(this.currentFrameIndex % 10 === 0) {&#xA;            return new Promise(resolve => setTimeout(() => resolve(buffer), 140));&#xA;        }&#xA;        return Promise.resolve(buffer);&#xA;    }&#xA;&#xA;    // prevent memory leaks - without this lambda memory will increase with every call&#xA;    _destroy(): void {&#xA;        this.drawingService.destroyStage();&#xA;    }&#xA;&#xA;    /**&#xA;     * This creates a raw pixel buffer that contains a single frame of the video drawn by the rendering library&#xA;     *&#xA;     */&#xA;    public async createImageBuffer(): Promise<buffer> {&#xA;&#xA;        const drawTimer = PerformanceUtil.startTimer();&#xA;        try {&#xA;            await this.drawingService.drawForFrame(this.currentFrameIndex);&#xA;        } catch (err: any) {&#xA;            throw new RenderingLibraryError(err);&#xA;        }&#xA;&#xA;        PerformanceUtil.logTimer(drawTimer, &#x27;DRAW   -> FRAME\t&#x27;);&#xA;&#xA;        const bufferTimer = PerformanceUtil.startTimer();&#xA;        // Creates a raw pixel buffer, containing simple binary data&#xA;        // the exact same information (BGRA/screen ratio) has to be provided to ffmpeg, because ffmpeg cannot detect format for raw input&#xA;        const buffer = await this.drawingService.toBuffer(BufferType.RAW);&#xA;        PerformanceUtil.logTimer(bufferTimer, &#x27;CANVAS -> BUFFER&#x27;);&#xA;&#xA;        return buffer;&#xA;    }&#xA;}&#xA;</buffer></buffer>

    &#xA;

    FfmpegService

    &#xA;

    import {ChildProcess, execFile} from &#x27;child_process&#x27;;&#xA;import {Readable} from &#x27;stream&#x27;;&#xA;import {FPS, StageSize} from &#x27;vm-rendering-library&#x27;;&#xA;import {&#xA;    FfmpegError,&#xA;    LOCAL_MERGE_VIDEOS_TEXT_FILE, LOCAL_SOUND_FILE_PATH,&#xA;    LOCAL_VIDEO_FILE_PATH,&#xA;    LOCAL_VIDEO_SOUNDLESS_MERGE_FILE_PATH&#xA;} from "vm-rendering-backend-commons";&#xA;&#xA;/**&#xA; * This class bundles all ffmpeg usages for rendering one scene.&#xA; * FFmpeg is a console program which can transcode nearly all types of sounds, images and videos from one to another.&#xA; */&#xA;export class FfmpegService {&#xA;&#xA;    ffmpegPath: string = null;&#xA;&#xA;&#xA;    constructor(ffmpegPath: string) {&#xA;        this.ffmpegPath = ffmpegPath;&#xA;    }&#xA;&#xA;    /**&#xA;     * Convert a stream of raw images into an .mp4 video using the command line program ffmpeg.&#xA;     *&#xA;     * @param inputStream an input stream containing images in raw format BGRA&#xA;     * @param stageSize the size of a single frame in pixels (minimum is 2*2)&#xA;     * @param outputPath the filepath to write the resulting video to&#xA;     */&#xA;    public imageToVideo(inputStream: Readable, stageSize: StageSize, outputPath: string): Promise<void> {&#xA;        const args: string[] = [&#xA;            &#x27;-f&#x27;,&#xA;            &#x27;rawvideo&#x27;,&#xA;            &#x27;-r&#x27;,&#xA;            `${FPS}`,&#xA;            &#x27;-pix_fmt&#x27;,&#xA;            &#x27;bgra&#x27;,&#xA;            &#x27;-s&#x27;,&#xA;            `${stageSize.width}x${stageSize.height}`,&#xA;            &#x27;-i&#x27;,&#xA;            // input "-" means input will be passed via pipe (streamed)&#xA;            &#x27;-&#x27;,&#xA;            // codec that also QuickTime player can understand&#xA;            &#x27;-vcodec&#x27;,&#xA;            &#x27;libx264&#x27;,&#xA;            &#x27;-pix_fmt&#x27;,&#xA;            &#x27;yuv420p&#x27;,&#xA;            /*&#xA;                * "-movflags faststart":&#xA;                * metadata at beginning of file&#xA;                * needs more RAM&#xA;                * file will be broken, if not finished properly&#xA;                * higher application compatibility&#xA;                * better for browser streaming&#xA;            */&#xA;            &#x27;-movflags&#x27;,&#xA;            &#x27;faststart&#x27;,&#xA;            // "-preset ultrafast", //use this to speed up compression, but quality/compression ratio gets worse&#xA;            // don&#x27;t overwrite an existing file here,&#xA;            // but delete file in the beginning of execution index.ts&#xA;            // (this is better for local testing believe me)&#xA;            outputPath&#xA;        ];&#xA;&#xA;        return this.execFfmpegPromise(args, inputStream);&#xA;    }&#xA;&#xA;    private execFfmpegPromise(args: string[], inputStream?: Readable): Promise<void> {&#xA;        const ffmpegServiceSelf = this;&#xA;        return new Promise(function (resolve, reject) {&#xA;            const executionProcess: ChildProcess = execFile(ffmpegServiceSelf.ffmpegPath, args, (err) => {&#xA;                if (err) {&#xA;                    reject(new FfmpegError(err));&#xA;                } else {&#xA;                    console.log(&#x27;ffmpeg finished&#x27;);&#xA;                    resolve();&#xA;                }&#xA;            });&#xA;            if (inputStream) {&#xA;                // it&#x27;s important to listen on errors of input stream before piping it into the write stream&#xA;                // if we don&#x27;t do this here, we get an unhandled promise exception for every issue in the input stream&#xA;                inputStream.on("error", err => {&#xA;                    reject(err);&#xA;                });&#xA;                // don&#x27;t reject promise here as the error will also be thrown inside execFile and will contain more debugging info&#xA;                // this log is just generated for tracing errors and if for some reason the handling in execFile doesn&#x27;t work&#xA;                inputStream.pipe(executionProcess.stdin).on("error", err => console.log("pipe stream: " , err));&#xA;            }&#xA;        });&#xA;    }&#xA;}&#xA;</void></void>

    &#xA;

  • FFmpeg stdout emits more frames than it should

    29 décembre 2022, par distante

    I am running this command to get two images per second from an rtsp stream :

    &#xA;

    const ffmpeg = spawn(this.ffmpeg, [&#xA;      // Set the frame rate of the input video to 2 frames per second&#xA;      &#x27;-r&#x27;,&#xA;      &#x27;2&#x27;,&#xA;      // Specify that the RTSP stream should use TCP as the transport protocol&#xA;      &#x27;-rtsp_transport&#x27;,&#xA;      &#x27;tcp&#x27;,&#xA;      // Set the input source to the RTSP stream specified by the `rtspUrl` variable&#xA;      &#x27;-i&#x27;,&#xA;      rtspUrl,&#xA;      // Set the video filter to only output two frames per second (final video)&#xA;      &#x27;-vf&#x27;,&#xA;      &#x27;fps=2&#x27;,&#xA;      // Set the output format to "image2pipe," which specifies that the output should be written to stdout as a series of images in a pipe&#xA;      &#x27;-f&#x27;,&#xA;      &#x27;image2pipe&#x27;,&#xA;      // Overwrite any existing output file without prompting for confirmation&#xA;      &#x27;-y&#x27;,&#xA;      // Set the output destination to stdout&#xA;      &#x27;-&#x27;,&#xA;    ]);&#xA;&#xA;

    &#xA;

    I am subscribing to the stdout and saving each emit into a file (just for testing, I need to process the data later)

    &#xA;

        let i = 0;&#xA;    from(ffmpeg.stdout)&#xA;      .pipe(&#xA;        concatMap((data) => {&#xA;          i&#x2B;&#x2B;&#xA;          return writeFile(`file_${i}`, data).then(() => i);&#xA;        }),&#xA;      )&#xA;      .subscribe((i) => {&#xA;        this.imageLogger.log(`file_${i} saved`);&#xA;      });&#xA;

    &#xA;

    The thing is, I am getting a lot more than 2 images per second :

    &#xA;

    i       | [Nest] 431  - 12/28/2022, 1:16:09 PM     LOG [Image Logger] stderr: ffmpeg version 5.0.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2022 the FFmpeg developers&#xA;api       |   built with gcc 8 (Debian 8.3.0-6)&#xA;api       |   configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg&#xA;api       |   libavutil      57. 17.100 / 57. 17.100&#xA;api       |   libavcodec     59. 18.100 / 59. 18.100&#xA;api       |   libavformat    59. 16.100 / 59. 16.100&#xA;api       |   libavdevice    59.  4.100 / 59.  4.100&#xA;api       |   libavfilter     8. 24.100 /  8. 24.100&#xA;api       |   libswscale      6.  4.100 /  6.  4.100&#xA;api       |   libswresample   4.  3.100 /  4.  3.100&#xA;api       |   libpostproc    56.  3.100 / 56.  3.100&#xA;api       |   configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg&#xA;api       |   libavutil      57. 17.100 / 57. 17.100&#xA;api       |   libavcodec     59. 18.100 / 59. 18.100&#xA;api       |   libavformat    59. 16.100 / 59. 16.100&#xA;api       |   libavdevice    59.  4.100 / 59.  4.100&#xA;api       |   libavfilter     8. 24.100 /  8. 24.100&#xA;api       |   libswscale      6.  4.100 /  6.  4.100&#xA;api       |   libswresample   4.  3.100 /  4.  3.100&#xA;api       |   libpostproc    56.  3.100 / 56.  3.100&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] stderr: Guessed Channel Layout for Input Stream #0.1 : mono&#xA;api       | Input #0, rtsp, from &#x27;rtsp://user:password@192.68.45.54:554/stream2&#x27;:&#xA;api       |   Metadata:&#xA;api       |     title           : Session streamed by "TP-LINK RTSP Server"&#xA;api       |     comment         : stream2&#xA;api       |   Duration: N/A, start: 0.000000, bitrate: N/A&#xA;api       |   Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 640x360, 15 fps, 28.58 tbr, 90k tbn&#xA;api       |   Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s&#xA;api       |&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] stderr: Stream mapping:&#xA;api       |   Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))&#xA;api       | Press [q] to stop, [?] for help&#xA;api       |&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] stderr: Output #0, image2pipe, to &#x27;pipe:&#x27;:&#xA;api       |   Metadata:&#xA;api       |     title           : Session streamed by "TP-LINK RTSP Server"&#xA;api       |     comment         : stream2&#xA;api       |     encoder         : Lavf59.16.100&#xA;api       |   Stream #0:0: Video: mjpeg, yuvj420p(pc, bt709, progressive), 640x360, q=2-31, 200 kb/s, 2 fps, 2 tbn&#xA;api       |&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] stderr:     Metadata:&#xA;api       |       encoder         : Lavc59.18.100 mjpeg&#xA;api       |     Side data:&#xA;api       |       cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] stderr: frame=    1 fps=0.0 q=5.0 size=      23kB time=00:00:00.50 bitrate= 383.9kbits/s speed=59.4x&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_1.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_2.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_3.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_4.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_5.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_6.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_7.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_8.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_9.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_10.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_11.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_12.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_13.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_14.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_15.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_16.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_17.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_18.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_19.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_20.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_21.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_22.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_23.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_24.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_25.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_26.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] stderr: frame=   27 fps=0.0 q=16.0 size=     559kB time=00:00:13.50 bitrate= 339.3kbits/s speed=25.3x&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_27.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_28.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_29.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_30.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_31.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:12 PM     LOG [Image Logger] file_32.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_33.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] stderr: frame=   34 fps= 33 q=16.6 size=     632kB time=00:00:17.00 bitrate= 304.6kbits/s speed=16.3x&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_34.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_35.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_36.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_37.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_38.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_39.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_40.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_41.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] stderr: frame=   41 fps= 26 q=16.5 size=     705kB time=00:00:20.50 bitrate= 281.7kbits/s speed=13.2x&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_42.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_43.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_44.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_45.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:13 PM     LOG [Image Logger] file_46.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_47.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_48.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] stderr: frame=   48 fps= 23 q=16.4 size=     779kB time=00:00:24.00 bitrate= 265.9kbits/s speed=11.6x&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_49.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_50.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_51.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_52.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_53.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_54.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_55.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] stderr: frame=   56 fps= 22 q=16.1 size=     865kB time=00:00:28.00 bitrate= 253.0kbits/s speed=10.9x&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_56.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_57.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_58.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_59.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:14 PM     LOG [Image Logger] file_60.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_61.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_62.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_63.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] stderr: frame=   63 fps= 20 q=15.5 size=     939kB time=00:00:31.50 bitrate= 244.3kbits/s speed=10.2x&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_64.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_65.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_66.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_67.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_68.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_69.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_70.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] stderr: frame=   70 fps= 19 q=15.4 size=    1017kB time=00:00:35.00 bitrate= 238.0kbits/s speed= 9.7x&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_71.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_72.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_73.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_74.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:15 PM     LOG [Image Logger] file_75.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:16 PM     LOG [Image Logger] file_76.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:16 PM     LOG [Image Logger] file_77.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:16 PM     LOG [Image Logger] stderr: frame=   78 fps= 19 q=15.1 size=    1106kB time=00:00:39.00 bitrate= 232.4kbits/s speed=9.48x&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:16 PM     LOG [Image Logger] file_78.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:16 PM     LOG [Image Logger] file_79.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:16 PM     LOG [Image Logger] file_80.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:16 PM     LOG [Image Logger] file_81.jpg saved&#xA;api       | [Nest] 431  - 12/28/2022, 1:16:16 PM     LOG [Image Logger] file_82.jpg saved&#xA;

    &#xA;

    Am I missing some part ? why I do not only get 2 stdout events pro second ?

    &#xA;

    Edit :

    &#xA;

    ffmpeg version 5.0.1-static&#xA;node : 18.12.1

    &#xA;

    Edit 2 :

    &#xA;

    When I run this command on the terminal :

    &#xA;

    ffmpeg -r 2 -rtsp_transport tcp -i "rtsp://user:password@192.68.45.54:554/stream2" -vf fps=2 -timecode 00:00:00:00 test.mp4&#xA;

    &#xA;

    The generated video has a frame rate of 2 but it looks like it is in slow motion. Since the source video has also a timer, I see how it takes something like 12 "frames" to go from one second to another.

    &#xA;

    This is the output :

    &#xA;

    fmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers&#xA;  built with Apple clang version 14.0.0 (clang-1400.0.29.202)&#xA;  configuration: --prefix=/usr/local/Cellar/ffmpeg/5.1.2_1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox&#xA;  libavutil      57. 28.100 / 57. 28.100&#xA;  libavcodec     59. 37.100 / 59. 37.100&#xA;  libavformat    59. 27.100 / 59. 27.100&#xA;  libavdevice    59.  7.100 / 59.  7.100&#xA;  libavfilter     8. 44.100 /  8. 44.100&#xA;  libswscale      6.  7.100 /  6.  7.100&#xA;  libswresample   4.  7.100 /  4.  7.100&#xA;  libpostproc    56.  6.100 / 56.  6.100&#xA;Input #0, rtsp, from &#x27;rtsp://user:password@192.68.45.54:554/stream2&#x27;:&#xA;  Metadata:&#xA;    title           : Session streamed by "TP-LINK RTSP Server"&#xA;    comment         : stream2&#xA;  Duration: N/A, start: 0.000000, bitrate: N/A&#xA;  Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 640x360, 15 fps, 28.58 tbr, 90k tbn&#xA;  Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s&#xA;File &#x27;test.mp4&#x27; already exists. Overwrite? [y/N] y&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))&#xA;  Stream #0:1 -> #0:1 (pcm_alaw (native) -> aac (native))&#xA;Press [q] to stop, [?] for help&#xA;[aac @ 0x7fa79fb061c0] Too many bits 8832.000000 > 6144 per frame requested, clamping to max&#xA;[libx264 @ 0x7fa79fb04e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2&#xA;[libx264 @ 0x7fa79fb04e00] profile High, level 2.2, 4:2:0, 8-bit&#xA;[libx264 @ 0x7fa79fb04e00] 264 - core 164 r3095 baee400 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=11 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=2 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00&#xA;[mp4 @ 0x7fa78f104780] Using non-standard frame rate 2/1&#xA;    Last message repeated 1 times&#xA;Output #0, mp4, to &#x27;test.mp4&#x27;:&#xA;  Metadata:&#xA;    title           : Session streamed by "TP-LINK RTSP Server"&#xA;    comment         : stream2&#xA;    timecode        : 00:00:00:00&#xA;    encoder         : Lavf59.27.100&#xA;  Stream #0:0: Video: h264 (avc1 / 0x31637661), yuvj420p(pc, bt709, progressive), 640x360, q=2-31, 2 fps, 16384 tbn&#xA;    Metadata:&#xA;      encoder         : Lavc59.37.100 libx264&#xA;    Side data:&#xA;      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A&#xA;  Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 48 kb/s&#xA;    Metadata:&#xA;      encoder         : Lavc59.37.100 aac&#xA;frame=  186 fps= 28 q=20.0 size=     256kB time=00:01:04.00 bitrate=  32.8kbits/s speed=9.58x&#xA;&#xA;[q] command received. Exiting.&#xA;&#xA;frame=  190 fps= 27 q=-1.0 Lsize=     749kB time=00:01:33.50 bitrate=  65.6kbits/s speed=13.2x&#xA;video:708kB audio:35kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.836704%&#xA;[libx264 @ 0x7fa79fb04e00] frame I:1     Avg QP:10.13  size: 45352&#xA;[libx264 @ 0x7fa79fb04e00] frame P:74    Avg QP:12.27  size:  7161&#xA;[libx264 @ 0x7fa79fb04e00] frame B:115   Avg QP:22.28  size:  1294&#xA;[libx264 @ 0x7fa79fb04e00] consecutive B-frames: 14.7%  9.5% 12.6% 63.2%&#xA;[libx264 @ 0x7fa79fb04e00] mb I  I16..4: 15.0% 14.0% 71.0%&#xA;[libx264 @ 0x7fa79fb04e00] mb P  I16..4:  0.6%  1.5%  2.4%  P16..4: 20.4%  4.9%  5.9%  0.0%  0.0%    skip:64.3%&#xA;[libx264 @ 0x7fa79fb04e00] mb B  I16..4:  0.0%  0.1%  0.3%  B16..8: 15.9%  2.4%  1.5%  direct: 0.9%  skip:78.9%  L0:45.5% L1:48.6% BI: 5.9%&#xA;[libx264 @ 0x7fa79fb04e00] 8x8 transform intra:27.4% inter:64.7%&#xA;[libx264 @ 0x7fa79fb04e00] coded y,uvDC,uvAC intra: 81.7% 60.2% 46.5% inter: 9.4% 4.2% 1.5%&#xA;[libx264 @ 0x7fa79fb04e00] i16 v,h,dc,p: 44% 10% 19% 27%&#xA;[libx264 @ 0x7fa79fb04e00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 52% 14% 13%  3%  2%  3%  3%  5%  4%&#xA;[libx264 @ 0x7fa79fb04e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 35% 18% 13%  6%  5%  6%  5%  6%  7%&#xA;[libx264 @ 0x7fa79fb04e00] i8c dc,h,v,p: 45% 18% 27%  9%&#xA;[libx264 @ 0x7fa79fb04e00] Weighted P-Frames: Y:0.0% UV:0.0%&#xA;[libx264 @ 0x7fa79fb04e00] ref P L0: 78.9%  7.6% 11.4%  2.1%&#xA;[libx264 @ 0x7fa79fb04e00] ref B L0: 90.8%  8.0%  1.2%&#xA;[libx264 @ 0x7fa79fb04e00] ref B L1: 97.0%  3.0%&#xA;[libx264 @ 0x7fa79fb04e00] kb/s:60.98&#xA;[aac @ 0x7fa79fb061c0] Qavg: 64944.246&#xA;

    &#xA;