Recherche avancée

Médias (1)

Mot : - Tags -/blender

Autres articles (72)

Sur d’autres sites (9834)

  • FFmpeg streaming stuck few minutes after start [closed]

    19 février, par josue ramirez

    Sorry for my english ! :D

    


    I'm trying to make a live video stream from my webcam with ffmpeg using Node.

    


    I get the images or frames from ffmpeg via pipe1 on the stdout event and send them via a socket-io client to my angular app to play the stream.

    


    So far the stream starts fine and my angular app can play it fine, but after a certain time (8 minutes or so) ffmpeg stops sending data and the stream in my angular app stops and if I want to start the webcam again it's not possible anymore because it's apparently occupied by another process. I've been trying to figure out what's going on and what I've noticed is that the ffmpeg process just stops and the process is no longer visible with the top command (ubuntu), but the child process in node still shows a ffmpeg process as if it were a zombie process.

    


    I've tried running ffmpeg from the terminal to save an mp4 file with the stream and in that case there is no problem, the recording doesn't stop even using pipe1. Only when I run ffmpeg from my Node app, the error occurs.

    


    Does anyone have any idea what could be going on ?

    


    This command is the one that is executed to send the data through pipe1 both from node and from the terminal but it only stops in Node

    


    ffmpeg -f v4l2 -input_format mjpeg -video_size 800x600 -i /dev/video0 -q:v 4 -f image2pipe pipe1


    


    The same thing happens when saving an mp4 video only in Node it fails

    


    ffmpeg -f v4l2 -input_format mjpeg -video_size 800x600 -i /dev/video0 -q:v 4 video.mp4


    


    This is my function that starts the streaming

    


    export const startCamera = () => {
    logger.info('Starting camera ', cameraName);

    const inputFormat = process.platform === 'win32' ? 'dshow' : 'v4l2';

    const ffmpegArgs = [
        '-f', inputFormat, // Formato de entrada según la plataforma
    ];

    if (process.platform === 'linux') {
        ffmpegArgs.push(
            '-input_format', 'mjpeg',  // Especificar el formato antes de video_size
            '-video_size', '800x600',  // Tamaño de la imagen
        );
    }
    
    ffmpegArgs.push(
        '-i', cameraName,    // Dispositivo de entrada
        '-vf', 'fps=15',     // Fotogramas por segundo
        '-q:v', '10',        // Calidad de video
        '-f', 'image2pipe',  // Formato de salida
        'pipe:1'             // Salida por stdout
    );

    try {
        logger.info('FFmpeg command: ffmpeg', ffmpegArgs.join(' '));
        ffmpeg = spawn('ffmpeg', ffmpegArgs);
        let cameraOpen = false;
        // Enviar los datos del fotograma a través del WebSocket
        ffmpeg.stdout.on('data', (chunk) => {
            logger.debug(`Sending chunk of ${chunk.length} bytes`);
            if (!cameraOpen) {
                cameraOpen = true;
                serialConnection.connect();
                logger.info('Camera started!!');
            }

            if (streamWS.isActive()) {
                streamWS.send(chunk);
            }
        });
        // Manejo de errores
        ffmpeg.stderr.on('error', (data) => {
            logger.error('FFmpeg Error:', data.toString());
        });

        ffmpeg.on('close', async () => {
            logger.info('Camera closed....', cameraName);
            if (!cameraOpen) {
                await commandWS.send(
                    {
                        command: COMMANDS.START_STREAM,
                        isError: true,
                        response: `Error al intentar iniciar la camara ${cameraName}, verificar que la camara se encuentre bien conectada.`,
                    },
                    COMMANDS_EVENTS.ROBOT_RESPONSE
                );
            }
            cameraOpen = false;
            await serialConnection.close();
            stopCamera();
            await streamWS.disconnectWS();
        });
    } catch (e) {
        logger.error('Error tryng to start the camera...', e);
    }
};


    


  • XABE : One or more errors occurred (FFmpeg)

    22 mars 2021, par A Farmanbar

    I am trying to build video from images by below piece of code :

    


    FFmpeg.SetExecutablesPath(dir);
FFmpeg.Conversions.New()
   .BuildVideoFromImages(files)
   .SetInputFrameRate(_video.Fps)
   .SetFrameRate(_video.Fps)
   .SetPixelFormat(PixelFormat.bgr24)
   .SetOutput(dir + "\\output.mp4").Start().Wait();


    


    but I get below error

    


    System.AggregateException: One or more errors occurred. (ffmpeg version n4.3.2-160-gfbb9368226 Copyright (c) 2000-2021 the FFmpeg developers&#xA;  built with gcc 9.3-win32 (GCC) 20200320&#xA;  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libtwolame --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp&#xA;  libavutil      56. 51.100 / 56. 51.100&#xA;  libavcodec     58. 91.100 / 58. 91.100&#xA;  libavformat    58. 45.100 / 58. 45.100&#xA;  libavdevice    58. 10.100 / 58. 10.100&#xA;  libavfilter     7. 85.100 /  7. 85.100&#xA;  libswscale      5.  7.100 /  5.  7.100&#xA;  libswresample   3.  7.100 /  3.  7.100&#xA;  libpostproc    55.  7.100 / 55.  7.100&#xA;[mjpeg @ 0000018b7067a780] bits 217 is invalid&#xA;[mjpeg @ 0000018b7067a780] bits 253 is invalid&#xA;[mjpeg @ 0000018b7067a780] bits 159 is invalid&#xA;[mjpeg @ 0000018b7067a780] bits 234 is invalid&#xA;[mjpeg @ 0000018b7067a780] unable to decode APP fields: Invalid data found when processing input&#xA;    Last message repeated 2 times&#xA;[mjpeg @ 0000018b7067a780] Found EOI before any SOF, ignoring&#xA;[mjpeg @ 0000018b7067a780] unable to decode APP fields: Invalid data found when processing input&#xA;    Last message repeated 1 times&#xA;[mjpeg @ 0000018b7067a780] No JPEG data found in image&#xA;[mjpeg @ 0000018b7067a780] bits 95 is invalid&#xA;[mjpeg @ 0000018b7067a780] Found EOI before any SOF, ignoring&#xA;[mjpeg @ 0000018b7067a780] bits 133 is invalid&#xA;[mjpeg @ 0000018b7067a780] bits 31 is invalid&#xA;[mjpeg @ 0000018b7067a780] dqt: invalid precision&#xA;[mjpeg @ 0000018b7067a780] unable to decode APP fields: Invalid data found when processing input&#xA;    Last message repeated 8 times&#xA;[mjpeg @ 0000018b7067a780] No JPEG data found in image&#xA;[mjpeg @ 0000018b7067a780] Found EOI before any SOF, ignoring&#xA;[mjpeg @ 0000018b7067a780] bits 105 is invalid&#xA;[image2 @ 0000018b72294f80] decoding for stream 0 failed&#xA;[image2 @ 0000018b72294f80] Could not find codec parameters for stream 0 (Video: mjpeg (Progressive), none(bt470bg/unknown/unknown), lossless): unspecified size&#xA;Consider increasing the value for the &#x27;analyzeduration&#x27; and &#x27;probesize&#x27; options&#xA;Input #0, image2, from &#x27;C:\Users\a\AppData\Local\Temp\79b5fa99-f5a5-4788-b126-ef1549eb2086\img_%03d.jpg&#x27;:&#xA;  Duration: 00:00:00.38, start: 0.000000, bitrate: N/A&#xA;    Stream #0:0: Video: mjpeg (Progressive), none(bt470bg/unknown/unknown), lossless, 29 fps, 29 tbr, 29 tbn, 29 tbc&#xA;File &#x27;C:\Users\a\source\repos\ConsoleApp1\ConsoleApp1\bin\Debug\net5.0\output.mp4&#x27; already exists. Exiting.)&#xA; ---> Xabe.FFmpeg.Exceptions.ConversionException: ffmpeg version n4.3.2-160-gfbb9368226 Copyright (c) 2000-2021 the FFmpeg developers&#xA;  built with gcc 9.3-win32 (GCC) 20200320&#xA;  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enable-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libtwolame --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp&#xA;  libavutil      56. 51.100 / 56. 51.100&#xA;  libavcodec     58. 91.100 / 58. 91.100&#xA;  libavformat    58. 45.100 / 58. 45.100&#xA;  libavdevice    58. 10.100 / 58. 10.100&#xA;  libavfilter     7. 85.100 /  7. 85.100&#xA;  libswscale      5.  7.100 /  5.  7.100&#xA;  libswresample   3.  7.100 /  3.  7.100&#xA;  libpostproc    55.  7.100 / 55.  7.100&#xA;[mjpeg @ 0000018b7067a780] bits 217 is invalid&#xA;[mjpeg @ 0000018b7067a780] bits 253 is invalid&#xA;[mjpeg @ 0000018b7067a780] bits 159 is invalid&#xA;[mjpeg @ 0000018b7067a780] bits 234 is invalid&#xA;[mjpeg @ 0000018b7067a780] unable to decode APP fields: Invalid data found when processing input&#xA;    Last message repeated 2 times&#xA;[mjpeg @ 0000018b7067a780] Found EOI before any SOF, ignoring&#xA;[mjpeg @ 0000018b7067a780] unable to decode APP fields: Invalid data found when processing input&#xA;    Last message repeated 1 times&#xA;[mjpeg @ 0000018b7067a780] No JPEG data found in image&#xA;[mjpeg @ 0000018b7067a780] bits 95 is invalid&#xA;[mjpeg @ 0000018b7067a780] Found EOI before any SOF, ignoring&#xA;[mjpeg @ 0000018b7067a780] bits 133 is invalid&#xA;[mjpeg @ 0000018b7067a780] bits 31 is invalid&#xA;[mjpeg @ 0000018b7067a780] dqt: invalid precision&#xA;[mjpeg @ 0000018b7067a780] unable to decode APP fields: Invalid data found when processing input&#xA;    Last message repeated 8 times&#xA;[mjpeg @ 0000018b7067a780] No JPEG data found in image&#xA;[mjpeg @ 0000018b7067a780] Found EOI before any SOF, ignoring&#xA;[mjpeg @ 0000018b7067a780] bits 105 is invalid&#xA;[image2 @ 0000018b72294f80] decoding for stream 0 failed&#xA;[image2 @ 0000018b72294f80] Could not find codec parameters for stream 0 (Video: mjpeg (Progressive), none(bt470bg/unknown/unknown), lossless): unspecified size&#xA;Consider increasing the value for the &#x27;analyzeduration&#x27; and &#x27;probesize&#x27; options&#xA;Input #0, image2, from &#x27;C:\Users\a\AppData\Local\Temp\79b5fa99-f5a5-4788-b126-ef1549eb2086\img_%03d.jpg&#x27;:&#xA;  Duration: 00:00:00.38, start: 0.000000, bitrate: N/A&#xA;    Stream #0:0: Video: mjpeg (Progressive), none(bt470bg/unknown/unknown), lossless, 29 fps, 29 tbr, 29 tbn, 29 tbc&#xA;File &#x27;C:\Users\a\source\repos\ConsoleApp1\ConsoleApp1\bin\Debug\net5.0\output.mp4&#x27; already exists. Exiting.&#xA;   at Xabe.FFmpeg.FFmpegWrapper.&lt;>c__DisplayClass11_0.<runprocess>b__0()&#xA;   at System.Threading.Tasks.Task`1.InnerInvoke()&#xA;   at System.Threading.Tasks.Task.&lt;>c.&lt;.cctor>b__277_0(Object obj)&#xA;   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)&#xA;--- End of stack trace from previous location ---&#xA;   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)&#xA;   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task&amp; currentTaskSlot, Thread threadPoolThread)&#xA;--- End of stack trace from previous location ---&#xA;   at Xabe.FFmpeg.Conversion.Start(String parameters, CancellationToken cancellationToken)&#xA;   --- End of inner exception stack trace ---&#xA;   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)&#xA;   at System.Threading.Tasks.Task.Wait()&#xA;   at ConsoleApp1.Program.Main(String[] args) in C:\Users\a\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:line 79&#xA;</runprocess>

    &#xA;

  • Error importing VideoFileClip from moviepy : AttributeError : 'PermissionError' object has no attribute 'message'

    11 mars 2017, par Tahlil

    I’m using jupyter notebook. I have also tried from anaconda console as well.

    Tried importing with both the ways shown below

    from moviepy.editor import VideoFileClip

    from moviepy.video.io.VideoFileClip import VideoFileClip

    Both of them gave me same error. Full trace is below

    AttributeError                            Traceback (most recent call last)
    in <module>()
         6 import glob
         7 import math
    ----> 8 from moviepy.editor import VideoFileClip
         9 from moviepy.video.io.VideoFileClip import VideoFileClip

    C:\Program Files\Anaconda3\lib\site-packages\moviepy\editor.py in <module>()
        20 # Clips
        21
    ---> 22 from .video.io.VideoFileClip import VideoFileClip
        23 from .video.io.ImageSequenceClip import ImageSequenceClip
        24 from .video.io.downloader import download_webfile

    C:\Program Files\Anaconda3\lib\site-packages\moviepy\video\io\VideoFileClip.py in <module>()
         1 import os
         2
    ----> 3 from moviepy.video.VideoClip import VideoClip
         4 from moviepy.audio.io.AudioFileClip import AudioFileClip
         5 from moviepy.Clip import Clip

    C:\Program Files\Anaconda3\lib\site-packages\moviepy\video\VideoClip.py in <module>()
        18
        19 import moviepy.audio.io as aio
    ---> 20 from .io.ffmpeg_writer import ffmpeg_write_image, ffmpeg_write_video
        21 from .io.ffmpeg_tools import ffmpeg_merge_video_audio
        22 from .io.gif_writers import (write_gif,

    C:\Program Files\Anaconda3\lib\site-packages\moviepy\video\io\ffmpeg_writer.py in <module>()
        13     DEVNULL = open(os.devnull, 'wb')
        14
    ---> 15 from moviepy.config import get_setting
        16 from moviepy.tools import verbose_print
        17

    C:\Program Files\Anaconda3\lib\site-packages\moviepy\config.py in <module>()
        49     success, err = try_cmd([FFMPEG_BINARY])
        50     if not success:
    ---> 51         raise IOError(err.message +
        52                  "The path specified for the ffmpeg binary might be wrong")
        53

    AttributeError: 'PermissionError' object has no attribute 'message'
    </module></module></module></module></module></module>

    Python version info

    Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.

    Running ffmpeg -version in a console gives me

    ffmpeg version N-83507-g8fa18e0 Copyright (c) 2000-2017 the FFmpeg developers
    built with gcc 5.4.0 (GCC)
    configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
    libavutil      55. 47.100 / 55. 47.100
    libavcodec     57. 80.100 / 57. 80.100
    libavformat    57. 66.102 / 57. 66.102
    libavdevice    57.  2.100 / 57.  2.100
    libavfilter     6. 73.100 /  6. 73.100
    libswscale      4.  3.101 /  4.  3.101
    libswresample   2.  4.100 /  2.  4.100
    libpostproc    54.  2.100 / 54.  2.100

    I’m running 64 bit version of Windows 10.

    I can’t find any solution anywhere and its driving me crazy ! Seems like its not finding the ffmpeg binary but I have put it in C :\ffmpeg\bin and added this to path environment variable. Followed the instruction from here.