Recherche avancée

Médias (29)

Mot : - Tags -/Musique

Sur d’autres sites (114)

  • FFMPEG - Pipe Different HLS Resolutions to S3

    17 juillet 2019, par Mike

    I’m trying to save all my HLS output files directly to S3. As you can see in the code, I’m saving output files for many different sizes and bitrates. My issue is I can’t figure out how to save the files onto S3. I have managed to get this working on an EC2 instance where I save all the files on the same server, but once I try to use aws cli it fails. I can also get this working if it’s just one resolution.

    I’m guessing it has something to do with piping multiple aws cli commands since I can see it tells me Unknown options:, but I don’t see any other way of doing this.

    Also, I’m using the -progress flag so I can show the transcode progress to the user, can I pipe that directly to S3 as-well ?

    Note, the code below has been formatted to make it readable, it obviously doesn’t look like this when ran on the server.

    FFMPEG Command

    ffmpeg
    -hide_banner -y
    -i https://my-bucket.s3.us-west-1.amazonaws.com/in.mp4
    -progress https://mybucket.s3.us-west-1.amazonaws.com/progress.log
    -c:a aac
    -c:v libx264
    -f mp4
    -profile:v high
    -level:v 4.0
    -crf 20
    -sc_threshold 0
    -flags +cgop
    -movflags frag_keyframe+faststart
    -pix_fmt yuv420p
    -preset ultrafast
    -g 100
    -keyint_min 100
    -hls_time 5000
    -hls_playlist_type vod

    -vf scale='trunc(oh*a/2)*2:288'
    -b:v 600k
    -maxrate 642k
    -bufsize 900k
    -b:a 64k
    -hls_segment_filename https://my-bucket.s3.us-west-1.amazonaws.com/288p_600k_%03d.ts
    pipe:1 | aws s3 cp - s3://my-bucket/288p_600k.m3u8

    -vf scale='trunc(oh*a/2)*2:360'
    -b:v 900k
    -maxrate 963k
    -bufsize 1350k
    -b:a 96k
    -hls_segment_filename https://my-bucket.s3.us-west-1.amazonaws.com/360p_900k_%03d.ts
    pipe:1 | aws s3 cp - s3://my-bucket/360p_900k.m3u8

    -vf scale='trunc(oh*a/2)*2:432'
    -b:v 1600k
    -maxrate 1712k
    -bufsize 2400k
    -b:a 128k
    -hls_segment_filename https://my-bucket.s3.us-west-1.amazonaws.com/432p_1600k_%03d.ts
    pipe:1 | aws s3 cp - s3://my-bucket/432p_1600k.m3u8

    -vf scale='trunc(oh*a/2)*2:720'
    -b:v 3200k
    -maxrate 3424k
    -bufsize 4800k
    -b:a 128k
    -hls_segment_filename https://my-bucket.s3.us-west-1.amazonaws.com/720p_3200k_%03d.ts
    pipe:1 | aws s3 cp - s3://my-bucket/720p_3200k.m3u8

    -vf scale='trunc(oh*a/2)*2:1080'
    -b:v 5300k
    -maxrate 5671k
    -bufsize 7950k
    -b:a 192k
    -hls_segment_filename https://my-bucket.s3.us-west-1.amazonaws.com/1080p_5300k_%03d.ts
    pipe:1 | aws s3 cp - s3://my-bucket/1080p_5300k.m3u8

    Error Message

    Exit Code: 1(General error)
    Working directory: /home/backend/public
    Output:
    ================
    Error Output:
    ================
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'https://my-bucket.s3.us-west-1.amazonaws.com/in.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       creation_time   : 1970-01-01T00:00:00.000000Z
       encoder         : Lavf53.24.2
    Duration: 00:00:05.31, start: 0.000000, bitrate: 1589 kb/s
     Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1205 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
     Metadata:
       creation_time   : 1970-01-01T00:00:00.000000Z
       handler_name    : VideoHandler
     Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 384 kb/s (default)
     Metadata:
       creation_time   : 1970-01-01T00:00:00.000000Z
       handler_name    : SoundHandler
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
     Stream #0:1 -> #0:1 (aac (native) -> aac (native))
    Press [q] to stop, [?] for help
    [libx264 @ 0x55ba09a95300] using SAR=1/1
    [libx264 @ 0x55ba09a95300] using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX
    [libx264 @ 0x55ba09a95300] profile Constrained Baseline, level 4.0
    [libx264 @ 0x55ba09a95300] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=100 keyint_min=51 scenecut=0 intra_refresh=0 rc_lookahead=0 rc=crf mbtree=0 crf=20.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=642 vbv_bufsize=900 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=0
    Output #0, mp4, to 'pipe:':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.83.100
       Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 512x288 [SAR 1:1 DAR 16:9], q=-1--1, 600 kb/s, 25 fps, 12800 tbn, 25 tbc (default)
       Metadata:
         creation_time   : 1970-01-01T00:00:00.000000Z
         handler_name    : VideoHandler
         encoder         : Lavc57.107.100 libx264
       Side data:
         cpb: bitrate max/min/avg: 642000/0/600000 buffer size: 900000 vbv_delay: -1
       Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 64 kb/s (default)
       Metadata:
         creation_time   : 1970-01-01T00:00:00.000000Z
         handler_name    : SoundHandler
         encoder         : Lavc57.107.100 aac
    frame=   27 fps=0.0 q=28.0 size=       0kB time=00:00:01.13 bitrate=  
    0.3kbits/s speed=2.21x
    Unknown options: -vf,scale=trunc(oh*a/2)*2:360,-b:v,900k,-maxrate,963k,-bufsize,1350k,-b:a,96k,-hls_segment_filename,https://my-bucket.s3.us-west-1.amazonaws.com/360p_900k_%03d.ts,-

    Unknown options: -vf,scale=trunc(oh*a/2)*2:432,-b:v,1600k,-maxrate,1712k,-bufsize,2400k,-b:a,128k,-hls_segment_filename,https://my-bucket.s3.us-west-1.amazonaws.com/432p_1600k_%03d.ts,-

    Unknown options: -vf,scale=trunc(oh*a/2)*2:720,-b:v,3200k,-maxrate,3424k,-bufsize,4800k,-b:a,128k,-hls_segment_filename,https://my-bucket.s3.us-west-1.amazonaws.com/720p_3200k_%03d.ts,-

    Unknown options: -vf,scale=trunc(oh*a/2)*2:1080,-b:v,5300k,-maxrate,5671k,-bufsize,7950k,-b:a,192k,-hls_segment_filename,https://my-bucket.s3.us-west-1.amazonaws.com/1080p_5300k_%03d.ts,-
    upload failed: - to s3://my-bucket/1080p_5300k.m3u8 seek() takes 2 positional arguments but 3 were given
    av_interleaved_write_frame(): Broken pipe
    Error writing trailer of pipe:: Broken pipe
    frame=  105 fps=104 q=27.0 Lsize=       0kB time=00:00:04.26 bitrate=  
    0.1kbits/s speed=4.24x
    video:405kB audio:36kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
    [libx264 @ 0x55ba09a95300] frame I:2     Avg QP:27.31  size: 31711
    [libx264 @ 0x55ba09a95300] frame P:103   Avg QP:29.12  size:  3522
    [libx264 @ 0x55ba09a95300] mb I  I16..4: 100.0%  0.0%  0.0%
    [libx264 @ 0x55ba09a95300] mb P  I16..4:  0.8%  0.0%  0.0%  P16..4: 58.1%  
    0.0%  0.0%  0.0%  0.0%    skip:41.2%
    [libx264 @ 0x55ba09a95300] coded y,uvDC,uvAC intra: 71.6% 66.1% 45.5%
    inter: 29.8% 10.3% 1.5%
    [libx264 @ 0x55ba09a95300] i16 v,h,dc,p: 16% 26% 35% 23%
    [libx264 @ 0x55ba09a95300] i8c dc,h,v,p: 47% 22% 20% 11%
    [libx264 @ 0x55ba09a95300] kb/s:811.77
    [aac @ 0x55ba09e26c60] Qavg: 88.610
    Conversion failed!
  • Mix additional audio file with video(+audio) in ffmpeg

    21 mai 2019, par Serg

    I’m trying to mix additional audio file with video which has also audio within. But the problem is that I already have complex ffmpeg command and don’t know how to combine them together.

    This is my existing ffmpeg command which uses some offsets and replaces additional audio file with embedded one (audio inside video) and also overlays few gauges and watermark to the video.

    ffmpeg -y
    -ss 00:00:01:213 -i videoFile.mp4
    -ss 00:00:03:435 -i audioFile.wav
    -i watermark.png
    -framerate 6 -i gauge1_path/img-%04d.png
    -framerate 1 -i gauge2_path/img-%04d.png
    -framerate 2 -i gauge3_path/img-%04d.png
    -framerate 2 -i gauge4_path/img-%04d.png
    -framerate 2 -i gauge5_path/img-%04d.png
    -framerate 2 -i gauge6_path/img-%04d.png
    -filter_complex [0][2]overlay=(21):(H-h-21)[ovr0];
    [ovr0][3]overlay=(W-w-21):(H-h-21)[ovr1];
    [ovr1][4]overlay=(W-w-21):(H-h-333)[ovr2];
    [ovr2][5]overlay=(W-w-21):(H-h-418)[ovr3];
    [ovr3][6]overlay=(W-w-21):(H-h-503)[ovr4];
    [ovr4][7]overlay=(W-w-21):(H-h-588)[ovr5];
    [ovr5][8]overlay=(W-w-21):(H-h-673)
    -map 0:v -map 1:a -c:v libx264 -preset ultrafast -crf 23 -t 00:5:10:000 output.mp4

    Now I would like to use ffmpeg's amix in order to mix both audios instead of replacing them, if possible with ability to set volumes. But official documentation amix says nothing about volume.

    Separately both seems to work ok.

    ffmpeg -y -i video.mp4 -i audio.mp3 -filter_complex [0][1]amix=inputs=2[a] -map 0:v -map [a] -c:v copy output.mp4

    and

    ffmpeg -y -i video.mp4 -i audio.mp3 -i watermark.png -filter_complex [0][2]overlay=(21):(H-h-21)[ovr0] -map [ovr0]:v -map 1:a -c:v libx264 -preset ultrafast -crf 23 output.mp4

    but together

    ffmpeg -y -i video.mp4 -i audio.mp3 -i watermark.png -filter_complex [0][1]amix=inputs=2[a];[a][2]overlay=(21):(H-h-21)[ovr0] -map [ovr0]:v -map [a] -c:v libx264 -preset ultrafast -crf 23 output.mp4

    I’m getting an error :

    ffmpeg version N-93886-gfbdb3aa179 Copyright (c) 2000-2019 the FFmpeg developers
     built with gcc 8.3.1 (GCC) 20190414
     configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
     libavutil      56. 28.100 / 56. 28.100
     libavcodec     58. 52.101 / 58. 52.101
     libavformat    58. 27.103 / 58. 27.103
     libavdevice    58.  7.100 / 58.  7.100
     libavfilter     7. 53.101 /  7. 53.101
     libswscale      5.  4.101 /  5.  4.101
     libswresample   3.  4.100 /  3.  4.100
     libpostproc    55.  4.100 / 55.  4.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       creation_time   : 1970-01-01T00:00:00.000000Z
       encoder         : Lavf53.24.2
     Duration: 00:00:29.57, start: 0.000000, bitrate: 1421 kb/s
       Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1032 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
       Metadata:
         creation_time   : 1970-01-01T00:00:00.000000Z
         handler_name    : VideoHandler
       Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)
       Metadata:
         creation_time   : 1970-01-01T00:00:00.000000Z
         handler_name    : SoundHandler
    [mp3 @ 0000015e2f934ec0] Estimating duration from bitrate, this may be inaccurate
    Input #1, mp3, from 'audio.mp3':
     Duration: 00:00:45.33, start: 0.000000, bitrate: 128 kb/s
       Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
    Input #2, png_pipe, from 'watermark.png':
     Duration: N/A, bitrate: N/A
       Stream #2:0: Video: png, rgb24(pc), 100x56 [SAR 3779:3779 DAR 25:14], 25 tbr, 25 tbn, 25 tbc
    [Parsed_amix_0 @ 0000015e2ff2e940] Media type mismatch between the 'Parsed_amix_0' filter output pad 0 (audio) and the 'Parsed_overlay_1' filter input pad 0 (video)
    [AVFilterGraph @ 0000015e2f91c600] Cannot create the link amix:0 -> overlay:0
    Error initializing complex filters.
    Invalid argument

    So my question : whether it’s possible to combine amix and overlay together and how and in which order they should be used ? Or should I look something different because amix unable to set volume levels ?

    Thanks in advance !

  • Could not find codec parameters for stream 0

    14 février 2021, par khinester

    When I run this command :

    



    ffmpeg -y -i ./in.mp4 -c:v png -f image2pipe -thread_queue_size 1024 -r 25 -t 186.75 -i - -filter_complex overlay=0:0 -c:v libx264 -pix_fmt yuv420p -movflags +faststart ./out.mp4 < ./out.png


    



    I get an error :

    



    (git)-[master] 
ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwbenc
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './in.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.99.1
  Duration: 00:03:06.75, start: 0.000000, bitrate: 538 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x320 [SAR 1:1 DAR 3:2], 465 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 67 kb/s (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : SoundHandler
[image2pipe @ 0x15f7200] Could not find codec parameters for stream 0 (Video: png, none(pc)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
pipe:: could not find codec parameters
Input #1, image2pipe, from 'pipe:':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, none(pc), 25 tbr, 25 tbn, 25 tbc
[buffer @ 0x15e2620] Unable to parse option value "0x0" as image size
[buffer @ 0x15e2620] Unable to parse option value "-1" as pixel format
[buffer @ 0x15e2620] Unable to parse option value "0x0" as image size
[buffer @ 0x15e2620] Error setting option video_size to value 0x0.
[graph 0 input from stream 1:0 @ 0x15e23e0] Error applying options to the filter.
Error configuring complex filters.
Invalid argument

Consider increasing the value for the 'analyzeduration' and 'probesize' options pipe:0: could not find codec parameters


    



    What am I missing in my setup ?