[FFmpeg-user] Adapting videos for -filter_complex concat

Nicolas George nicolas.george at normalesup.org
Fri Aug 24 11:22:50 CEST 2012


L'octidi 8 fructidor, an CCXX, Donovan Watteau a écrit :
> Here's how I adapt the jingle (see the attached adapted_jingle.log):
> /usr/local/bin/ffmpeg -threads 2 \
>   -i gizmo.mp4 \
>   -vf "scale=iw*min(640/iw\,360/ih):ih*min(640/iw\,360/ih),pad=640:360:(640-iw)/2:(360-ih)/2,setsar=255:254,setdar=680:381" \

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.

> 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.

> 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.

>				 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 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.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-user/attachments/20120824/9a660aaf/attachment.asc>


More information about the ffmpeg-user mailing list