Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • FFmpeg av_dump_format showing incorrect output, but ffprobe displays correct metadata

    29 janvier, par グルグル

    I use ffmpeg 7.1 source build on windows and compilation configuration as follow:

    configuration:
      --toolchain=msvc
      --arch=x86_64
      --enable-x86asm
      --enable-asm
      --enable-shared
      --enable-w32threads
      --prefix=/D/build
    

    When I use av_dump_format to print metadata of test.mp3, it display the incorrect information.

    extern "C"
    {
    #include avformat.h>
    }
    
    int main()
    { 
        av_log_set_level(AV_LOG_DEBUG);
    
        auto url = "D:/music/test.mp3";
    
        AVFormatContext* fmt;
        auto ret = avformat_open_input(&fmt, url, nullptr, nullptr);
        if (ret < 0)
        {
            av_log(nullptr, AV_LOG_ERROR, "Cannot open %s format : %s", url, av_err2str(ret));
            exit(EXIT_FAILURE);
        }
    
        av_dump_format(fmt, 0, url, 0);
    }
    

    output

    [AVFormatContext @ 000001768E65BC40] Opening 'D:/music/test.mp3' for reading
    [file @ 000001768E65C180] Setting default whitelist 'file,crypto,data'
    [mp3 @ 000001768E65BC40] Format mp3 probed with size=4096 and score=51
    id3v2 ver:4 flags:00 len:35
    [mp3 @ 000001768E65BC40] pad 576 576
    [mp3 @ 000001768E65BC40] Skipping 0 bytes of junk at 462.
    Input #0, mp3, from 'D:/music/test.mp3':
      Metadata:
        encoder         : Lavf58.76.100
      Duration: N/A, bitrate: N/A
      Stream #0:0, 0, 1/14112000: Audio: mp3, 0 channels
          Metadata:
            encoder         : Lavc58.13
    

    You can see the Stream info is useless.

    But I use ffprobe which is built with same configuration to print metadata of test.mp3.

    It's display normal.

    ffprobe version 7.0.1 Copyright (c) 2007-2024 the FFmpeg developers
      built with Microsoft (R) C/C++ Optimizing Compiler Version 19.41.34123 for x64
      configuration: --toolchain=msvc --arch=x86_64 --enable-x86asm --enable-asm --enable-shared --enable-w32threads --prefix=/D/build
      WARNING: library configuration mismatch
      avutil      configuration: --toolchain=msvc --arch=x86_64 --enable-x86asm --enable-asm --enable-shared --enable-w32threads --disable-programs --disable-doc --disable-static --prefix=/D/build
      avcodec     configuration: --toolchain=msvc --arch=x86_64 --enable-x86asm --enable-asm --enable-shared --enable-w32threads --disable-programs --disable-doc --disable-static --prefix=/D/build
      avformat    configuration: --toolchain=msvc --arch=x86_64 --enable-x86asm --enable-asm --enable-shared --enable-w32threads --disable-programs --disable-doc --disable-static --prefix=/D/build
      avdevice    configuration: --toolchain=msvc --arch=x86_64 --enable-x86asm --enable-asm --enable-shared --enable-w32threads --disable-programs --disable-doc --disable-static --prefix=/D/build
      avfilter    configuration: --toolchain=msvc --arch=x86_64 --enable-x86asm --enable-asm --enable-shared --enable-w32threads --disable-programs --disable-doc --disable-static --prefix=/D/build
      swscale     configuration: --toolchain=msvc --arch=x86_64 --enable-x86asm --enable-asm --enable-shared --enable-w32threads --disable-programs --disable-doc --disable-static --prefix=/D/build
      swresample  configuration: --toolchain=msvc --arch=x86_64 --enable-x86asm --enable-asm --enable-shared --enable-w32threads --disable-programs --disable-doc --disable-static --prefix=/D/build
      libavutil      59.  8.100 / 59. 39.100
      libavcodec     61.  3.100 / 61. 19.100
      libavformat    61.  1.100 / 61.  7.100
      libavdevice    61.  1.100 / 61.  3.100
      libavfilter    10.  1.100 / 10.  4.100
      libswscale      8.  1.100 /  8.  3.100
      libswresample   5.  1.100 /  5.  3.100
    Input #0, mp3, from 'D:\music\test.mp3':
      Metadata:
        encoder         : Lavf58.76.100
      Duration: 00:05:00.12, start: 0.025057, bitrate: 128 kb/s
      Stream #0:0: Audio: mp3 (mp3float), 44100 Hz, stereo, fltp, 128 kb/s
          Metadata:
            encoder         : Lavc58.13
    

    Why is av_dump_format not correctly showing stream information? How can I fix it?

  • converting mp3 to ts with ffmpeg [closed]

    29 janvier, par tamirg

    i have an mp3 of about 50 kb. if i use ffmpeg to convert to ts:

    ffmpeg -i sample.mp3 sample.ts
    

    i end up getting a file of almost 200kb.

    while if i use some online software which converts mp3 to ts (https://clideo.com/editor/?convertTo=TS for example), i get a file with similar size to the original mp3.

    why does the ffmpeg conversion creates such a large file? is it possible to reduce that?

  • GPU-accelerated video processing with ffmpeg

    29 janvier, par Wang Hai

    I want to use ffmpeg to accelerate video encode and decode with an NVIDIA GPU.

    From NVIDIA's website:

    NVIDIA GPUs contain one or more hardware-based decoder and encoder(s) (separate from the CUDA cores) which provides fully-accelerated hardware-based video decoding and encoding for several popular codecs. With decoding/encoding offloaded, the graphics engine and the CPU are free for other operations.

    My question is: can I use CUDA cores to encode and decode video, maybe faster?

  • HlS playlist skip files with ffmpeg

    29 janvier, par tamirg

    I simply downloaded 5 mp3 files from here: https://samplelib.com/sample-mp3.html

    which means i have:

    sample-3s.mp3
    sample-6s.mp3
    sample-9s.mp3
    sample-12s.mp3
    sample-15s.mp3
    

    and then i create a simple hls playlist sample.m3u8:

    #EXTM3U
    #EXT-X-TARGETDURATION:20
    #EXT-X-MEDIA-SEQUENCE:0
    #EXTINF:3.0,
    sample-3s.mp3
    #EXTINF:6.0,
    sample-6s.mp3
    #EXTINF:9.0,
    sample-9s.mp3
    #EXTINF:12.0,
    sample-12s.mp3
    #EXTINF:15.0,
    sample-15s.mp3
    

    But when i play this playlist:

    ffplay sample.m3u8
    

    i get:

    [hls @ 0x13703b4d0] Opening 'sample-9s.mp3' for reading
    [mp3 @ 0x13703b740] invalid concatenated file detected - using bitrate for duration
    Input #0, hls, from 'playlist2.m3u8':
      Duration: N/A, start: 0.000000, bitrate: 128 kb/s
      Program 0
        Metadata:
          variant_bitrate : 0
      Stream #0:0: Audio: mp3 (mp3float), 44100 Hz, stereo, fltp, 128 kb/s
          Metadata:
            variant_bitrate : 0
            encoder         : Lavc57.10
    2025-01-29 10:57:46.957 ffplay[17029:696588] +[IMKClient subclass]: chose IMKClient_Modern
    2025-01-29 10:57:46.957 ffplay[17029:696588] +[IMKInputSession subclass]: chose IMKInputSession_Modern
    [hls @ 0x13703b4d0] Opening 'sample-12s.mp3' for reading 0B
    [mp3float @ 0x13703c710] Header missingvq=    0KB sq=    0B
    [hls @ 0x13703b4d0] Opening 'sample-15s.mp3' for reading 0B
    

    It starts playing from the file sample-9s, and not sample-3s. So it skips the first two files. Why does it happen?

  • Silent Audio In Concatenated MP4s (Python, FFMPEG)

    28 janvier, par John Coleman

    I am trying to solve an issue with concatenating several video files and ending up with silent audio for the whole generated video. Part of this is generating two videos, one title and one end screen, created from images, which I have added silence to. I then take these and add up to seven videos (with stereo audio, 48000hz). So, it ends up being Title + {up to seven videos} + end screen.

    I've added silence to the title/end screens, set the sample rate, channels, etc. but still no go. I still lose audio on the videos that should have audio (that originally did).

    Relevant code:

    Title Screen:

    (
                ffmpeg
                .input(thumbnail_path, loop=1, t=self.config.title_duration)
                .filter('fade', type='in', duration=self.config.fade_duration)
                .output(title_temp, vcodec='h264', acodec='aac', af='aevalsrc=0:d={}[aout]:s=48000:c=2'.format(self.config.title_duration))
                .overwrite_output()
                .run(capture_stdout=True, capture_stderr=True)
            )
    

    End Screen:

    (
                ffmpeg
                .input(end_screen_path, loop=1, t=self.config.end_screen_duration)
                .filter('fade', type='in', duration=self.config.fade_duration)
                .output(end_temp, vcodec='h264', acodec='aac', af='aevalsrc=0:d={}[aout]:s=48000:c=2'.format(self.config.end_screen_duration))
                .overwrite_output()
                .run(capture_stdout=True, capture_stderr=True)
            )
    

    Concatenate:

    (
                ffmpeg
                .input(concat_file, format='concat', safe=0)
                .output(output_path, c='copy')
                .overwrite_output()
                .run(capture_stdout=True, capture_stderr=True)
            )
    

    Any help with this would be SUPER appreciated. Thank you!