Recherche avancée

Médias (91)

Sur d’autres sites (333)

  • Cutting sections with -ss and -t is not frame accurate

    16 avril, par Théo Champion

    I'm using ffmpeg 6.0 to extract small sections from longer videos. According to the doc i can use the -ss option to specify the start time and the -t option to specify the duration and this should result in frame accurate cuts (since FFmpeg 2.1).

    


    However, in my testing i found that the cuts are not frame accurate. I'm using the following command :

    


    ffmpeg -ss 10 -i ffmpeg -ss 10 -i https://storage.googleapis.com/klap-assets/Frame%20Counter%20%5B4K%2C%2060%20FPS%5D%20%E2%80%93%200100.mp4   -t 10 -y -vcodec libx264 -acodec aac -movflags +faststart out2.mp4   -t 10 -y -vcodec libx264 -acodec aac -movflags +faststart out.mp4


    


    This result in a video that start at 9:57 (-2 frames) and ends at 19:57 (-2 frames) instead of 10:00 and 20:00.

    


    Also weird is that ffprobe on the resulting video show its duration being exactly 10 seconds.

    


    FFprobe of the resulting video :

    


    ffprobe version 6.0 Copyright (c) 2007-2023 the FFmpeg developers
  built with Apple clang version 14.0.0 (clang-1400.0.29.202)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.0 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --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-neon
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf60.3.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 303 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 287 kb/s, 60 fps, 60 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
      vendor_id       : [0][0][0][0]
      encoder         : Lavc60.3.100 libx264
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
      vendor_id       : [0][0][0][0]


    


    I've done some testing with other videos and results are never totally frame accurate.

    


    What am i missing here ? How can i get frame accurate cuts with FFmpeg ?

    


  • How do I stream audio from a mic in a raspberry pi with FFmpeg ?

    23 mars, par Ignacio

    I'm trying to follow this to stream audio from a mic in my raspberry pi.

    


    ignacio@pi-satellite-bigbedroom:~ $ ffmpeg -re -f pulse -ac 1 -i plughw:CARD=seeed2micvoicec,DEV=0 -f rtsp -rtsp_transport tcp rtsp://192.168.86.151:8554/live.stream
ffmpeg version 4.3.6-0+deb11u1+rpt5 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-6)
  configuration: --prefix=/usr --extra-version=0+deb11u1+rpt5 --toolchain=hardened --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --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-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-mmal --enable-neon --enable-v4l2-request --enable-libudev --enable-epoxy --enable-sand --libdir=/usr/lib/aarch64-linux-gnu --arch=arm64 --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
plughw:CARD=seeed2micvoicec,DEV=0: No such process


    


    I believe this shows the cards I have :

    


    ignacio@pi-satellite-bigbedroom:~ $ pactl list sources
Source #0
    State: SUSPENDED
    Name: alsa_output.platform-bcm2835_audio.analog-stereo.monitor
    Description: Monitor of Built-in Audio Analog Stereo
    Driver: module-alsa-card.c
    Sample Specification: s16le 2ch 44100Hz
    Channel Map: front-left,front-right
    Owner Module: 4
    Mute: no
    Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
            balance 0.00
    Base Volume: 65536 / 100% / 0.00 dB
    Monitor of Sink: alsa_output.platform-bcm2835_audio.analog-stereo
    Latency: 0 usec, configured 0 usec
    Flags: DECIBEL_VOLUME LATENCY 
    Properties:
        device.description = "Monitor of Built-in Audio Analog Stereo"
        device.class = "monitor"
        alsa.card = "0"
        alsa.card_name = "bcm2835 Headphones"
        alsa.long_card_name = "bcm2835 Headphones"
        alsa.driver_name = "snd_bcm2835"
        device.bus_path = "platform-bcm2835_audio"
        sysfs.path = "/devices/platform/soc/3f00b840.mailbox/bcm2835_audio/sound/card0"
        device.form_factor = "internal"
        device.string = "0"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card"
    Formats:
        pcm

Source #1
    State: IDLE
    Name: alsa_output.platform-soc_sound.stereo-fallback.monitor
    Description: Monitor of Built-in Audio Stereo
    Driver: module-alsa-card.c
    Sample Specification: s16le 2ch 44100Hz
    Channel Map: front-left,front-right
    Owner Module: 12
    Mute: no
    Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
            balance 0.00
    Base Volume: 65536 / 100% / 0.00 dB
    Monitor of Sink: alsa_output.platform-soc_sound.stereo-fallback
    Latency: 0 usec, configured 2000000 usec
    Flags: DECIBEL_VOLUME LATENCY 
    Properties:
        device.description = "Monitor of Built-in Audio Stereo"
        device.class = "monitor"
        alsa.card = "2"
        alsa.card_name = "seeed-2mic-voicecard"
        alsa.long_card_name = "seeed-2mic-voicecard"
        alsa.driver_name = "snd_soc_simple_card"
        device.bus_path = "platform-soc:sound"
        sysfs.path = "/devices/platform/soc/soc:sound/sound/card2"
        device.form_factor = "internal"
        device.string = "2"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card"
    Formats:
        pcm

Source #2
    State: RUNNING
    Name: alsa_input.platform-soc_sound.stereo-fallback
    Description: Built-in Audio Stereo
    Driver: module-alsa-card.c
    Sample Specification: s16le 2ch 44100Hz
    Channel Map: front-left,front-right
    Owner Module: 12
    Mute: no
    Volume: front-left: 32845 /  50% / -18.00 dB,   front-right: 32845 /  50% / -18.00 dB
            balance 0.00
    Base Volume: 20724 /  32% / -30.00 dB
    Monitor of Sink: n/a
    Latency: 688 usec, configured 10000 usec
    Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
    Properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "bcm2835-i2s-wm8960-hifi wm8960-hifi-0"
        alsa.id = "bcm2835-i2s-wm8960-hifi wm8960-hifi-0"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "2"
        alsa.card_name = "seeed-2mic-voicecard"
        alsa.long_card_name = "seeed-2mic-voicecard"
        alsa.driver_name = "snd_soc_simple_card"
        device.bus_path = "platform-soc:sound"
        sysfs.path = "/devices/platform/soc/soc:sound/sound/card2"
        device.form_factor = "internal"
        device.string = "hw:2"
        device.buffering.buffer_size = "352800"
        device.buffering.fragment_size = "176400"
        device.access_mode = "mmap+timer"
        device.profile.name = "stereo-fallback"
        device.profile.description = "Stereo"
        device.description = "Built-in Audio Stereo"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card"
    Ports:
        analog-input: Analog Input (type: Analog, priority: 10000, availability unknown)
    Active Port: analog-input
    Formats:
        pcm


    


    I want to use the mic from the seeed-2mic-voicecard.

    


    Thanks for the help

    


  • FFMPEG : how to create a "title slide" for 3 seconds before a video [closed]

    15 mars, par ashay

    I'm trying to make a lecture video to put online. I have the video itself, and I have a title slide that I'd like to play for 3 seconds before the main video.

    


    I tried using ffmpeg to (1) create a 3 second long video from the title slide and (2) concat the two videos together.

    


    I'm having issues concatenating the videos together — when I do so, the resulting video is much longer than it should be. When I look online, others have similar problems — and this seems to occur when the parameters of the two videos do not match perfectly.

    


    I'd prefer to do this without re-encoding the main video — and it seems this should be possible because I should be able to control what parameters are set for the "lecture slide video".

    


    Here are the commands I've run.
The main video has framerate 25, resolution 1920x1080, and an audio stream at #0:0 and a video stream at #0:1 (according to ffmpeg -i [video].

    


    To create the video of the title slide, I ran ffmpeg -framerate 25 -i lec01_title.png -t 3 -c:v libx264 -x265-params lossless=1 -pix_fmt yuvj420p -vf scale=1920:1080 lec01_title.mp4 -f lavfi -i anullsrc -c:a aac -shortest.
Then to reorder the streams to match the main video, I ran ffmpeg -i lec01_title.mp4 -map 0:a -map 0:v -c:v copy -c:a copy lec01_title_matched.mp4.

    


    Then to concatenate the two files together, I created a text file "concat_list" with :
file 'lec01_title_matched.mp4' file 'lec01.mp4', and ran the command ffmpeg -f concat -safe 0 -i concat_list.txt -c copy -movflags +faststart output.mp4.

    


    The main video is 53 minutes long, but the final output video after concatenating is 1 hour and 43 minutes long.

    


    I'm looking for advice for how to create the "lecture title video" properly to match the parameters of the second video so that I can concatenate them without problems.

    


    Here's the output of ffmpeg -i lec01.mp4 :

    


    ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
  built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.1.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-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      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'dcai_lec01.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : 2-190-wideshot
    encoder         : Lavf60.16.100
  Duration: 00:47:39.08, start: 0.000000, bitrate: 1435 kb/s
  Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 96000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 1298 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc60.31.102 libx264


    


    Described above in detail.