← Blog
Two waveforms from the same lesson master. The first track carries producer commentary. The second carries the instructor’s room-tone lesson.
Published on

Extract the right audio track from a course video with FFmpeg

The first English audio track in our lesson video opens with “Producer note for the edit.” It lasts just as long as the instructor’s lesson. If you extract the default track, the learner gets directions for cutting the video instead of instructions for recording room tone.

To extract audio from a video with FFmpeg, identify the track you want and select it with -map. Copy its audio into an M4A when the source codec and delivery format allow it. If the course requires MP3, encode that same track as MP3. Open the audio file on its own and check the words against the approved lesson script.

Find the instructor in the lesson master

Download the two-track lesson, both audio exports and the approved script. Unzip the packet. The master, lesson-04-r2.mp4, is an 11-second field-recording lesson. Both audio tracks contain synthetic English speech. The learner should hear “Set the recorder on a folded towel” at the start and “Save ten seconds of room tone” at the end.

With FFmpeg installed, open a terminal in the sample folder and list the streams. This form inspects the input without creating a file. FFmpeg prints the stream list followed by a message asking for an output file.

ffmpeg -hide_banner -i lesson-04-r2.mp4
  • Stream 0:0 is the lesson picture.
  • Stream 0:1 is labeled “Producer commentary.” It is the first audio stream and the default. The producer says, “Keep the wide shot under the opening line.”
  • Stream 0:2 is labeled “Instructor narration.” It is the second audio stream. This is the one named in the delivery brief.

In 0:a:1, the first zero identifies the input file, a limits the selection to audio, and the final 1 selects the second audio stream because counting starts at zero. For this master, -map 0:2 selects the same stream by its overall index. Check the order on each new master, even if its filename differs only by a revision number. FFmpeg’s stream selection reference.

Copy the narration to an M4A

Both source tracks use AAC. The course accepts AAC in an M4A file, so the instructor track can be copied without encoding it again. Use a fresh output name so you can compare your file with the supplied example. The -n option protects an existing file from being overwritten.

ffmpeg -n -i lesson-04-r2.mp4 -map 0:a:1 -c:a copy my-lesson-en.m4a

This selects a single audio stream and leaves the picture and commentary behind. If your source has missing or ambiguous labels, audition the candidates. For this sample, repeat the command with -map 0:a:0 and a different filename to hear the producer’s track. Use the opening words to settle which one belongs to the learner. How FFmpeg copies a stream.

Make an MP3 if the delivery brief asks for one

An outlet that requires MP3 needs a new encode from the selected source track. For this mono speech example we used 96 kb/s. Use the outlet’s requested format and bitrate for your own delivery.

ffmpeg -n -i lesson-04-r2.mp4 -map 0:a:1 -c:a libmp3lame -b:a 96k my-lesson-en.mp3

The sample M4A has one AAC audio stream and runs 11.00 seconds. The sample MP3 has one MP3 audio stream and reports 11.04 seconds. Both contain the closing instruction. Duration alone would also have passed the producer track.

Check the file a learner will open

Close the video, open the audio download and follow the three lines in lesson-script.txt. The instructor tells the learner where to put the recorder, asks them to keep their hands off the table, then specifies ten seconds of room tone. Each action makes sense without the slide. If your lesson says “move this here” and the picture supplies the missing detail, mark the line and ask the producer for an audio-friendly instruction before release.

For the handoff, record the master revision, selected track, language, delivery filename and listening decision. If you hear the editing directions, hold the file and export the instructor track. If the right words play but the opening or closing is cut short, check the source revision before changing any encoding settings. For a series with uneven levels, use the weekly lesson audio-normalization guide after choosing the right narration.

What we checked. We made both sample exports locally with FFmpeg 7.1. The decoded M4A matched the instructor stream sample for sample. A local speech recognizer recovered all three script lines from the M4A and MP3, including the closing instruction. It transcribed the separate producer check as editing directions. An editor also listened to the delivery MP3 and confirmed that the opening instruction and the closing words “room tone” were clear. Playback inside a course platform was outside this check.

When a weekly audio batch needs a CPU worker

A workstation is enough for this example. If dozens of lessons need new MP3s before a weekly release, time a representative batch. Record the total lesson minutes, time waiting for a worker and time spent encoding. Track transfers and listening separately. If encoding is using the time editors need for review, take those figures to the CPU VM buying guide. We did not measure cloud throughput for this lesson.

Your next workload belongs on Hivenet.

Pick one AI, compute, or storage workload and see the difference for yourself. Spin it up in minutes, or let our team map your fastest path to production.