Recherche avancée

Médias (33)

Mot : - Tags -/creative commons

Sur d’autres sites (351)

  • input/output error with ffmpeg using an input URL in docker

    12 décembre 2023, par Grimou

    I need to use ffmpeg to listen to an rtmp url within a running docker container using ffmpeg.
my ffmpeg command is quite simple : ffmpeg -listen 1 -i rtmp://localhost:1935/live/app ./output.wav

    


    ffmpeg seems to start correctly and listen to the url.

    


    But, when I start the stream (using OBS Studio) I have an input/output error. Here is the logs (with debug log level)

    


    ❯ ffmpeg -loglevel debug -listen 1 -i rtmp://127.0.0.1:1935/live/app ./output.wav
ffmpeg version 5.1.4-0+deb12u1 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr --extra-version=0+deb12u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-listen' ... matched as AVOption 'listen' with argument '1'.
Reading option '-i' ... matched as input url with argument 'rtmp://127.0.0.1:1935/live/app'.
Reading option './output.wav' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url rtmp://127.0.0.1:1935/live/app.
Successfully parsed a group of options.
Opening an input file: rtmp://127.0.0.1:1935/live/app.
[NULL @ 0x56288f8e7a00] Opening 'rtmp://127.0.0.1:1935/live/app' for reading
[rtmp @ 0x56288f8e8200] No default whitelist set
[tcp @ 0x56288f8e8d40] No default whitelist set
[rtmp @ 0x56288f8e8200] Proto = rtmp, path = /live/app, app = live, fname = app
[rtmp @ 0x56288f8e8200] New incoming chunk size = 4096
rtmp://127.0.0.1:1935/live/app: Input/output error


    


    The last 3 lines only appear when I start the stream.

    


    It doesn't seems to be a permission problem with the file system, since using ffmpeg -i ./test.mp4 ./output.wav works inside the container.

    


    I also did not find any problem with the network. I am currently using network_mode: "host" in my docker_compose.yml and the logs show that it did receive data before the error appear.

    


    It also doesn't seem to be a problem with the ffmpeg command, since the exact same command works when using it without docker involved.

    


    What else could be the problem ?

    


    here is my docker_compose.yml

    


    version: '3'

services:
  ffmpeg-container:
    build:
      context: .
    network_mode: "host"
    tty: true  # Allocate a pseudo-TTY for interactive use



    


    Dockerfile

    


    FROM python:3

# Install ffmpeg
RUN apt-get update && apt-get install -y ffmpeg

# Create a working directory
WORKDIR app

# Copy the Python script to the container
COPY app.py .
COPY test.mp4 .

# Run the Python script
CMD ["python", "app.py"]



    


  • Latest FFmpeg fails to create a good MP4 out of JPG file (Windows 10)

    30 décembre 2023, par mengrie

    I am using FFmpeg to create an MP4 file out of several JPG files. The command to accomplish this

    


    ffmpeg.exe ^
-hide_banner -nostats -loglevel error -y ^
-loop 1 -t 6 -i 001.jpg ^
-loop 1 -t 6 -i 002.jpg ^
-loop 1 -t 6 -i 003.jpg ^
-loop 1 -t 6 -i 004.jpg ^
-loop 1 -t 6 -i 005.jpg ^
-loop 1 -t 6 -i 006.jpg ^
-filter_complex ^
"[0:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=out:st=5:d=1[v0]; ^
[1:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1[v1]; ^
[2:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1[v2]; ^
[3:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1[v3]; ^
[4:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1[v4]; ^
[5:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=5:d=1[v5]; ^
[v0][v1][v2][v3][v4][v5]concat=n=6:v=1:a=0,format=yuv420p[v]" -map "[v]" -r 30 006.mp4


    


    Using "ffmpeg version 2022-12-25-git-eeb280f351-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers built with gcc 12.1.0 (Rev2, Built by MSYS2 project)" does the job as expected.

    


    However, yesterdag I downloaded (from gyan.dev - Windows - ffmpeg-git-full.7z) the latest version and upgrade the tool. "ffmpeg version 2023-12-28-git-c1340f3439-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers built with gcc 12.2.0 (Rev10, Built by MSYS2 project)"

    


    Using this version, the MP4 contains only a few JPGs and timing is also messed up, resulting in a useless MP4.

    


    Has something changed or are these parameters causing a new behaviour ?

    


    Thx

    


    In meanwhile I went back to older version

    


  • Cutting and rejoining videos causes audio de-synchronization using ffmpeg [closed]

    10 décembre 2023, par Donotalo

    This is the original post. I'm not getting any answer there so I thought may be the programming community knows the answer.

    


    Main Post

    


    I'm trying to cut a video into pieces and rejoin them using ffmpeg on Windows 11 x64. Here's the details of ffmpeg :

    


    ffmpeg version 2023-11-22-git-0008e1c5d5-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads
--disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp
--enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt
--enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2
--enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d
--enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx
--enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi
--enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg
--enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc
--enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo
--enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt
--enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame
--enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb
--enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite
--enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      58. 32.100 / 58. 32.100
  libavcodec     60. 34.100 / 60. 34.100
  libavformat    60. 17.100 / 60. 17.100
  libavdevice    60.  4.100 / 60.  4.100
  libavfilter     9. 13.100 /  9. 13.100
  libswscale      7.  6.100 /  7.  6.100
  libswresample   4. 13.100 /  4. 13.100
  libpostproc    57.  4.100 / 57.  4.100


    


    I've a video file in MKV format. I've cut it into 3 pieces using the following command :

    


    ffmpeg.exe -ss 0:0:0 -i input.mkv -t 0:54:15 -c:v hevc_amf -b:v 3M -c:s mov_text seg-01.mp4
ffmpeg.exe -ss 0:54:29 -i input.mkv -t 0:35:35 -c:v hevc_amf -b:v 3M -c:s mov_text seg-02.mp4
ffmpeg.exe -ss 1:30:12 -i input.mkv -t 0:4:10 -c:v hevc_amf -b:v 3M -c:s mov_text seg-03.mp4


    


    The audio is copied in all 3 pieces like original. Now I'm joining them using the following command :

    


    ffmpeg.exe -y -f concat -safe 0 -i .\join.txt -c:v hevc_amf -c:a copy -c:s copy -fflags +genpts out.mp4


    


    where, join.txt is :

    


    file seg-01.mp4
file seg-02.mp4
file seg-03.mp4


    


    ffmpeg throws the following warning :

    


    [mp4 @ 000002a5cf9cc040] Non-monotonic DTS in output stream 0:1; previous: 156240896, current: 156240084; changing to 156240897.
This may result in incorrect timestamps in the output file.
[mp4 @ 000002a5cf9cc040] Non-monotonic DTS in output stream 0:1; previous: 258720980, current: 258720462; changing to 258720981.
This may result in incorrect timestamps in the output file.


    


    I've observed that audio is de-synchronized after the places where I cut.

    


    How to keep audio, video and subtitle synchronized after cutting and rejoining the video using ffmpeg ?