I wish to optimize the process of video transcoding. Exactly I need to get two different video resolutions with the same audio stream options, but now I transcode audio stream twice (as I think ffmpeg works).
Source video has such audio stream:
ffprobe /v
/v: Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 437 kb/s (default)
Now I use these options for transcode one video into two qualities:
ffmpeg -to 00:00:10 -i /v \
-c:a mp3 -ab 42k -vcodec libx264 -s 1920x1080 -b:v 4000k -preset fast -vprofile main -g 50 -f flv 1.mp4 \
-c:a mp3 -ab 42k -vcodec libx264 -s 1280x720 -b:v 2000k -preset fast -vprofile main -g 50 -f flv 2.mp4
As you can see, I define audio stream settings twice for each output, and I think ffmpeg transcodes audio stream twice (does he?). I get audio stream parameters as expected:
ffprobe 1.mp4
ffprobe 2.mp4
1.mp4: Stream #0:1: Audio: mp3, 48000 Hz, stereo, fltp, 42 kb/s
2.mp4: Stream #0:1: Audio: mp3, 48000 Hz, stereo, fltp, 42 kb/s
I wish to transcode audio stream once and use its output for two output files. How to do that? I tried this, but got different audio stream parameters:
ffmpeg -to 00:00:10 -i /v \
-c:a mp3 -ab 42k \
-vcodec libx264 -s 1920x1080 -b:v 4000k -preset fast -vprofile main -g 50 -f flv 1.mp4 \
-vcodec libx264 -s 1280x720 -b:v 2000k -preset fast -vprofile main -g 50 -f flv 2.mp4
ffprobe 1.mp4
ffprobe 2.mp4
1.mp4: Stream #0:1: Audio: mp3, 48000 Hz, stereo, fltp, 42 kb/s
2.mp4: Stream #0:1: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s
As you can see, 2.mp4 has audio bitratte 128 Kb/s instead of 42 Kb/s. I tried to read about -map and -filter_complex, but hope on your help.