Recherche avancée

Médias (1)

Mot : - Tags -/intégration

Sur d’autres sites (352)

  • machine hangs during ffmpeg command execution [closed]

    15 décembre 2023, par Tejas

    I'm running this ffmpeg command that does multiple trims on input video and concats those trims to generate output.

    


    ffmpeg -i https://d8r14y803bnlk.cloudfront.net/usetldr/2736037/u/796/st/5a919413ff884892bbfffcd0671687a9/p/67c1a16438bf4bb78b785557f4cef7ef/OJx1SIKTNbbGHmQfKT4C_render.mp4 -filter_complex "[0:v:0]trim=start=0.0:end=4.289,setpts=PTS-STARTPTS,format=yuva420p[0v];[0:v:0]trim=start=4.84:end=1034.7,setpts=PTS-STARTPTS,format=yuva420p[1v];[0v][1v]concat=n=2:v=1:a=0" -crf 18 -an -preset ultrafast -y /tmp/8TZeqB3Z6h.mp4


    


    This command works fine on my M1 mac but hangs EC2 instances (c5.4xlarge).

    


    I'm using ffmpeg version 6.1-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2023 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) on EC2.

    


    Any idea why this could be happening ?

    


  • ffmpeg mp3 chunk to wav chunk adds gap in the start of the audio

    13 décembre 2023, par 1Mayur

    I have an mp3 streaming from a URL, I save the chunks in 1024 byes buffer size.
After I get all the chunks, I'm using ffmpeg to convert the incoming mp3 chunk (22050 mono) to a wav chunk.

    


    When I open/play the wav chunk I see that there is an empty gap at the start of every chunk.

    


    here is the code I'm running in Python subprocess in a loop for all the saved chunks

    


    subprocess.run(["ffmpeg", "-i",
    f"{Path.cwd()}/input/{path}",
    f"{Path.cwd()}/temp_output/{path.replace('.mp3', '')}.wav"
])


    


    here is the output in the terminal

    


    processing: test-016.mp3
ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers
  built with Apple clang version 15.0.0 (clang-1500.0.40.1)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/6.0_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-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
  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
[mp3 @ 0x7fd48e104480] Format mp3 detected only with low score of 25, misdetection possible!
[mp3 @ 0x7fd48e104480] Skipping 463 bytes of junk at 0.
[mp3 @ 0x7fd48e104480] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/Users/mayur/Projects/input/test-016.mp3':
  Duration: 00:00:00.39, start: 0.000000, bitrate: 169 kb/s
  Stream #0:0: Audio: mp3, 22050 Hz, mono, fltp, 160 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to '/Users/mayur/Projects/temp_output/test-016.wav':
  Metadata:
    ISFT            : Lavf60.3.100
  Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s
    Metadata:
      encoder         : Lavc60.3.100 pcm_s16le
size=      17kB time=00:00:00.36 bitrate= 379.7kbits/s speed= 253x    
video:0kB audio:17kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.451389%


    


    I tried the pydub as well and faced similar issue.

    


  • Attaching audio to video stream using ffmpeg

    5 novembre 2023, par lazarea

    My goal is to build a simple 10-second long video with a grey background, a simple text, and a simple mp3 audio to be played. I believe it should be a simple enough task ; yet, I am unable to get it right, as the audio is not attached to the video stream.

    


    My code is as follows :

    


    import subprocess
from pathlib import Path

folder_path = Path(__file__).parent.absolute()
assert folder_path / "i_have_a_cat.mp3"

ffmpeg_command = [
    'ffmpeg',
    '-y',  # Force override without prompting
    '-f', 'lavfi',
    '-i', 'color=c=gray:s=640x480:d=10',
    '-i', str(folder_path / 'i_have_a_cat.mp3'),
    '-vf', 'drawtext=text=\'I have a cat\':fontsize=24:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/3*2:enable=\'between(t,2,5)\'',
    '-t', '10',
    str(folder_path / 'output.mp4')
]

subprocess.run(ffmpeg_command)


    


    Checking the ffmpeg logs, I don't see anything extraordinary but I'll paste them here nevertheless because I might be overlooking something.

    


    Input #0, lavfi, from 'color=c=gray:s=640x480:d=10':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc

[mp3 @ 000001d271db1140] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from 'c:\Users\myfolder\ffmpeg_poc\i_have_a_cat.mp3':
  Metadata:
    encoder         : Lavf58.76.100
  Duration: 00:00:00.86, start: 0.000000, bitrate: 48 kb/s
    Stream #1:0: Audio: mp3, 22050 Hz, mono, fltp, 48 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (mp3 (mp3float) -> aac (native))


    


    Output #0, mp4, to 'c:\Users\myfolder\ffmpeg_poc\output.mp4':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 25 fps, 12800 tbn, 25 tbc     
    Metadata:
      encoder         : Lavc58.54.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 69 kb/s
    Metadata:
      encoder         : Lavc58.54.100 aac
[Parsed_color_0 @ 000001d271c6b040] EOF timestamp not reliable
frame=  250 fps=0.0 q=-1.0 Lsize=      24kB time=00:00:09.88 bitrate=  19.9kbits/s speed=31.3x    
video:7kB audio:12kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 23.716467%
[libx264 @ 000001d271d058c0] frame I:1     Avg QP: 9.00  size:   104
[libx264 @ 000001d271d058c0] frame P:63    Avg QP: 9.21  size:    41
[libx264 @ 000001d271d058c0] frame B:186   Avg QP:12.67  size:    21
[libx264 @ 000001d271d058c0] consecutive B-frames:  0.8%  0.0%  0.0% 99.2%
[libx264 @ 000001d271d058c0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 000001d271d058c0] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
[libx264 @ 000001d271d058c0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct: 0.0%  skip:100.0%  L0:50.0% L1:50.0% BI: 0.0%      
[libx264 @ 000001d271d058c0] 8x8 transform intra:0.0%
[libx264 @ 000001d271d058c0] coded y,uvDC,uvAC intra: 0.7% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 000001d271d058c0] i16 v,h,dc,p: 97%  0%  3%  0%
[libx264 @ 000001d271d058c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 58% 10% 17%  2%  4%  2%  2%  2%  2%
[libx264 @ 000001d271d058c0] i8c dc,h,v,p: 100%  0%  0%  0%
[libx264 @ 000001d271d058c0] Weighted P-Frames: Y:1.6% UV:0.0%
[libx264 @ 000001d271d058c0] kb/s:5.26
[aac @ 000001d271d071c0] Qavg: 24689.965


    


    Edit

    


    The output of ffprobe -i output.mp4 is as follows :

    


    ffprobe version 6.0-essentials_build-www.gyan.dev Copyright (c) 2007-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth 
--enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  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 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:04.00, start: 0.000000, bitrate: 37 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], 6 kb/s, 25 fps, 25 tbr, 12800 tbn 
(default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 111 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]