Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to add dynamic captions with animations on a video in a cross-platform Android & iOS app and export it as a final video ? [closed]

    29 avril, par Danial Qsk

    I'm building a cross-platform mobile app using Flutter (or React Native) where users can:

    Add dynamic text captions with animations over a video, similar to TikTok

    See these changes in real-time during video playback

    Export the video with the animated captions burned into the output (e.g., MP4)

    What I’ve implemented so far:

    Video playback using video_player in Flutter (or react-native-video).

    Captions are rendered using Canvas/UI layer during playback.

    Problem: While I can overlay animated text in the UI, I can't figure out how to include these in the exported video. I’m considering using FFmpeg to burn in the captions, but I’m unclear how to integrate it with the animated UI overlays or render them into a final video on both Android and iOS.

    What I want to achieve:

    Efficient way to render animated text overlays onto a video and export it as a final video file on both Android and iOS.

    Maintain good performance for real-time playback and smooth export.

    What approaches or processing pipelines could achieve this? (For example, rendering the UI layer to an offscreen video, integrating with FFmpeg, or using native rendering techniques.)

  • ffmpeg : Stream specifiers per format/codec [closed]

    29 avril, par nathan wurtz

    I was wondering if it were possible to select all the stream in a specific format.

    Example :

      Stream #0:0(eng): Video: h264 (High), yuv420p(tv, smpte170m/smpte170m/bt709, progressive), 710x480 [SAR 32:27 DAR 142:81], SAR 841:710 DAR 841:480, 29.97 fps, 29.97 tbr, 1k tbn, 180k tbc (default)
      Stream #0:1(deu): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
      Stream #0:2(deu): Subtitle: dvd_subtitle, 720x480
      Stream #0:3(eng): Subtitle: dvd_subtitle, 720x480
      Stream #0:4(fra): Subtitle: dvd_subtitle, 720x480
      Stream #0:5(spa): Subtitle: dvd_subtitle, 720x480
      Stream #0:6(eng): Subtitle: subrip (default)
    

    I would like to select all the dvd_subtitle to set the 'codec' to copy. And select the subrip subtitle to set the 'codec' to mov_text. And all that without having to specify the stream number (I would like to reuse the same arguments to convert other videos)

    I thought about doing something like that : -c:m:dvd_subtitle copy -c:m:subrip mov_text, but that obviously didn't work.

    I have read the doc https://ffmpeg.org/ffmpeg.html#Stream-specifiers but didn't find a solution.

    Thank you for reading

  • ffmpeg - Any way to add a transition to a list of clips to combine into a single video ?

    29 avril, par J. Pena

    Let's say I have a directory with 5 videos with the titles listed as the following

    • 1.mp4
    • 2.mp4
    • 3.mp4
    • 4.mp4
    • 5.mp4

    I created the text file named mylist.txt with the following written.

    file '1.mp4'
    file '2.mp4'
    file '3.mp4'
    file '4.mp4'
    file '5.mp4'
    

    I have an ffmpeg command that will combine these clips into one file beautifully already using the text file.

    ffmpeg -f concat -safe 0 -i mylist.txt -c copy combined.mp4
    

    My question is how can I add a fade transition to clips 2-4 using the text file? The filter_complex parameter gives me an error.

    Streamcopy requested for output stream fed from a complex filtergraph. Filtering and streamcopy cannot be used together.
    
  • Codec AVOption b (set bitrate (in bits/s)) specified for output file #0 (360p.m3u 8) has not been used for any stream.

    28 avril, par Marc Archenault

    I am receiving this warning from ffmpeg. The job runs and all the videos seem to output correctly. I have 2 hls, 1 mp4 with overlay + A single thumbnail.

    The warning:

    Stream #1:0: Video: png, rgba(pc), 500x38, 25 tbr, 25 tbn, 25 tbc Codec AVOption b (set bitrate (in bits/s)) specified for output file #0 (360p.m3u 8) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of s ome encoder which was not actually used for any stream.

    The windows batch command:

    ffmpeg -loglevel info -threads 2 -hide_banner -y -i SampleVideo_1280x720_10mb.mp4 -i ecocastvideo-overlay-shadow-white-500.png^ -filter_complex "[1]colorchannelmixer=aa=0.7,scale=iw*0.7:-1[wm];[0:v][wm]overlay=(main_w-overlay_w)-10:(main_h-overlay_h)-30,split=3[a][b][c];[a]scale=w=640:h=360:force_original_aspect_ratio=decrease[a];[b]scale=w=1280:h=720:force_original_aspect_ratio=decrease[b];[c]scale=w=1280:h=720:force_original_aspect_ratio=decrease[c]"^ -map "[a]" -map 0:v -c:v h264 -profile:v main -crf 20 -preset veryfast -sc_threshold 0 -g 72 -keyint_min 72 -hls_time 4 -hls_playlist_type vod -b:a 96k -hls_flags single_file 360p.m3u8^ -map "[b]" -map 0:v -c:v h264 -profile:v main -crf 20 -preset veryfast -sc_threshold 0 -g 72 -keyint_min 72 -hls_time 4 -hls_playlist_type vod -b:a 96k -hls_flags single_file 720p.m3u8^ -map "[c]" -map 0:v -c:v h264 -profile:v main -preset veryfast 720.mp4^ -map 0:v -y -ss 0.5 -vframes 1 -an -s 120x90 -ss 30 thumbname-00001.png

  • FFmpeg container is unable to communicate to my application container in Quarkus [duplicate]

    28 avril, par Abhi11

    I'm working on a application where i am running different container such as clamav,postgres,my quarkus application.all the configuration is defined in docker compose file.now i want to perform some operation on file that's why want to use ffmpeg. i am using ffmpeg as separate container and connected via docker network.i want to execute some ffmpeg command for example check version and other advance.I'm getting error. Please help me to solve this.

    My docker-compose.yml --

    version: "3.8"
    services:
      clamav:
        image: clamav/clamav:latest
        container_name: clamav
        ports:
          - "3310:3310"
        restart: always
        healthcheck:
          test: ["CMD", "clamdscan", "--version"]
          interval: 30s
          timeout: 10s
          retries: 5
        networks:
          - techtonic-antivirus-net
    
      postgres-database:
        image: postgres:15
        container_name: postgres
        environment:
          POSTGRES_DB: antivirustt
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
        ports:
          - "5434:5432"`enter code here`
        restart: always
        volumes:
          - pgdata:/var/lib/postgresql/data
        networks:
          - techtonic-antivirus-net
    
      # Add Redis container
      redis:
        image: redis:latestenter code here
        container_name: redis
        ports:
          - "6379:6379"
        restart: always
        networks:
          - techtonic-antivirus-net
    
      ffmpeg:
        image: jrottenberg/ffmpeg:latest
        container_name: ffmpeg
        restart: always
        entrypoint: ["tail", "-f", "/dev/null"]  # Keeps the container running
        networks:
          - techtonic-antivirus-net
        healthcheck:
          test: ["CMD", "ffmpeg", "-version"]
          interval: 10s
          timeout: 5s
          retries: 3
    
      techtonic-antivirus:
        build:
          context: .
          dockerfile: src/main/docker/Dockerfile.native-micro
        container_name: techtonic-antivirus
        depends_on:
          clamav:
            condition: service_healthy
          postgres-database:
            condition: service_started
          redis:
            condition: service_started
        ports:
          - "8080:8080"
        environment:
          - CLAMAV_HOST=${CLAMAV_HOST}
          - CLAMAV_PORT=${CLAMAV_PORT}
          - QUARKUS_PROFILE=${QUARKUS_PROFILE:-dev}
          - QUARKUS_DATASOURCE_JDBC_URL=jdbc:postgresql://postgres-database:5432/antivirustt
          - QUARKUS_DATASOURCE_USERNAME=postgres
          - QUARKUS_DATASOURCE_PASSWORD=postgres
          - QUARKUS_REDIS_HOSTS=redis://redis:6379
        restart: always
        volumes:
          - ffmpeg:/ffmpeg
          - /var/run/docker.sock:/var/run/docker.sock
        networks:
          - techtonic-antivirus-net
    
    volumes:
      pgdata:
      ffmpeg:
    
    networks:
      techtonic-antivirus-net:
    

    My Service code :

    @Slf4j
    @ApplicationScoped
    public class CheckFFmpegStatus {
    
        public static boolean isFFmpegReady() {
            try {
                // ProcessBuilder pb = new ProcessBuilder("docker", "exec", "ffmpeg", "ffmpeg", "-version");
                ProcessBuilder pb = new ProcessBuilder("ffmpeg", "-version");
                Process process = pb.start();
                int exitCode = process.waitFor();
                if (exitCode == 0) {
                    log.info("✅ FFmpeg is ready and reachable inside the container.");
                } else {
                    log.warn("⚠️ FFmpeg process exited with code: " + exitCode);
                }
    
                return exitCode == 0;
            } catch (IOException | InterruptedException e) {
                log.error("❌ Failed to check FFmpeg status", e);
                return false;
            }
        }
    }