2

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
  • 245
  • 4
  • 11
  • The `FFmpeg` documentation clearly states that they do the same thing. Just be careful if you ever work with videos - you would have to use `-c:a copy` to only copy the audio codec, like `-acodec` – pigeonburger Jan 25 '21 at 00:41
  • I think the quality issue is you are asking two different questions in one(so that's one problem re quality). Also, you have the one question in your title(Fine), and the other is at the end, how can you "improve" on those commands.. and that latter type of question isn't favoured that much by the site..as they are quick to label things as "too ambiguous", You could have asked the one question in your title, then made a new question to ask if your command (which works), is correct or has any problem that you haven't noticed. – barlop Jan 25 '21 at 02:45
  • If you split it into two questions, the question in your title might do OK.. The other question might get labelled too ambiguous and get closed , which is OK. – barlop Jan 25 '21 at 02:47
  • Nobody replied in their answer re any suggestions to improve your commands , apart from a comment from Frank saying that your second one is more succinct. So you could delete the "Also...." part from your question And that includes removing the "(I just need to sequentially join together 3 mp3s)." – barlop Jan 25 '21 at 02:48
  • @barlop Why would I delete those things I want to know the answer. – niico Jan 25 '21 at 14:46
  • @niico well, if you say "Both of these commands seem to work fine" then they work. And if nobody has suggested an improvement then maybe they are fine and there isn't one? Is there anything that makes you think they could be "improved"? And what improvement did you have in mind? – barlop Jan 25 '21 at 20:46
  • nice driveby unexplained down votes. Down voters should be forced to at least explain why they downvoted, otherwise how are people supposed to learn what they did wrong?! – niico Jan 25 '21 at 21:00
  • @barlop I don't (didn't) understand what they're doing exactly, so it's certainly possible they can be improved yes. – niico Jan 25 '21 at 21:01
  • well, the only reason why `copy /b` had issues is that it's a hack. Using ffmpeg as you are, the output should play as well as the individual mp3 files play. I did once use ffmpeg to create an mp4 file and the mp4 wouldn't play because the audio codec was too advanced, but changing the audio codec to mp3 made it more compatible. You can always keep the original files and if for some reason you find out that things don't work in some player then you have everything you could possibly need to fix it and you can look into it if it happens. Really mp3 files and compatibility is pretty safe! – barlop Jan 25 '21 at 21:32

2 Answers2

7

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
  • 23,380
  • 43
  • 145
  • 225
  • Thanks for the comprehensive answer. So in my particular case, if I just want to concatinate 3 mp3s, what would you suggest I use? Short simple syntax is preferred, so maybe my 2nd option is OK? – niico Jan 25 '21 at 00:16
  • 1
    @niico i'm not an ffmpeg expert. I only know what I researched and tried of it, it's a complex program, . and I don't recall if I used ffmpeg for that but i'd probably just go to the cmd prompt and do `copy /b aaa.mp3+bbb.mp3 ccc.mp3` but it's not great for metadata, this link mentions some other methods including with ffmpeg https://stackoverflow.com/questions/62618/what-is-the-best-way-to-merge-mp3-files – barlop Jan 25 '21 at 00:29
  • I was actually using copy - but it creates mp3s with the wrong length and some mp3 players will only play the new mp3 for the length of the first one. ffmpeg fixes this issue. – niico Jan 25 '21 at 00:57
  • @niico yeah as mentioned, the windows copy command with /b used to combine mp3 files, has issues, it's dirty.. that SO link mentions a ton of solutions including with ffmpeg though. – barlop Jan 25 '21 at 01:02
  • @niico your question does also say that your commands work fine.. frank seems to know quite a bit about ffmpeg and thinks they're ok so they should be fine! – barlop Jan 25 '21 at 02:42
  • mp3wrap looks interesting but it's written by 1 guy on a site from 1993. Probably abandoned, don't want to rely on something like this. – niico Jan 25 '21 at 15:06
  • This wasn't working on all players with copy /b - but does appear to be with ffmpeg concat now. Will do further testing to confirm. – niico Jan 25 '21 at 15:13
  • Also 'work fine' I mean, I can't know for sure that there will be no problems - I can't test in all MP3 players. – niico Jan 25 '21 at 21:03
5

-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
  • 35,097
  • 3
  • 77
  • 98
  • Thanks for the comprehensive answer. So in my particular case, if I just want to concatinate 3 mp3s, what would you suggest I use? Short simple syntax is preferred, so maybe my 2nd option is OK? – niico Jan 25 '21 at 00:15
  • 1
    Yep, your second command is certainly the most succinct. since you are starting with .mp3 files, they are already audio only, so `-c copy` and `-acodec copy` have exactly the same effect. – Frank Thomas Jan 25 '21 at 00:19