[FFmpeg-user] Adapting videos for -filter_complex concat

Donovan Watteau tsoomi at gmail.com
Fri Aug 24 13:50:23 CEST 2012

On Fri, 24 Aug 2012, Nicolas George wrote:
> The setsar has no effect there, as it is immediately overriden by setdar.
> There is always the following relation:
> 	DAR = SAR × IAR
> where IAR is the image aspect ratio, i.e. the ratio between the dimensions
> of the image in pixels. Filters that change one of these parameters must
> adapt the others accordingly, usually by keeping one of them constant and
> changing the other one. More specifically:
> * scale sets IAR, keeps DAR and adapts SAR;
> * pad and crop set IAR, keep SAR and adapt DAR;
> * setsar sets SAR, keeps IAR and adapts DAR;
> * setdar sets DAR, keeps IAR and adapts SAR.

Thank you for these explanations.  I was copying all the parameters I
could get to adapt my jingle to the video, but I didn't know that I 
had to omit DAR to keep the rescaling and SAR.  Now, I understand why.

> > Then I try to to concatenate the new jingle and the video this way:
> > /usr/local/bin/ffmpeg -threads 2 \
> >   -i adapted_jingle.mp4 -i clipcanvas_14348_H264_640x360.mp4 \
> >   -filter_complex concat final_video.mp4
> Also, since you are transcoding at this step, there is no need to adapt
> gizmo.mp4 first: just plug the scaling+padding line above in the
> -filter_complex graph.

Yes, thanks, that's what I will eventually do.  They were kept
separated to make things easier to check, for the moment.

> > But when I'm not having this problem, I see that the bitrates I gave
> > on the command line are not used.
> You did not show that.

Indeed, but anyway I don't think it's relevant anymore, see below.

> >				 They differ, and eventually the video
> > I'm creating has playing issues: when the jingle ends, the rest of
> > the video is played slower than it should be (MPlayer gives a "Too
> > many video packets in the buffer" warning at this moment).
> The command you showed concatenates the video but not the audio. Therefore,
> the resulting video will have less audio than video: mplayer does not like
> that.

I didn't realize that.  With "-filter_complex concat=n=2:v=1:a=1",
things seem to work.

> >						I also need the
> > bitrates to be the same, even if the _jingle_ is losing some quality.
> If you are transcoding the video, both will lose quality, that is
> inevitable. If you absolutely want to preserve the quality of the original
> video, you must concatenate without transcoding: remux it into a
> concatenable format, convert the jingle with EXACTLY the same parameters,
> concatenate the result and remux it into a more agreeable format.

Well, I was asking for the bitrates to be exactly the same because I
thought it was the reason why I was having problems playing the
resulting video with mplayer and ffplay.  But "-filter_complex
concat=n=2:v=1:a=1" seems to be the right fix.

Thank you very much!

More information about the ffmpeg-user mailing list