3

I'm new to FFMPEG, and can't find much clear documentation on this specifically.

I'm concatenating 3 mp3's (I just want muxing, no encoding/transcoding).

Both of these commands seem to work fine. Is there any difference between using '-c' and '-acodec'?

ffmpeg -i "concat:a.mp3|b.mp3|c.mp3" -acodec copy out.mp3

ffmpeg -i "concat:a.mp3|b.mp3|c.mp3" -c copy out.mp3

I've searched Google for hours, I've found various documentation of ffmpeg but none that explain what -c or -acodec actually do. I think -c stands for 'codec' and -acodec stands for 'audio codec'?? What does each do / is there a difference / is one better?

Documentation I've found that doesn't help:

https://ffmpeg.org/ffmpeg-all.html

https://gist.github.com/tayvano/6e2d456a9897f55025e25035478a3a50

Also any suggestions on how to improve this most welcome (I just need to sequentially join together 3 mp3s).

Thanks.

niico
  • 255

2 Answers2

9

To address your title.

Doing -c copy will copy both the audio codec (acodec) and the video codec (vcodec)

-c copy is the same as -acodec copy -vcodec copy

-c:a copy is the same as -acodec copy.

-c:v copy is the same as -vcodec copy

and of course you can specify a codec e.g. -vcodec libx264 or -c:v libx264

The -c stands for codec. You can alternatively write -codec https://ffmpeg.org/ffmpeg.html e.g. -codec:a copy

and if you don't specify e.g. -acodec copy or -acodec blahblah or -codec:a ..., then it will pick some default codec. You can also say -vn for no video. https://stackoverflow.com/questions/9913032/how-can-i-extract-audio-from-video-with-ffmpeg so it doesn't copy video. or -an for no audio Remove audio from video file with FFmpeg

Added

The syntax of -acodec and -vcodec is deprecated now.. And it's recommended to use the syntax of -c:a and -c:v (which are aliases for -codec:a and -codec:v)

barlop
  • 25,198
6

-c or -codec is a generic stream selector, so you can use it to set the codec for any of the streams be they audio or video.

-acodec is a subset of that functionality that automatically scopes to Audio streams

-acodec:1 is the same as -codec:a:1 and indicates you are setting the codec for the second audio stream (the first audio stream is 0).

from your linked documentation: -c, -codec

-c[:stream_specifier] codec (input/output,per-stream) -codec[:stream_specifier] codec (input/output,per-stream)

Select an encoder (when used before an output file) or a decoder (when used before an input file) for one or more streams. codec is the

name of a decoder/encoder or a special value copy (output only) to indicate that the stream is not to be re-encoded.

-acodec

-acodec codec (input/output)

Set the audio codec. This is an alias for -codec:a.

there is also a -vcodec that works the same way for video streams.

so to put it all together consider this command from the doc ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT

this is saying use the original codec for all the steams (-c copy), but for the second video stream use libx264 (-c:v:1 libx264), and for the 138th audio stream use libvorbis (-c:a:137 libvorbis).

so with -c you can control all the types of streams, whereas -acodec and -vcodec are just shortcuts for the audio or video subsets thereof.

Frank Thomas
  • 37,476