[FFmpeg-user] Right way to extract and recombine audio/video streams?

Werner Robitza werner.robitza at gmail.com
Tue Apr 30 15:43:00 CEST 2013

> Per www.howto-pages.org/ffmpeg/ :

The author says that they're "no ffmpeg expert", and their examples show an
ffmpeg version from 2007.
Maybe you should look for examples on the FFmpeg Wiki (
http://ffmpeg.org/trac/ffmpeg/) – more up to date info there.

> 1. Extract video stream
> ffmpeg.exe -i input.flv -vcodec copy -an output.h264
> 2. Extract audio stream
> ffmpeg.exe -i input.flv -vn -acodec copy output.aac
> 3. Edit audio track in eg. Audacity
> 4. Build new FLV file by combining original video stream + edited
> audio stream:
> ffmpeg.exe -i output.h264 -i output.aac new.flv
> Is this correct?

The problem here is that you're extracting to raw bitstreams (H.264 or
AAC), without any container. Raw bitstreams usually don't carry any info
about the duration of the contents, the frame sizes or frame rates, or any
metadata. If you want to edit such a stream, that may turn out cumbersome,
or near impossible.

Rather try to mux into a container that can be easily parsed and opened
with (almost) any video or audio editor:

ffmpeg -i input.flv -c:v copy -an output.m4v
ffmpeg -i input.flv -c:a copy -vn output.m4a

Mux with:

ffmpeg -i input.m4v -i input.m4a -c copy output.mp4

You need -c copy here to make sure the bitstreams aren't converted again.

More information about the ffmpeg-user mailing list