[FFmpeg-user] How to offset clip position start along with audio?

Edin Mujagić edinmujagic2 at gmail.com
Sun Mar 15 23:39:40 CET 2015


Hi. I have color filter generated blank screen of 5mins. I want to offset
two or more input videos for some seconds and overlay them on top of
background. I have used color, setpts and overlay filter and it works for
video but audio does not move.

I assume I would need to use aevalsrc, asetpts and amerge to create audio
support but so far I haven't been able to do so.

Commands:
trailer.mp4 is video from: http://www.w3.org/2010/05/video/mediaevents.html
(uses two inputs, offsets one and overlays them - audio stays at 0 start):
ffmpeg \
    -i trailer.mp4 \
    -i trailer2.mp4 \
    -filter_complex '
    color=c=black,scale=w=640:h=480[bg];
    [1:v]setpts=PTS-STARTPTS+90/TB[v1];
    [bg][0:v]overlay[o1];
    [o1][v1]overlay[vout]
    ' -map 0:a -map "[vout]" -f mp4 -y -t 300 out.mp4

This overlays two input videos on start and +90 and copies audio from first
input.

I want to have first input audio on first second and second input audio
sync with video on +90 second.

If I try to use amerge:
ffmpeg \
    -i trailer.mp4 \
    -i trailer2.mp4 \
    -filter_complex '
    color=c=black,scale=w=640:h=480[bg];
    [1:v]setpts=PTS-STARTPTS+90/TB[v1];
    [bg][0:v]overlay[o1];
    [o1][v1]overlay[vout];
    aevalsrc=0:d=300[abase];
    [0:a]anull[a0];[a0]anullsink;
    [1:a]asetpts=PTS-STARTPTS+90/TB[a1];
    [abase][a0][a1]amerge=inputs=3[aout];
    [vout][aout]concat=n=1:v=1:a=1
    ' -ac 2 -y -t 300 out.mp4

If I loose -ac 2 then aac codec complains with: Error while opening encoder
for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate,
width or height.

With -ac 2 I get is buffer queue overflow, dropping. Which results in video
that is jerky and stalled. I haven't been able to isolate this behavior
since every filter in itself behaves normally (like asetpts), but issue
arise when I merge them with amerge (or amix).

Here is complete output:
ffmpeg version 2.5.4 Copyright (c) 2000-2015 the FFmpeg developers
  built on Mar 10 2015 00:59:38 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --enable-gpl --enable-ffplay --enable-version3
--enable-avisynth --enable-libass --enable-libx264 --enable-frei0r
--enable-gnutls --enable-libcaca --enable-libmodplug --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg
--enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr
--enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-aacenc --enable-libvorbis
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'trailer.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Sintel Trailer
    artist          : Durian Open Movie Team
    encoder         : Lavf56.15.102
    copyright       : (c) copyright Blender Foundation | durian.blender.org
    description     : Trailer for the Sintel open movie project
  Duration: 00:00:52.21, start: 0.012000, bitrate: 306 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
400x300, 174 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'trailer2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Sintel Trailer
    artist          : Durian Open Movie Team
    encoder         : Lavf56.15.102
    copyright       : (c) copyright Blender Foundation | durian.blender.org
    description     : Trailer for the Sintel open movie project
  Duration: 00:00:52.21, start: 0.012000, bitrate: 306 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
400x300, 174 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[Parsed_amerge_9 @ 0x3850ba0] No channel layout for input 2
[Parsed_amerge_9 @ 0x3850ba0] Input channel layouts overlap: output layout
will be determined by the number of distinct input channels
[libx264 @ 0x38d9540] using SAR=1/1
[libx264 @ 0x38d9540] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x38d9540] profile High, level 3.0
[libx264 @ 0x38d9540] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec
- Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1
ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00
mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11
fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2
sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0
constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1
weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40
intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0
qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Sintel Trailer
    artist          : Durian Open Movie Team
    description     : Trailer for the Sintel open movie project
    copyright       : (c) copyright Blender Foundation | durian.blender.org
    encoder         : Lavf56.15.102
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p,
640x480 [SAR 1:1 DAR 4:3], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc56.13.100 libx264
    Stream #0:1: Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100
Hz, stereo, s16, 128 kb/s (default)
    Metadata:
      encoder         : Lavc56.13.100 libvo_aacenc
Stream mapping:
  Stream #0:0 (h264) -> overlay:overlay
  Stream #0:1 (aac) -> anull
  Stream #0:1 (aac) -> amerge:in1
  Stream #1:0 (h264) -> setpts
  Stream #1:1 (aac) -> asetpts
  concat:out:v0 -> Stream #0:0 (libx264)
  concat:out:a0 -> Stream #0:1 (libvo_aacenc)
Press [q] to stop, [?] for help
[Parsed_overlay_4 @ 0x38ecd40] [framesync @ 0x384e808] Buffer queue
overflow, dropping.
    Last message repeated 59 times
[Parsed_overlay_4 @ 0x38ecd40] [framesync @ 0x384e808] Buffer queue
overflow, dropping.
    Last message repeated 122 times
[Parsed_overlay_4 @ 0x38ecd40] [framesync @ 0x384e808] Buffer queue
overflow, dropping.
    Last message repeated 150 times
[Parsed_overlay_4 @ 0x38ecd40] [framesync @ 0x384e808] Buffer queue
overflow, dropping.
    Last message repeated 130 times
[Parsed_overlay_4 @ 0x38ecd40] [framesync @ 0x384e808] Buffer queue
overflow, dropping.
    Last message repeated 2 times


More information about the ffmpeg-user mailing list