Blog / extract-audio-from-video-url

How to Extract Audio From a Video URL (FFmpeg and yt-dlp)

Quick answer

Commands to extract audio from a video URL with FFmpeg and yt-dlp, the right format for speech recognition, and when you can skip the audio step.

2026-10-05 | 7 min read | ReelWords Team

ReelWords illustration of a video URL being converted into an audio file with FFmpeg and yt-dlp.

To extract audio from a video URL, first work out what kind of URL it is. A direct link to a media file (.mp4, .mov, .webm) can be read by FFmpeg over HTTP with no download step. A link to a platform page (a YouTube watch page, a TikTok post) is HTML, so FFmpeg cannot read it and you need a tool such as yt-dlp to resolve the media first.

This guide covers both cases, the output settings worth using, and the common situation where you do not need the audio file at all.

Direct file URLs: extract audio from a video URL with FFmpeg

FFmpeg accepts an HTTPS URL anywhere it accepts a file path. It reads only what it needs from the remote file.

Copy the audio stream without re-encoding

ffmpeg -i "https://cdn.example.com/video.mp4" -vn -c:a copy audio.m4a

-vn drops the video. -c:a copy writes the existing audio stream as it is, so there is no quality loss and the command finishes quickly. The container has to suit the codec: AAC audio from an MP4 goes in .m4a, Opus from a WebM goes in .opus or .webm. Find out what you have with:

ffprobe -v error -select_streams a:0 \
  -show_entries stream=codec_name,sample_rate,channels \
  -of default=noprint_wrappers=1 "https://cdn.example.com/video.mp4"

Convert to MP3

ffmpeg -i "https://cdn.example.com/video.mp4" -vn -c:a libmp3lame -q:a 2 audio.mp3

-q:a 2 is a high-quality variable bitrate setting. Use this when the destination needs MP3 specifically. It is a re-encode, so it is slower than a stream copy.

Convert for speech recognition

ffmpeg -i "https://cdn.example.com/video.mp4" -vn -ac 1 -ar 16000 -c:a pcm_s16le audio.wav

Mono, 16 kHz, 16-bit PCM is the input format whisper.cpp expects, and other speech models accept it too. Stereo and 48 kHz add file size without helping recognition. If upload size matters more than avoiding a lossy step, a mono Opus or MP3 file is far smaller than WAV.

Platform page URLs: yt-dlp

yt-dlp resolves a platform page to its media streams and calls FFmpeg for conversion. Its documentation lists ffmpeg and ffprobe as strongly recommended dependencies, and -x requires them.

yt-dlp -x --audio-format mp3 --audio-quality 0 -o "%(id)s.%(ext)s" "PAGE_URL"
  • -x (--extract-audio) converts the download to an audio-only file.
  • --audio-format accepts best (the default), aac, alac, flac, m4a, mp3, opus, vorbis, and wav.
  • --audio-quality takes 0 (best) to 10 (worst) for VBR, or a bitrate such as 128K. The default is 5.

To avoid downloading video you will throw away, ask for the audio stream only:

yt-dlp -f bestaudio -o "%(id)s.%(ext)s" "PAGE_URL"

Check that you are allowed to download the content. Platform terms of service generally restrict downloading, and copyright applies regardless of what a tool makes possible. Use this on your own uploads and on content you have permission to process.

Operational caveats

yt-dlp works by tracking how each site serves media, and sites change. In a production service that means:

  1. Pin a version, and plan to update it often.
  2. Expect failures from datacenter IP ranges, rate limits, and login-gated or region-restricted videos.
  3. Treat each failure as a normal outcome with a clear error, and avoid retrying in a tight loop.

Do you need the audio file at all?

Most pipelines extract audio as a means to an end, and the end is usually text. If what you need is a transcript, there are two shorter routes.

Use the captions that already exist. Many platform videos have a caption track. yt-dlp can fetch it without downloading media:

yt-dlp --skip-download --write-subs --write-auto-subs --sub-langs "en.*" --sub-format "srt/best" "PAGE_URL"

--skip-download writes the related files only. --write-auto-subs includes automatically generated tracks.

Send the URL to a transcript API. ReelWords does not return audio files. It takes a public video URL from YouTube, TikTok, Instagram, X, Facebook, or a direct file link, and returns the transcript. It uses the platform's native captions when they exist and falls back to speech recognition when they do not; the job's transcriptSource field tells you which one you got.

curl -s -X POST https://api.reelwords.ai/api/v1/transcript-jobs \
  -H "x-api-key: $REELWORDS_KEY" \
  -H "content-type: application/json" \
  -d '{"url": "PAGE_URL"}'

Poll GET /api/v1/transcript-jobs/{id} until status is complete, then download srt, vtt, txt, or txt_timestamps. The video URL transcript guide walks through it in the web app, and the API docs have the full contract.

Here is how the three approaches compare:

ApproachOutputYou maintain
FFmpeg on a direct URLAudio fileFFmpeg binary
yt-dlp + FFmpegAudio fileyt-dlp updates, network reliability, FFmpeg
Transcript APISRT, VTT, or textAn API key

If you do want to keep audio extraction in house and build transcription around it, our Node.js transcription pipeline guide covers the queueing side.

Verify the result

A truncated download produces a valid but short audio file, and nothing downstream will complain. Compare durations before moving on:

ffprobe -v error -show_entries format=duration -of csv=p=0 audio.m4a

If the audio is more than a second or so shorter than the source, treat the extraction as failed.

FAQ

Can FFmpeg extract audio straight from a YouTube URL?

No. A watch-page URL returns HTML, which FFmpeg cannot demux. You need a direct media URL, or a tool such as yt-dlp to resolve the page.

What is the best audio format for transcription?

Mono 16 kHz audio. WAV avoids a lossy step and is what whisper.cpp expects. Check your provider's accepted formats and size limits, because a long WAV file can exceed an upload cap.

How do I extract audio without losing quality?

Use -vn -c:a copy and a container that matches the source codec. Nothing is re-encoded, so the audio is bit-for-bit what was in the video.

Why does "-c:a copy" fail with a container error?

The output extension does not support the source codec, for example Opus audio written to .m4a. Run ffprobe to see the codec and pick a matching container, or re-encode.

Can I extract only part of the audio?

Yes. Put -ss and -t before the input: ffmpeg -ss 00:01:00 -t 30 -i URL -vn -c:a copy clip.m4a. With a stream copy the cut lands on the nearest packet boundary, which is accurate enough for audio.

Is it legal to extract audio from a video URL?

It depends on who owns the content and on the platform's terms. Your own videos and content you have licensed are fine. Downloading other people's content from a platform usually breaches its terms and may infringe copyright.

Does ReelWords return the audio file?

No. The API returns transcripts and captioned video renders. If you need the audio itself, use FFmpeg or yt-dlp as described above.

Need the transcript and not the audio? See ReelWords features, check pricing, or read the FAQ.