Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to stream to YouTube from an X server using DISPLAY with ffmpeg ? [closed]

    21 avril, par Ahmed Seddik Bouchiba

    I'm trying to stream my desktop (from an X11 session) to YouTube Live using ffmpeg. I'm running this on a Linux machine with an active X server, and I set the DISPLAY variable accordingly (:0 in most cases).

    Here's the ffmpeg command I've tried:

    ffmpeg -loglevel info \
        -probesize ${PROBESIZE} -analyzeduration ${ANALYZE_DURATION} \
        -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -draw_mouse 0 -i ${DISPLAY} \
        -f alsa -i default \
        -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset fast \
        -r 30 -g 60 -b:v 2000k -bufsize 4000k \
        -acodec libmp3lame -ar 44100 -b:a 128k \
        -map 0:v:0 -map 1:a:0 -vsync 0 \
        -f flv "${RTMP_URL}" &
    

    Environment variables are set correctly (DISPLAY, VIDEO_SIZE, FRAME_RATE, etc.), and I replaced ${RTMP_URL} with the correct YouTube RTMP endpoint (e.g., rtmp://a.rtmp.youtube.com/live2/). But nothing seems to work — the stream never starts or appears on YouTube, and sometimes I get timeout or "connection refused" errors.

    I've checked:

    That I'm logged into an active X session

    That I have access to the display (even tried xhost +)

    That ffmpeg has access to ALSA (sound seems okay)

    Questions:

    Am I missing something in my command?

    Is there a better way to stream both screen and audio from an X server to YouTube Live?

    Could this be a codec or YouTube-specific format issue?

    Any help or working examples would be really appreciated. Thanks!

  • Python add audio to video using opencv or other library

    21 avril, par olokelo

    I use python cv2 module to join jpg frames into video, but I can't add audio to it. Is it possible to add audio to video in python without ffmpeg?

  • Python add audio to video opencv

    21 avril, par olokelo

    I use python cv2 module to join jpg frames into video, but I can't add audio to it. Is it possible to add audio to video in python without ffmpeg? P.S. Sorry for my poor English

  • How to quote a file name with a single quote in ffmpeg movie= filter notation ? [closed]

    21 avril, par PieterV

    I am trying to run ffmpeg using a file that contains a single quote ' in the filename.

    I tried to follow the docs that say I should replace a ' with '\''.
    And a ticket that says I should replace a ' with \\\\\'.

    I've tried both, and can't get get it working.

    E.g. docs format:

    ./ffprobe -loglevel error -read_intervals %00:30 -select_streams s:0 -f lavfi -i "movie='D\:\\Test\\Interlaced - Dragons'\'' Den - S14E02 - Episode 2.mkv'[out0+subcc]" -show_packets -print_format json
    
    {
    [Parsed_movie_0 @ 00000222a2f82200] Failed to avformat_open_input 'D:\Test\Interlaced - Dragons Den - S14E02 - Episode 2.mkv'
    [AVFilterGraph @ 00000222a2f76ec0] Error processing filtergraph: No such file or directory
    movie='D\:\\Test\\Interlaced - Dragons'\'' Den - S14E02 - Episode 2.mkv'[out0+subcc]: No such file or directory
    

    E.g. ticket format:

    ./ffprobe -loglevel error -read_intervals %00:30 -select_streams s:0 -f lavfi -i "movie='D\:\\Test\\Interlaced - Dragons\\\\\' Den - S14E02 - Episode 2.mkv'[out0+subcc]" -show_packets -print_format json
    
    {
    [Parsed_movie_0 @ 00000158613d2080] Failed to avformat_open_input 'D:\Test\Interlaced - Dragons\\ Den - S14E02 - Episode 2.mkv[out0+subcc]'
    [AVFilterGraph @ 00000158613c6ec0] Error processing filtergraph: No such file or directory
    movie='D\:\\Test\\Interlaced - Dragons\\\\\' Den - S14E02 - Episode 2.mkv'[out0+subcc]: No such file or directory
    
    > dir "D:\Test\Interlaced - Dragons' Den - S14E02 - Episode 2.mkv"
    
        Directory: D:\Test
    
    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    -a---           4/20/2025 11:38 AM       18059051 Interlaced - Dragons' Den - S14E02 - Episode 2.mkv
    

    This is on Win11 using FFmpeg7.
    Any ideas?

    [Update]
    I found a doc on escape filtergraph strings, did not help, I tried 0 to 7 \.

    I also found and tried the ffescape utility, the output it produces just uses a single \' and does not work.

    > echo "D:\Test\Interlaced - Dragons' Den - S14E02 - Episode 2.mkv" | ./ffescape.exe
    => D:\\Test\\Interlaced - Dragons\' Den - S14E02 - Episode 2.mkv\
    
    > ./ffprobe -loglevel error -read_intervals %00:30 -select_streams s:0 -f lavfi -i "movie='D:\\Test\\Interlaced - Dragons\' Den - S14E02 - Episode 2.mkv\'[out0+subcc]" -show_packets -print_format json
    {
    [Parsed_movie_0 @ 0000021348f12200] Failed to avformat_open_input 'D'
    [AVFilterGraph @ 0000021348f06ec0] Error processing filtergraph: No such file or directory
    movie='D:\\Test\\Interlaced - Dragons\' Den - S14E02 - Episode 2.mkv\'[out0+subcc]: No such file or directory
    

    [Update]
    I found docs for ffmpeg filter script where I can place commands in a file.

    I tried ./ffprobe -loglevel error -read_intervals %00:01 -select_streams s:0 -f lavfi -/i "d:\filtergraph.txt" -show_packets -print_format json, and it load the script.

    Works: movie=test.mkv[out0+subcc]\ if test.mkv is in ffprobe dir. Works: movie=test\'.mkv[out0+subcc]\ if test'.mkv is in ffprobe dir.
    Not: movie=D:\test.mkv[out0+subcc]
    Not: movie=D\:\\test.mkv[out0+subcc]
    Not: movie=test space.mkv[out0+subcc]
    Not: movie='test space.mkv[out0+subcc]'
    Not: movie="test space.mkv[out0+subcc]"
    Not: 'movie=test space.mkv[out0+subcc]'
    Not: "movie=test space.mkv[out0+subcc]"\

    :(

  • How to get duration a video - laravel

    21 avril, par S.M_Emamian

    I want to get the duration of my videos when I upload them. To do this, I upload my videos like this:

    $video = Carbon::now()->timestamp . '_' .
                $request->file('video')->getClientOriginalName();
    
    
            $request->file('video')->move(
                $this->getCorrectPathOnServerAndLocal('/assets/videos/videos'), $video
            );
    

    My movie is uploaded well. now I want to get the duration of this video. I'm using PHP-FFMpeg:

    composer require php-ffmpeg/php-ffmpeg
    

    $ffprobe = FFProbe::create(); //error
            dd("test");
            $duration = $ffprobe
                ->format($this->getCorrectPathOnServerAndLocal('/assets/videos/videos').$video) // extracts file informations
                ->get('duration');
    

    but I got this error:

      (2/2) ExecutableNotFoundException
    
    Unable to load FFProbe
    in FFProbeDriver.php (line 50)
    at FFProbeDriver::create(array(), null)in FFProbe.php (line 207)