0

I'm trying to take a video with two audio streams and compress the first one in stereo at 48 kbps with AAC HEv2 encoding, with the second in mono at 40 kbps using HEv1. My code is essentially as follows:

set STREAM_01=-map 0:a:0 -b:a:0 48000 -ac 2 -c:a:0 libfdk_aac -profile:a aac_he_v2 
set STREAM_02=-map 0:a:1 -b:a:1 40000 -ac 1 -c:a:1 libfdk_aac -profile:a aac_he 
set SPECS=-ar 48000 -sample_fmt s16 -cutoff 20000
ffmpeg.exe -i input.mkv -map 0:v:0 -c:v copy %SPECS% %STREAM_01% %STREAM_02% output.mkv

But the program only seems to execute whichever of the two profiles was specfied last -- both streams either come out HEv1 or they both come out HEv2. This is doubtless because the profile instruction omits a stream specifier, but when I try to write the profile options in the form "-profile:a:1 aac_he_v2" or "-profile:a:2 aac_he" I get an error message, "Error while opening encoder for output stream #0:1." What am I missing here?

0

aac_he_v2 encodes stereo streams and your channel layout option isn't stream-qualified.

set STREAM_01=-map 0:a:0 -b:a:0 48000 -ac:a:0 2 -c:a:0 libfdk_aac -profile:a:0 aac_he_v2 
set STREAM_02=-map 0:a:1 -b:a:1 40000 -ac:a:1 1 -c:a:1 libfdk_aac -profile:a:1 aac_he 
  • Thanks, Mulvya, though I'm not entirely sure what "stream-qualified" means. What I do know is that if I omit either stream 1 or stream 2 from the ffmpeg line, the command works as expected -- which is to say, I get a stereo stream with he_v2 encoding if I remove %STREAM_02% or a mono stream with he_v1 if I remove %STREAM_01%. – Wally Walters May 23 '17 at 7:28
  • A setting which applies only to the specified stream. – Gyan May 23 '17 at 7:35
  • Then that suggests that my best bet would be to process each stream separately and then remux at the end, something like ffmpeg.exe -i -map 0:v -c:v copy -an "VIDEO_01.mkv" ffmpeg.exe -i input.mkv -vn %SPECS% %STREAM_01% AUDIO_01.m4a ffmpeg.exe -i input.mkv -vn %SPECS% %STREAM_02% AUDIO_02.m4a ffmpeg.exe -i VIDEO_01.mkv -i AUDIO_01.m4a -i AUDIO_02.m4a -map 0 -map 1 -map 2 -c copy output.mkv And it does work; it just isn't as straightforward. In any event, thanks again. – Wally Walters May 23 '17 at 13:58
  • I don't understand; did my command not work? – Gyan May 23 '17 at 14:04
  • My mistake; it does work. There was an error in my typing. Again, my thanks. – Wally Walters May 23 '17 at 14:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.