Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • How to convert an MJPEG stream to YUV420p, then hardware encode to h264 on rpi4 using go2rtc and frigate ? [closed]

    13 juin, par Josh Pirihi

    I am putting together a dashcam/dvr/reversing camera system for my van. I am using some analogue HD reversing cameras and AHD to USB dongles along with a Raspberry Pi 4. The pi is running frigate in docker, it has a fresh Raspberry Pi OS installed. The AHD dongles show up straight away as /dev/video0 when plugged in.

    I am running into an issue getting the MJPEG stream from the dongle to be accepted by the hardware h264 encoder. I am able to feed the hardware encoder with the raw YUYV 4:2:2 stream, however due to bandwidth limitations this cuts the framerate intolerably low (720p 10fps, 1080p 5fps). Similarly, I am able to use the software encoder to convert the MJPEG stream at 30fps, however this uses 200% CPU per camera so it is no good for when I add more than one camera (at least 2 in total, maybe more).

    I have played around with frigate, and have reduced it back to just the go2rtc docker container to troubleshoot until I get it working.

    Here is the output from the go2rtc FFMPEG Devices (USB) tab:

    go2rtc FFMPEG Devices tab

    The basic go2rtc config gives me 10fps 720p using the hardware encoder. This ingests the raw stream I think:

    streams:
        grill:
          - "ffmpeg:device?video=0&video_size=1280x720#video=h264#hardware"
    

    Telling it to use MJPEG results in an error:

    streams:
        grill:
          - "ffmpeg:device?video=0&input_format=mjpeg&video_size=1280x720#video=h264#hardware"
    
    go2rtc-1  | 19:34:14.379 WRN [rtsp] error="streams: exec/rtsp\n[h264_v4l2m2m @ 0x7facadfb40] Encoder requires yuv420p pixel format.\n[vost#0:0/h264_v4l2m2m @ 0x7faf9aa3a0] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.\nError while filtering: Invalid argument\n[out#0/rtsp @ 0x7fafff7ec0] Nothing was written into output file, because at least one of its streams received no packets.\n" stream=grill
    

    I tried splitting it into steps to ingest the MJPEG, then convert the pixel format, then encode to h264, however this results in the same error. The _mjpeg feeds both work, but the final encoded feed has the same encoder error:

    streams:
        grill_mjpeg: "ffmpeg:device?video=/dev/video0&input_format=mjpeg&video_size=1920x1080"
        grill_mjpeg_yuv: exec:ffmpeg -i http://localhost:1984/api/stream.mjpeg?src=grill_mjpeg -pix_fmt yuv420p -c:v copy -rtsp_transport tcp -f rtsp {output}
        grill: ffmpeg:http://localhost:1984/api/stream.mjpeg?src=grill_mjpeg_yuv#video=h264#hardware
    
    go2rtc-1  | 19:39:07.871 WRN [rtsp] error="streams: exec/rtsp\n[h264_v4l2m2m @ 0x7f7f1aca70] Encoder requires yuv420p pixel format.\n[vost#0:0/h264_v4l2m2m @ 0x7f820f83b0] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.\nError while filtering: Invalid argument\n[out#0/rtsp @ 0x7f82745ec0] Nothing was written into output file, because at least one of its streams received no packets.\n" stream=grill
    

    If I change grill_mjpeg_yuv to "-c:v mjpeg" instead of copy, it pegs one of the CPU cores at 100% and this stream will not output anything.

    Can anyone offer any tips?

    As a small side consideration, having an intermediate MJPEG feed available would be helpful for displaying the reversing camera on a monitor in the van with the lowest latency possible, however I want h264 streams for recording and viewing via the van's 4G connection.

  • How to install ffmpeg for ubuntu using command line ?

    12 juin, par Cheng Jaycee Jiang

    A lit background... This is a piece of code in my Dockerfile. I want to deploy my app to google app engine. Somehow I couldn't install ffmpeg.

    ENV VIRTUAL_ENV /env
    ENV PATH /env/bin:$PATH
    RUN apt-get install ffmpeg
    

    This is error log:

    E: Unable to locate package ffmpeg
    The command '/bin/sh -c apt-get install ffmpeg' returned a non-zero code: 100
    ERROR
    ERROR: build step "gcr.io/cloud-builders/docker@sha256:ef2e6744a171cfb0e8a0ef27f9b9a34970341bfc0c3d401afdeedca72292cf73" failed: exit status 100
    

    I found this but it didn't work for me. It complained about add-apt-repository is not valid command. https://askubuntu.com/questions/691109/how-do-i-install-ffmpeg-and-codecs

    Anyone can help me with this? Thanks!!!

  • ffmpeg combine images to video and specify duration for each image ? [duplicate]

    11 juin, par hanshenrik

    Can ffmpeg combine images to a video with a specific duration for each image? For example, i want 1.jpg to be displayed for 100 ms, and 2.jpg to be displayed for 120 ms, and 3.jpg to be displayed for 115 ms, and so on.. can ffmpeg do this?

    I have a bunch of images, each image has their own timestamp, and the timestamps decides how long each image should be in the video..

    This is similar to question Conversion of images to video with variable fps using FFmpeg , but unlike that post, I do not need a gradual increase, but I rather need to specify the duration of each image.

  • Can't import moviepy due to missing ffmpex.exe

    11 juin, par SilentGrove_99

    I was trying to create an application with python using the moviepy library. I installed it using:

    pip install moviepy
    

    I found this from a MoviePy crash-course:

    # Import everything needed to edit video clips
    from moviepy.editor import *
    # or 
    from moviepy import *  # moviepy v2 after removal of editor
    

    After trying to run this line i get this error:

    Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32     bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> # Import everything needed to edit video clips
    ... from moviepy.editor import *
    Traceback (most recent call last):
      File "", line 2, in 
      File "C:\Python27\lib\site-packages\moviepy\editor.py", line 22, in 
        from .video.io.VideoFileClip import VideoFileClip
      File "C:\Python27\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 3, in 
        from moviepy.video.VideoClip import VideoClip
      File "C:\Python27\lib\site-packages\moviepy\video\VideoClip.py", line 20, in 
        from .io.ffmpeg_writer import ffmpeg_write_image, ffmpeg_write_video
      File "C:\Python27\lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 15, in 
        from moviepy.config import get_setting
      File "C:\Python27\lib\site-packages\moviepy\config.py", line 38, in 
        FFMPEG_BINARY = get_exe()
      File "C:\Python27\lib\site-packages\imageio\plugins\ffmpeg.py", line 86, in get_exe
        raise NeedDownloadError('Need ffmpeg exe. '
    imageio.core.fetching.NeedDownloadError: Need ffmpeg exe. You can download it by calling:
      imageio.plugins.ffmpeg.download()
    

    What is the problem here, and how can i fix it?

  • FFMPEG - Image extraction stretch problem [closed]

    11 juin, par karmasan

    I have a .mov video file with 1440x1080 resolution. I extracted the frames from the video, using scale -vf scale=1440:-1 but the images are stretched. Even though, the dimension of the extracted images are 1440x1080, the image is stretched on the height dimension and doesn't match the aspect ratio of the video.

    How can I solve this issue?

    Here is the output from FFMPEG for the original video:

    Stream #0:0(eng): Video: qtrle (rle  / 0x20656C72), rgb24(progressive), 1440x1080, 624445 kb/s, SAR 4:3 DAR 16:9, 25 fps, 25 tbr, 25 tbn (default)