I know about the -c copy switch with ffmpeg, but this does not work with filters as it means "don't re-encode". But what I want is to have my output use the same stream formats as my input. So if I scale and remux some file "input.avi" at 1920x1080 to "output.mp4" at 1280x720 I want the video and audio streams to be in the same format (i.e. re-encoding is OK but don't use a different codec).

Currently I need to specifically choose the codecs otherwise ffmpeg will use some default codecs based on the container--not based on my input formats. Is there any switch for this?

Note that I want to retain the formats, the specific encoder is not really important. E.g. As long as I can get H264 I don't care if it uses libx264 or some other 'competitor'.

On a side note, does ffmpeg has a command to list the defaults per container, or is it only available in external documentation?

  • 1) Not all containers support the same codecs. In your example, you posit a AVI -> MP4 remux. Well, MP4 spec doesn't support PCM audio, so a source AVI with that audio codec will fail encode to a MP4.
    – Gyan
    Dec 10, 2015 at 5:51
  • 2) FFmpeg doesn't include a corresponding encoder for each codec decoder it has, so some streams it can read but not write. Again, encoding failure. AFAIK, you'll have to specify the codecs explicitly.
    – Gyan
    Dec 10, 2015 at 5:54
  • @Mulvya if the container doesn't support the codec it should just give an error--like normal. 1) Assume the user knows the target container can handle the codecs. 2) Assume that FFmpeg has encoders for the relevant formats. It seems my case should be pretty common, and that it would not be hard to implement such a "copy" switch.
    – jiggunjer
    Dec 10, 2015 at 6:33
  • 1
    ffmpeg -h encoder=label will list all the parameters that the encoder accepts. If a default is set, it's (usually) noted. So, for Xvid, you should run ffmpeg -h encoder=libxvid
    – Gyan
    Dec 10, 2015 at 7:05


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.