Newest 'ffmpeg' Questions - Stack Overflow

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

Articles published on the website

  • I get an error when running ffmpeg in a daemonized process

    1 October, by 新本修平

    I'm running ffmpeg(4.3.1) in a python(3.7.7) file using the subprocess.call() function.

    cmd = f'ffmpeg -y -i "{mv_temp_out_path}" -vcodec h264 "{mv_ffmpeg_path}"'
    # cmd = f'ffmpeg -y -i "{mv_temp_out_path}" -vcodec h264_nvenc "{mv_ffmpeg_path}"' # gpu
    subprocess.call(cmd, shell=True)
    

    However, when running the python file in gunicorn, I get an error when running it with the -D option (daemonization). If I run it without the -D option, it works fine.I'm wondering if I can't use gpu and I get the same error when I set it to use cpu.

    The result is as follows.

    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './Outputs/TempSaveMovie/200703_4_short_5fr_p2(100_20)_r(50_20).mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2mp41
        encoder         : Lavf58.35.100
      Duration: 00:00:06.15, start: 0.000000, bitrate: 10246 kb/s
        Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 10244 kb/s, 13 fps, 13 tbr, 13312 tbn, 13 tbc (default)
        Metadata:
          handler_name    : VideoHandler
    Stream mapping:
      Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (h264_nvenc))
    Press [q] to stop, [?] for help
    [mpeg4 @ 0x55cec17c5480] header damaged
    [mpeg4 @ 0x55cec17c6840] header damaged
    [mpeg4 @ 0x55cec1855f80] header damaged
    [mpeg4 @ 0x55cec1866e00] header damaged
    Output #0, mp4, to './Outputs/MovieOutputs/200703_4_short_5fr_p2(100_20)_r(50_20).mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2mp41
        encoder         : Lavf58.45.100
        Stream #0:0(und): Video: h264 (h264_nvenc) (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 13 fps, 13312 tbn, 13 tbc (default)
        Metadata:
          handler_name    : VideoHandler
          encoder         : Lavc58.91.100 h264_nvenc
        Side data:
          cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
    Error while decoding stream #0:0: Invalid data found when processing input
    [mpeg4 @ 0x55cec17c8780] header damaged
    Error while decoding stream #0:0: Invalid data found when processing input
    [mpeg4 @ 0x55cec17c5480] header damaged
    ...
    ...
    ...
    [mpeg4 @ 0x55cec1855f80] header damaged
    Error while decoding stream #0:0: Invalid data found when processing input
    [mpeg4 @ 0x55cec1866e00] header damaged
    Error while decoding stream #0:0: Invalid data found when processing input
        Last message repeated 3 times
    frame=   83 fps=0.0 q=14.0 Lsize=    1800kB time=00:00:06.30 bitrate=2337.4kbits/s dup=76 drop=0 speed=18.7x
    video:1799kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.064613%
    Conversion failed!
    

    I would appreciate it if someone could tell me about this. Thank you in advance.

    Postscript I modified the code as follows and ran it.

    com = ['/usr/local/bin/ffmpeg', '-y', '-i', '/var/www/System/Backend/Outputs/TempSaveMovie/200703_4.mp4', '-vcodec', 'h264_nvenc', '/var/www/System/Backend/Outputs/MovieOutputs/200703_4.mp4']
    subprocess.call(com, shell=False)
    

    The result is as follows.

    ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
      built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
      configuration: --disable-shared --enable-static
      libavutil      56. 51.100 / 56. 51.100
      libavcodec     58. 91.100 / 58. 91.100
      libavformat    58. 45.100 / 58. 45.100
      libavdevice    58. 10.100 / 58. 10.100
      libavfilter     7. 85.100 /  7. 85.100
      libswscale      5.  7.100 /  5.  7.100
      libswresample   3.  7.100 /  3.  7.100
    "/var/www/System/Backend/Outputs/TempSaveMovie/200703_4.mp4": No such file or directory
    1
    
    os.path.exists('/var/www/System/Backend/Outputs/TempSaveMovie/200703_4.mp4')
    => True
    
  • Is ffmpeg support GPU acceleration on Jetson platform?

    1 October, by Vincent_Wang

    I want to run ZoneMinder on Jetson nano as an IP CAM server, but it seems that Jetson nano can not handle many cams which are using ffmpeg decode, if I open three cams on ZoneMinder, CPU usage is always 100%, but GPU usage is 0%, and I can not open more cams.

    In this discussion https://forums.developer.nvidia.com/t/ffmpeg-using-hardware-gpu-cuda/72312, the NV Moderator said that

    ffmpeg with GPU support is not enabled on Jetson platform ...

    NVENC/NVDEC can help ffmpeg acceleration, but these hardware blocks is on CPU, not on GPU.

    but I found a repo https://github.com/jocover/jetson-ffmpeg, is this repo can use GPU acceleration? Because I tried but didn't work(still using NVENC/NVDEC acceleration of CPU).

    If GPU on Jetson nano is sure that can not support ffmpeg acceleration, but I want to use ZoneMinder, is there a better way to solve this problem? e.g. using GStreamer?

  • Synchronize multiple audio streams

    1 October, by Pittie

    I try to synchronize several audio streams coming from several RTP sources with this filter

    [0:a][1:a][2:a] amix=inputs=3 [mixed]
    

    I want the audio to be almost real-time and the sounds can be played right after they arrive. but ffmpeg try to sync them based on the timestamp. and if the stream 1 arrive sooner, they have to wait for the last stream to come.

    what should I do to make the program do what I expect?

  • Audio in ffmpeg

    1 October, by Konduri Sai Aditya

    I need to add audio as an input to below command, How can I achieve it

    ffmpeg -i test.png -i test.mp4 -y -filter_complex "[1:v]scale=1422:800[scale1],[scale1]rotate=0:c=black@0:ow=rotw(0):oh=roth(0)[rotate0],[0:v][rotate0]overlay=258.04:107.71[mediaoverlayout0],color=black@0:451x137[c1],[c1]setsar=1,drawtext=fontfile='/Windows/fonts/Peddana-Regular.ttf':text='ADITYA':fontsize=121.19999999999999:fontcolor=#1e8bc3:line_spacing=16.91,rotate=0:ow=rotw(0):oh=roth(0):c=black@0[rottext1],[mediaoverlayout0][rottext1]overlay=x=544.63:y=263.076:shortest=1" -pix_fmt yuv420p op.mp4
    
  • Video with music taking long time

    1 October, by Konduri Sai Aditya

    Hi I am rendering video with filters and adding audio at the end. But while running it is taking a long time and rendering continuously. Can anyone help me where I am wrong? below is the command

     ffmpeg -i test.png -i test.mp4 -i test.mp3  -y -filter_complex "[1:v]scale=1422:800[scale1],[scale1]rotate=0:c=black@0:ow=rotw(0):oh=roth(0)[rotate0],[0:v][rotate0]overlay=258.04:107.71[mediaoverlayout0],color=black@0:451x137[c1],[c1]setsar=1,drawtext=fontfile='/Windows/fonts/Peddana-Regular.ttf':text='ADITYA':fontsize=121.199:fontcolor=#1e8bc3:line_spacing=16.91,rotate=0:ow=rotw(0):oh=roth(0):c=black@0[rottext1],[mediaoverlayout0][rottext1]overlay=x=544.63:y=263.076[out]" -vcodec libx264 -map "[out]" -map 2:a -preset veryfast -c:a copy -pix_fmt yuv420p op.mp4