Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Empty audio backends for torchaudio list audio backends, with ffmpeg installed on system libraries [closed]

    28 mars, par Alberto Agudo Dominguez

    I installed torchaudio 2.5.1 and a system install of ffmpeg on Windows and get:

    PS C:\Users\> ffmpeg -version
    ffmpeg version 2025-01-05-git-19c95ecbff-essentials_build-www.gyan.dev Copyright (c) 2000-2025 the FFmpeg developers
    built with gcc 14.2.0 (Rev1, Built by MSYS2 project)
    configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
    libavutil      59. 54.101 / 59. 54.101
    libavcodec     61. 31.100 / 61. 31.100
    libavfilter    10.  6.101 / 10.  6.101
    libswresample   5.  4.100 /  5.  4.100
    libpostproc    58.  4.100 / 58.  4.100
    
    PS C:\Users\> python
    Python 3.12.5 (tags/v3.12.5:ff3bc82, Aug  6 2024, 20:45:27) [MSC v.1940 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import torchaudio
    >>> torchaudio.list_audio_backends()
    []
    

    Hence ffmpeg is added to the path and recognized by the console, but not by torchaudio.

  • How to initialize video decoder with a already decoded frame ?

    27 mars, par Ragdoll Car

    Let's say I have an FFmpeg video decoder x264 initially initialized with some parameters. I am using C++ in my scenario. In normal conditions we push an encoded I-frame into such decoder and then referencing encoded P-frames.

    I have a special case where my I-frame is already decoded. So in my case I want to:

    • push already decoded I-frame into my decoder
    • push referencing encoded P-frames into my decoder

    How can I initialize the decoder state with already decoded I-frame? Currently to bypass these limitations I have to:

    • create a new temporary encoder
    • encode already decoded I-frame
    • decode encoded I-frame
    • and then I am able to push referencing encoded P-frames
  • Audio delay after resuming FFmpeg on Windows

    27 mars, par Iman Sajadpur

    I'm building a screen recording software for Windows using Python. I use FFmpeg for recording and psutil to pause and resume the process.

    Here is a sample of my code:

    import psutil
    import subprocess
    
    process = subprocess.Popen([
            'ffmpeg', '-y',
            '-rtbufsize', '100M',
            '-f', 'gdigrab',
            '-thread_queue_size', '1024',
            '-probesize', '50M',
            '-r', '24',
            '-draw_mouse', '1',
            '-video_size', '1920x1080',
            '-i', 'desktop', 
            '-f', 'dshow',
            '-channel_layout', 'stereo',
            '-thread_queue_size', '1024',
            '-i', 'audio=Microphone (2- High Definition Audio Device)', # my audio device
            '-c:v', 'h264_nvenc', # encoding via Nvidia
            '-r', '24',
            '-preset', 'p1',
            '-pix_fmt', 'yuv444p',
            '-fps_mode', 'cfr',
            '-c:a', 'aac', 
            '-ac', '2',
            '-b:a', '128k',
            'output.mp4'])
    
    ffmpeg_proc = psutil.Process(process.pid)
    
    # pause
    ffmpeg_proc.suspend()
    
    # resume
    ffmpeg_proc.resume() 
    

    The issue is that after resuming, the audio becomes choppy and delayed, while the video continues smoothly.

    I have tried using following flags, but they didn't solve the issue:

    -analyzeduration
    -fflags +genpts
    -async
    -use_wallclock_as_timestamps
    -af aresample=async=1
    

    How can I properly pause and resume FFmpeg without causing audio delay? Is there any other method to handle this properly?

    Thanks for any suggestions.

  • How can I remove silence from an MP3 programmatically ?

    27 mars, par Benjamin Oakes

    I have MP3 files that sometimes have silence at the end. I would like to remove this silence automatically. From what I can tell, it is "perfect" silence (0 amplitude), not background noise. The length of the content and the silence varies.

    I found some other questions about cropping to the first 30 seconds or cropping to X and X+N seconds using ffmpeg. I would think I could use a similar approach, as long as I have a way to find when the silence starts. How would I do that programatically?

    For example, one possible solution would be to have a command that finds the beginning of the "silence". I'd expect a sequence like this

    end=$(ffmpeg some-command-to-find-start-of-silence)
    ffmpeg -t "$end" -acodec copy -i inputfile.mp3 outputfile.mp3
    

    The solution does not have to use ffmpeg, but it does need to be available on Ubuntu.

  • Rewrite video with ffmpeg with given non-equidistant times for each frame

    27 mars, par Aleph0

    In one of my projects it is necessary to synchronize a video with a different datasource. I already have the video as a mts file.

    I also exactly know which frame will be displayed at which time. This times are not necessarily equidistant.

    For simplicity assume that my video consists just out of 5 frames:

    Frame No Time
    1 1s
    2 3s
    3 5s
    4 8s
    5 12s

    What kind of ffmpeg command using a list of times give by a simple text file can be used to create a video stream with non-equidistant frames with the given times.