[savvyadmin] 0:home1:processes2:recipes3:explain4:archive linux & server reference since 2007
david@web-1:~$ less recipes/extract-ac3-dolby-digital-with-ffmpeg.md
EXTRACT-AC3-DOLBY-DIGITAL-WITH-FFMPEG recipes

Extract AC3 Dolby Digital with FFMpeg

published 2013-02-21 · tags: ac3, encoding, ffmpeg, multimedia

AS PUBLISHED, 2013Original text from Feb 21, 2013, kept as published. Package names and flags reflect the tooling of that time; an in-place refresh with a tested on line is on the way.

If you have a source video file encoded with an AC3 Dolby Digital audio stream, you can extract the audio in it’s native format using FFMpeg.

The following example shows how to identify the available audio streams of the file video.avi. Just use ffmpeg without any output options, and you can see there are two streams (0.0 and 0.1), the second is AC3 audio.

ffmpeg -i video.avi

Input #0, avi, from 'video.avi':

Duration: 01:17:57.64, start: 0.000000, bitrate: 1587 kb/s

Stream #0.0: Video: mpeg4, yuv420p, 672x576 (snipped for brevity)

Stream #0.1: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s

At least one output file must be specified

The following command will extract the AC3 audio stream to a file called audio.ac3.

ffmpeg -i video.avi -acodec copy audio.ac3

Input #0, avi, from 'video.avi':

Duration: 01:17:57.64, start: 0.000000, bitrate: 1587 kb/s

Stream #0.0: Video: mpeg4, yuv420p, 672x576 (snipped for brevity)

Stream #0.1: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s

Output #0, ac3, to 'audio.ac3':

Stream #0.0: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s

Stream mapping:

Stream #0.1 -> #0.0

Press [q] to stop encoding

size= 255799kB time=4677.51 bitrate= 448.0kbits/s

video:0kB audio:255799kB global headers:0kB muxing overhead 0.000000%

Verify the file was created. The output below shows that this stream is about 250Mb.

ls -lh audio.ac3 

-rw-r--r-- 1 username gmendoza 250M 2010-02-21 09:47 audio.ac3

You can now use ffmpeg again to show that audio.ac3 only contains the ac3 audio stream.

ffmpeg -i audio.ac3

Input #0, ac3, from 'audio.ac3':

Duration: 01:17:57.46, bitrate: 448 kb/s

Stream #0.0: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s

At least one output file must be specified

Now that you have extracted the audio stream, you can do anything you wish with it. Enjoy.

savvyadmin.com 2013-02-21 EXTRACT-AC3-DOLBY-DIGITAL-WITH-FFMPEG
recipes/extract-ac3-dolby-digital-with-ffmpeg.md (END)