Recherche avancée

Médias (1)

Mot : - Tags -/wave

Autres articles (96)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

Sur d’autres sites (5726)

  • Error Opening RTMP Stream through FFmpeg command when executed through exec package [closed]

    3 octobre 2024, par Akhil

    I have been trying to transcode the live stream from RTMP server running on rtmp://localhost:1936/live/test with FFmpeg in a Go application using os/exec package, But seems to not work and gives the input/output error (I have attached below). The same exact ffmpeg command when I execute on terminal, works as its supposed to. Not Sure why that is, here is my code for reproducing and analyzing the mistakes.

    


    ffmpegCmd := fmt.Sprintf("ffmpeg -nostdin -i rtmp://localhost:1936/live/%s -c:v libx264 -s %s -f %s %s/stream.mpd",
        streamKey, resolution, sp.OutputFormat, outputPath)
    log.Printf("Executing FFmpeg command: %s", ffmpegCmd)

    // Prepare the command execution with a timeout context
    ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) // Set a 60-second timeout
    defer cancel()

    cmd := exec.CommandContext(ctx, "bash", "-c", ffmpegCmd)


    


    the ffmpeg command looks like this :
    
ffmpeg -nostdin -i rtmp://localhost:1936/live/test -c:v libx264 -s 1920x1080 -f dash output/test/1080p/stream.mpd

    


    I get the following error :

    


    Error opening input: Input/output error

Error opening input file rtmp://localhost:1936/live/test.

Error opening input files: Input/output error

Exiting normally, received signal 2.

signal: interrupt


    


    I have already tried to break the command, and then execute it. Something like :

    


    cmd := exec.CommandContext(ctx,
        "ffmpeg",
        "-nostdin",
        "-i", "rtmp://localhost:1936/live/"+streamKey,
        "-c:v", "libx264",
        "-s", resolution,
        "-f", sp.OutputFormat,
        outputPath+"/stream.mpd")


    


    After running the ffmpeg command with -loglevel debug and -report :

    


    Here is the logs and errors I get :

    


    When I run it within the go application :

    


    ffmpeg started on 2024-10-02 at 12:00:06
Report written to "ffmpeg-20241002-120006.log"
Log level: 48
Command line:
ffmpeg -loglevel debug -report -i rtmp://localhost:1936/live/test -c:v libx264 -s 1920x1080 -f dash ./output/test/1080p/stream.mpd
ffmpeg version 7.0.2 Copyright (c) 2000-2024 the FFmpeg developers
  built with Apple clang version 15.0.0 (clang-1500.3.9.4)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/7.0.2_1 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox --enable-neon
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-i' ... matched as input url with argument 'rtmp://localhost:1936/live/test'.
Reading option '-c:v' ... matched as option 'c' (select encoder/decoder ('copy' to copy stream without reencoding)) with argument 'libx264'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '1920x1080'.
Reading option '-f' ... matched as option 'f' (force container format (auto-detected otherwise)) with argument 'dash'.
Reading option './output/test/1080p/stream.mpd' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url rtmp://localhost:1936/live/test.
Successfully parsed a group of options.
Opening an input file: rtmp://localhost:1936/live/test.
[AVFormatContext @ 0x13f721f90] Opening 'rtmp://localhost:1936/live/test' for reading
[rtmp @ 0x13f6040e0] No default whitelist set
[tcp @ 0x13f7223d0] No default whitelist set
[tcp @ 0x13f7223d0] Original list of addresses:
[tcp @ 0x13f7223d0] Address ::1 port 1936
[tcp @ 0x13f7223d0] Address 127.0.0.1 port 1936
[tcp @ 0x13f7223d0] Interleaved list of addresses:
[tcp @ 0x13f7223d0] Address ::1 port 1936
[tcp @ 0x13f7223d0] Address 127.0.0.1 port 1936
[tcp @ 0x13f7223d0] Starting connection attempt to ::1 port 1936
[tcp @ 0x13f7223d0] Connection attempt to ::1 port 1936 failed: Connection refused
[tcp @ 0x13f7223d0] Starting connection attempt to 127.0.0.1 port 1936
[tcp @ 0x13f7223d0] Successfully connected to 127.0.0.1 port 1936
[rtmp @ 0x13f6040e0] Handshaking...
[rtmp @ 0x13f6040e0] Type answer 3
[rtmp @ 0x13f6040e0] Server version 13.14.10.13
[rtmp @ 0x13f6040e0] Proto = rtmp, path = /live/test, app = live, fname = test
[rtmp @ 0x13f6040e0] Window acknowledgement size = 5000000
[rtmp @ 0x13f6040e0] Max sent, unacked = 5000000
[rtmp @ 0x13f6040e0] New incoming chunk size = 4096
[rtmp @ 0x13f6040e0] Creating stream...
[rtmp @ 0x13f6040e0] Sending play command for 'test'
[rtmp @ 0x13f6040e0] Deleting stream...
[in#0 @ 0x13f721d40] Error opening input: Input/output error
Error opening input file rtmp://localhost:1936/live/test.
Error opening input files: Input/output error
Exiting normally, received signal 2.


    


    This is what i get when i run the same command on terminal :

    


    <same as="as" but="but" please="please" scroll="scroll" further="further">&#xA;&#xA;[rtmp @ 0x1437144c0] No default whitelist set&#xA;[tcp @ 0x143604f20] No default whitelist set&#xA;[tcp @ 0x143604f20] Original list of addresses:&#xA;[tcp @ 0x143604f20] Address ::1 port 1936&#xA;[tcp @ 0x143604f20] Address 127.0.0.1 port 1936&#xA;[tcp @ 0x143604f20] Interleaved list of addresses:&#xA;[tcp @ 0x143604f20] Address ::1 port 1936&#xA;[tcp @ 0x143604f20] Address 127.0.0.1 port 1936&#xA;[tcp @ 0x143604f20] Starting connection attempt to ::1 port 1936&#xA;[tcp @ 0x143604f20] Connection attempt to ::1 port 1936 failed: Connection refused&#xA;[tcp @ 0x143604f20] Starting connection attempt to 127.0.0.1 port 1936&#xA;[tcp @ 0x143604f20] Successfully connected to 127.0.0.1 port 1936&#xA;[rtmp @ 0x1437144c0] Handshaking...&#xA;[rtmp @ 0x1437144c0] Type answer 3&#xA;[rtmp @ 0x1437144c0] Server version 13.14.10.13&#xA;[rtmp @ 0x1437144c0] Proto = rtmp, path = /live/test, app = live, fname = test&#xA;[rtmp @ 0x1437144c0] Window acknowledgement size = 5000000&#xA;[rtmp @ 0x1437144c0] Max sent, unacked = 5000000&#xA;[rtmp @ 0x1437144c0] New incoming chunk size = 4096&#xA;[rtmp @ 0x1437144c0] Creating stream...&#xA;[rtmp @ 0x1437144c0] Sending play command for &#x27;test&#x27;&#xA;[flv @ 0x143604b30] Format flv probed with size=2048 and score=100&#xA;[flv @ 0x143604b30] Before avformat_find_stream_info() pos: 13 bytes read:2263 seeks:0 nb_streams:0&#xA;Transform tree:&#xA;    mdct_inv_float_c - type: mdct_float, len: 64, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]&#xA;        fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]&#xA;Transform tree:&#xA;    mdct_inv_float_c - type: mdct_float, len: 64, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]&#xA;        fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]&#xA;Transform tree:&#xA;    mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 120, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]&#xA;        fft4_fwd_float_neon - type: fft_float, len: 4, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]&#xA;Transform tree:&#xA;    mdct_inv_float_c - type: mdct_float, len: 128, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]&#xA;        fft_sr_ns_float_neon - type: fft_float, len: 64, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]&#xA;Transform tree:&#xA;    mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 480, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]&#xA;        fft16_ns_float_neon - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]&#xA;Transform tree:&#xA;    mdct_inv_float_c - type: mdct_float, len: 512, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]&#xA;        fft_sr_ns_float_neon - type: fft_float, len: 256, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]&#xA;Transform tree:&#xA;    mdct_pfa_15xM_inv_float_c - type: mdct_float, len: 960, factors[2]: [15, any], flags: [unaligned, out_of_place, inv_only]&#xA;        fft32_ns_float_neon - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]&#xA;Transform tree:&#xA;    mdct_inv_float_c - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only]&#xA;        fft_sr_ns_float_neon - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]&#xA;Transform tree:&#xA;    mdct_fwd_float_c - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only]&#xA;        fft_sr_ns_float_neon - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]&#xA;[NULL @ 0x144124920] nal_unit_type: 7(SPS), nal_ref_idc: 3&#xA;[NULL @ 0x144124920] Decoding VUI&#xA;[NULL @ 0x144124920] nal_unit_type: 8(PPS), nal_ref_idc: 3&#xA;[NULL @ 0x144124920] Decoding VUI&#xA;[h264 @ 0x144124920] nal_unit_type: 7(SPS), nal_ref_idc: 3&#xA;[h264 @ 0x144124920] Decoding VUI&#xA;[h264 @ 0x144124920] nal_unit_type: 8(PPS), nal_ref_idc: 3&#xA;[h264 @ 0x144124920] nal_unit_type: 7(SPS), nal_ref_idc: 3&#xA;[h264 @ 0x144124920] nal_unit_type: 8(PPS), nal_ref_idc: 3&#xA;[h264 @ 0x144124920] nal_unit_type: 5(IDR), nal_ref_idc: 3&#xA;[h264 @ 0x144124920] Decoding VUI&#xA;[h264 @ 0x144124920] Format yuv420p chosen by get_format().&#xA;[h264 @ 0x144124920] Reinit context to 1280x720, pix_fmt: yuv420p&#xA;[h264 @ 0x144124920] no picture &#xA;[flv @ 0x143604b30] All info found&#xA;[flv @ 0x143604b30] rfps: 29.666667 0.016552&#xA;[flv @ 0x143604b30] rfps: 29.750000 0.009347&#xA;[flv @ 0x143604b30] rfps: 29.750000 0.009347&#xA;[flv @ 0x143604b30] rfps: 29.833333 0.004197&#xA;[flv @ 0x143604b30] rfps: 29.916667 0.001104&#xA;[flv @ 0x143604b30] rfps: 29.916667 0.001104&#xA;[flv @ 0x143604b30] rfps: 30.000000 0.000067&#xA;[flv @ 0x143604b30] rfps: 30.000000 0.000067&#xA;[flv @ 0x143604b30] rfps: 60.000000 0.000270&#xA;[flv @ 0x143604b30] rfps: 60.000000 0.000270&#xA;[flv @ 0x143604b30] rfps: 120.000000 0.001079&#xA;[flv @ 0x143604b30] rfps: 120.000000 0.001079&#xA;[flv @ 0x143604b30] rfps: 240.000000 0.004316&#xA;[flv @ 0x143604b30] rfps: 240.000000 0.004316&#xA;[flv @ 0x143604b30] rfps: 29.970030 0.000204&#xA;[flv @ 0x143604b30] rfps: 29.970030 0.000204&#xA;[flv @ 0x143604b30] rfps: 59.940060 0.000814&#xA;[flv @ 0x143604b30] rfps: 59.940060 0.000814&#xA;[flv @ 0x143604b30] After avformat_find_stream_info() pos: 496783 bytes read:496783 seeks:0 frames:179&#xA;Input #0, flv, from &#x27;rtmp://localhost:1936/live/test&#x27;:&#xA;  Metadata:&#xA;    |RtmpSampleAccess: true&#xA;    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)&#xA;    displayWidth    : 1280&#xA;    displayHeight   : 720&#xA;    fps             : 30&#xA;    profile         : &#xA;    level           : &#xA;  Duration: 00:00:00.00, start: 6.742000, bitrate: N/A&#xA;  Stream #0:0, 138, 1/1000: Audio: aac (LC), 48000 Hz, stereo, fltp, 163 kb/s&#xA;  Stream #0:1, 41, 1/1000: Video: h264 (High), 1 reference frame, yuv420p(tv, bt709, progressive, left), 1280x720 [SAR 1:1 DAR 16:9], 0/1, 2560 kb/s, 30 fps, 30 tbr, 1k tbn&#xA;Successfully opened the file.&#xA;Parsing a group of options: output url ./output/test/1080p/stream.mpd.&#xA;Applying option c:v (select encoder/decoder (&#x27;copy&#x27; to copy stream without reencoding)) with argument libx264.&#xA;Applying option s (set frame size (WxH or abbreviation)) with argument 1920x1080.&#xA;Applying option f (force container format (auto-detected otherwise)) with argument dash.&#xA;Successfully parsed a group of options.&#xA;Opening an output file: ./output/test/1080p/stream.mpd.&#xA;[out#0/dash @ 0x123707480] No explicit maps, mapping streams automatically...&#xA;[vost#0:0/libx264 @ 0x123707d60] Created video stream from input stream 0:1&#xA;detected 10 logical cores&#xA;[h264 @ 0x123607b70] nal_unit_type: 7(SPS), nal_ref_idc: 3&#xA;[h264 @ 0x123607b70] Decoding VUI&#xA;[h264 @ 0x123607b70] nal_unit_type: 8(PPS), nal_ref_idc: 3&#xA;[aost#0:1/aac @ 0x144028080] Created audio stream from input stream 0:0&#xA;Transform tree:&#xA;    mdct_inv_float_c - type: md&#xA;&#xA;<it simply="simply" starts="starts" working="working">&#xA;</it></same>

    &#xA;

    I am not sure if there is something to do with Permissions.

    &#xA;

  • How to add custom configure option with VCPKG when building FFMPEG ?

    1er novembre 2024, par NickWuzh

    Does anyone know how to enable x11grab format in FFMPEG with VCPKG ?

    &#xA;

    I'm building FFMPEG in vcpkg manifest mode. Here is my vcpkg.json :

    &#xA;

    {&#xA;  "name": "project",&#xA;  "version": "1.0.0",&#xA;  "dependencies": [&#xA;    {&#xA;      "name": "ffmpeg",&#xA;      "features": [&#xA;        "avcodec",&#xA;        "avdevice",&#xA;        "avfilter",&#xA;        "avformat",&#xA;        "bzip2",&#xA;        "ffmpeg",&#xA;        "lzma",&#xA;        "postproc",&#xA;        "swresample",&#xA;        "swscale",&#xA;        "x264",&#xA;        "zlib"&#xA;      ]&#xA;    },&#xA;    "iniparser",&#xA;    "jsoncpp",&#xA;    "spdlog"&#xA;  ]&#xA;}&#xA;&#xA;

    &#xA;

    And I want to enable x11grab configuration in order to capture screen in Linux, but I found no feature was adapted.&#xA;Soon I found that —enable-libxcb was needed in configure and it was autodetect. So I build and install libxcb with source. And pkg-config can find it :

    &#xA;

    $ pkg-config --modversion xcb&#xA;1.17.0&#xA;

    &#xA;

    But it doesn't work because in default it is —disable-autodetect in $VCPKG_ROOT/ports/ffmpeg/portfile.cmake :

    &#xA;

    set(OPTIONS "--enable-pic --disable-doc --enable-debug --enable-runtime-cpudetect --disable-autodetect")&#xA;

    &#xA;

    I try to modify $VCPKG_ROOT/ports/ffmpeg/portfile.cmake —enalbe-autodetect, but it doesn't work either. Here is the short message when appling vcpkg install --triplet x64-linux-release

    &#xA;

    -- Using source at /usr/local/src/cpp/third-party/vcpkg/buildtrees/ffmpeg/src/n7.0.2-8cb3114be3.clean&#xA;-- Getting CMake variables for x64-linux-release&#xA;-- Building Options: --enable-pic --disable-doc --enable-debug --enable-runtime-cpudetect --disable-autodetect --target-os=linux --enable-pthreads --cc=gcc --host_cc=gcc --cxx=g&#x2B;&#x2B; --nm=nm --ar=&#x27;ar&#x27; --ranlib=ranlib --strip=strip --enable-gpl --enable-ffmpeg --disable-ffplay --disable-ffprobe --enable-avcodec --enable-avdevice --enable-avformat --enable-avfilter --enable-postproc --enable-swresample --enable-swscale --disable-alsa --disable-amf --disable-libaom --disable-libass --disable-avisynth --enable-bzlib --disable-libdav1d --disable-libfdk-aac --disable-libfontconfig --disable-libharfbuzz --disable-libfreetype --disable-libfribidi --disable-iconv --disable-libilbc --enable-lzma --disable-libmp3lame --disable-libmodplug --disable-cuda --disable-nvenc --disable-nvdec  --disable-cuvid --disable-ffnvcodec --disable-opencl --disable-opengl --disable-libopenh264 --disable-libopenjpeg --disable-libopenmpt --disable-openssl --disable-libopus --enable-sdl2 --disable-libsnappy --disable-libsoxr --disable-libspeex --disable-libssh --disable-libtensorflow --disable-libtesseract --disable-libtheora --disable-libvorbis --disable-libvpx --disable-libwebp --enable-libx264 --disable-libx265 --disable-libxml2 --enable-zlib --disable-libsrt --disable-libmfx --enable-cross-compile --pkg-config="/bin/pkg-config" --pkg-config-flags=--static&#xA;-- Building Release Options: --enable-optimizations --extra-ldflags=-L"/usr/local/src/cpp/cmq/build/vcpkg_installed/x64-linux-release/lib"&#xA;-- Building ffmpeg for Release&#xA;

    &#xA;

    $ ffmpeg -devices&#xA;ffmpeg version 7.0.2 Copyright (c) 2000-2024 the FFmpeg developers&#xA;  built with gcc 14.2.0 (GCC)&#xA;  configuration: --prefix=/usr/local/src/cpp/third-party/vcpkg/packages/ffmpeg_x64-linux-release --enable-pic --disable-doc --enable-debug --enable-runtime-cpudetect --disable-autodetect --target-os=linux --enable-pthreads --cc=gcc --host_cc=gcc --cxx=g&#x2B;&#x2B; --nm=nm --ar=ar --ranlib=ranlib --strip=strip --enable-gpl --enable-ffmpeg --disable-ffplay --disable-ffprobe --enable-avcodec --enable-avdevice --enable-avformat --enable-avfilter --enable-postproc --enable-swresample --enable-swscale --disable-alsa --disable-amf --disable-libaom --disable-libass --disable-avisynth --enable-bzlib --disable-libdav1d --disable-libfdk-aac --disable-libfontconfig --disable-libharfbuzz --disable-libfreetype --disable-libfribidi --disable-iconv --disable-libilbc --enable-lzma --disable-libmp3lame --disable-libmodplug --disable-cuda --disable-nvenc --disable-nvdec --disable-cuvid --disable-ffnvcodec --disable-opencl --disable-opengl --disable-libopenh264 --disable-libopenjpeg --disable-libopenmpt --disable-openssl --disable-libopus --disable-sdl2 --disable-libsnappy --disable-libsoxr --disable-libspeex --disable-libssh --disable-libtensorflow --disable-libtesseract --disable-libtheora --disable-libvorbis --disable-libvpx --disable-libwebp --enable-libx264 --disable-libx265 --disable-libxml2 --enable-zlib --disable-libsrt --disable-libmfx --enable-cross-compile --pkg-config=/bin/pkg-config --pkg-config-flags=--static --enable-optimizations --extra-ldflags=-L/usr/local/src/cpp/cmq/vcpkg_installed/x64-linux-release/lib --arch=x86_64 --enable-asm --enable-x86asm&#xA;  libavutil      59.  8.100 / 59.  8.100&#xA;  libavcodec     61.  3.100 / 61.  3.100&#xA;  libavformat    61.  1.100 / 61.  1.100&#xA;  libavdevice    61.  1.100 / 61.  1.100&#xA;  libavfilter    10.  1.100 / 10.  1.100&#xA;  libswscale      8.  1.100 /  8.  1.100&#xA;  libswresample   5.  1.100 /  5.  1.100&#xA;  libpostproc    58.  1.100 / 58.  1.100&#xA;Devices:&#xA; D. = Demuxing supported&#xA; .E = Muxing supported&#xA; ---&#xA; D  lavfi           Libavfilter virtual input device&#xA; DE oss             OSS (Open Sound System) playback&#xA;

    &#xA;

  • How to add subtitles using FFmpeg-kit ?

    17 novembre 2024, par Mohammed Bekele

    I'm running a Flutter app with Ffmpeg-kit package to burn a subtitle on a video. I have a words list with the timings and map that to generate an srt and ass file, but when executing this it didn't work.

    &#xA;

    Firstly, here is how I generated the Ass file.

    &#xA;

    Future<string> _createAssFile() async {&#xA;    String filePath = await getAssOutputFilePath();&#xA;&#xA;    final file = File(filePath);&#xA;    final buffer = StringBuffer();&#xA;&#xA;    // Write ASS headers&#xA;    buffer.writeln(&#x27;[Script Info]&#x27;);&#xA;    buffer.writeln(&#x27;Title: Generated ASS&#x27;);&#xA;    buffer.writeln(&#x27;ScriptType: v4.00&#x2B;&#x27;);&#xA;    buffer.writeln(&#x27;Collisions: Normal&#x27;);&#xA;    buffer.writeln(&#x27;PlayDepth: 0&#x27;);&#xA;    buffer.writeln(&#x27;Timer: 100,0000&#x27;);&#xA;    buffer.writeln(&#x27;[V4&#x2B; Styles]&#x27;);&#xA;    buffer.writeln(&#xA;        &#x27;Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding&#x27;);&#xA;    buffer.writeln(&#xA;        &#x27;Style: Default,Arial,40,&amp;H00FFFFFF,&amp;H000000FF,&amp;H00000000,&amp;H80000000,1,1,1,1,100,100,0,0,1,1,1,2,10,10,10,1&#x27;);&#xA;    buffer.writeln(&#x27;[Events]&#x27;);&#xA;    buffer.writeln(&#xA;        &#x27;Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text&#x27;);&#xA;&#xA;    // Write events (subtitles)&#xA;    for (int i = 0; i &lt; widget.words.length; i&#x2B;&#x2B;) {&#xA;      final word = widget.words[i];&#xA;      final startTime = _formatAssTime(word[&#x27;startTime&#x27;].toDouble());&#xA;      final endTime = _formatAssTime(word[&#x27;endTime&#x27;].toDouble());&#xA;      final text = word[&#x27;word&#x27;];&#xA;&#xA;      buffer.writeln(&#x27;Dialogue: 0,$startTime,$endTime,Default,,0,0,0,,$text&#x27;);&#xA;    }&#xA;&#xA;    await file.writeAsString(buffer.toString());&#xA;    return filePath;&#xA;  }&#xA;&#xA;  String _formatAssTime(double seconds) {&#xA;    final int hours = seconds ~/ 3600;&#xA;    final int minutes = ((seconds % 3600) ~/ 60);&#xA;    final int secs = (seconds % 60).toInt();&#xA;    final int millis = ((seconds - secs) * 1000).toInt() % 1000;&#xA;&#xA;    return &#x27;${hours.toString().padLeft(1, &#x27;0&#x27;)}:${minutes.toString().padLeft(2, &#x27;0&#x27;)}:${secs.toString().padLeft(2, &#x27;0&#x27;)}.${(millis ~/ 10).toString().padLeft(2, &#x27;0&#x27;)}&#x27;;&#xA;  }&#xA;</string>

    &#xA;

    Then I used this command which was the official way of adding ass file to a video.

    &#xA;

      String newCmd = "-i $videoPath -vf ass=$assFilePath -c:a copy $_outputPath";&#xA;

    &#xA;

    Yet when executing this command it did not work. However I changed it to this command

    &#xA;

    String newCmd = "-i $videoPath -i $assFilePath $_outputPath";&#xA;

    &#xA;

    Well, that code works but the styling is not being applied. So I tried yet another command to filter and position the ass file.

    &#xA;

    String newCmd = "-i $videoPath -i $assFilePath -filter_complex \"[0:v][1:s]ass=\\an5:text=&#x27;%{event.text}&#x27;,scale=iw*0.8:ih*0.8,setdar=16/9[outv]\" -map [outv] -c:a copy $_outputPath";&#xA;

    &#xA;

    This made it even worse, because the app crashed when I ran this. Also there is a log for this command before crashing

    &#xA;

    F/libc    (19624): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x19 in tid 21314 (pool-4-thread-7), pid 19624 (ple.caption_app)&#xA;*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***&#xA;Build fingerprint: &#x27;samsung/a15nsxx/a15:14/UP1A.231005.007/A155FXXU1AWKA:user/release-keys&#x27;&#xA;Revision: &#x27;5&#x27;&#xA;ABI: &#x27;arm64&#x27;&#xA;Processor: &#x27;7&#x27;&#xA;Timestamp: 2024-07-10 19:27:40.812476860&#x2B;0300&#xA;Process uptime: 1746s&#xA;Cmdline: com.example.caption_app&#xA;pid: 19624, tid: 21314, name: pool-4-thread-7  >>> com.example.caption_app &lt;&lt;&lt;&#xA;uid: 10377&#xA;tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)&#xA;signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000019&#xA;Cause: null pointer dereference&#xA;    x0  0000000000000001  x1  b400006ec98d8660  x2  0000000000000000  x3  0000000000000002&#xA;    x4  0000006f62d1ea12  x5  b400006e04f745ea  x6  352f35372f64352f  x7  7f7f7f7f7f7f7f7f&#xA;    x8  632ace36577a905e  x9  632ace36577a905e  x10 0000006e191378c0  x11 0000000000000001&#xA;    x12 0000000000000001  x13 0000000000000000  x14 0000000000000004  x15 0000000000000008&#xA;    x16 0000006e27ffa358  x17 0000006e27dbfb00  x18 0000006e00d48000  x19 0000006f62d1f0e8&#xA;    x20 0000006f62d24000  x21 0000006e27ffc5d0  x22 0000006e27ffc5f0  x23 0000000000000000&#xA;    x24 b400006f3f089248  x25 0000006f62d1f220  x26 b400006f3f057b20  x27 0000000000000002&#xA;    x28 0000000000000088  x29 0000006f62d1f100&#xA;    lr  0000006e27dbfb0c  sp  0000006f62d1f0a0  pc  0000006e27dbfb10  pst 0000000060001000&#xA;1 total frames&#xA;backtrace:&#xA;      #00 pc 0000000000121b10  /data/app/~~oWqjrGA2indQhuEw6u_J2A==/com.example.caption_app-u2Ofk54FVtMc5D-i3SLC6g==/base.apk!libavfilter.so (offset 0x10a46000) (avfilter_inout_free&#x2B;16)    &#xA;Lost connection to device.&#xA;

    &#xA;

    I tried the normal command in my local machine on Windows, and this is what I used

    &#xA;

    ffmpeg -i F:\ffmpeg\video.avi -vf subtitles=&#x27;F\:\\ffmpeg\\caption.srt&#x27;:force_style=&#x27;Fontsize=24&#x27; F:\ffmpeg\new.mp4&#xA;

    &#xA;

    As you can see above when subtitles are used it had an extra backslashes for each path and a pre backslash after the partition letter. But I don't know if this does apply for android devices. How can I make sense of this ?

    &#xA;