Friday, January 11, 2013

Video/Audio Stream Demuxing/Muxing Using ffmpeg

ffmpeg is a very fast video and audio converter that can also grab from a live audio/video source. It can also convert between arbitrary sample rates and resize video on the fly with a high quality poly phase filter.

ffmpeg reads from an arbitrary number of input "files" (which can be regular files, pipes, network streams, grabbing devices, etc.), specified by the -i option, i.e., and writes to an arbitrary number of output "files", which are specified by a plain output file name. Anything found on the command line which cannot be interpreted as an option is considered to be an output file name.

FFmpeg Windows Builds are available at Zeranoe FFmpeg Builds.

The syntax is

ffmpeg [[infile options][`-i' infile]]... {[outfile options] outfile}...

Therefore ffmpeg can be used for video/audio stream demuxing (splitting) and muxing (recombining). 

For example, get the video only and audio only from a file:
  1. Video: ffmpeg -i test.avi  -vcodec copy -f h264 test.264
  2. Audio: ffmpeg -i test.avi  -acodec copy -f s16le test.pcm, assuming pcm_s16le is applied when audio stream is captured. pcm_s16le is a common file format when TI DSP is used
Or one command line does it all:

ffmpeg -i test.avi  -acodec copy -f s16le test.pcm -vcodec copy -f h264 test.264

If we want to recombine the audio and video files to one file

ffmpeg -i test.264 -i test.pcm -vcodec copy -acodec copy -f avi test.avi

The following video and audio codecs are supported with ffmpeg:

video codecs

Video codec nameDescription
mjpegMotion JPEG
ljpeglossless JPEG
jpeglsJPEG LS
targaTarga image
gifGIF image
bmpBMP image
pngPNG image
mpeg4ISO standard MPEG-4 (DivX, Xvid compatible)
msmpeg4pre-standard MPEG-4 variant by MS, v3 (AKA DivX3)
msmpeg4v2pre-standard MPEG-4 by MS, v2 (used in old ASF files)
wmv1Windows Media Video, version 1 (AKA WMV7)
wmv2Windows Media Video, version 2 (AKA WMV8)
rv10RealVideo 1.0
rv20RealVideo 2.0
mpeg1videoMPEG-1 video
mpeg2videoMPEG-2 video
huffyuvlossless compression
ffvhuffFFmpeg modified huffyuv lossless
asv1ASUS Video v1
asv2ASUS Video v2
ffv1FFmpeg's lossless video codec
svq1Sorenson video 1
flvSorenson H.263 used in Flash Video
flashsvFlash Screen Video
dvvideoSony Digital Video
snowFFmpeg's experimental wavelet-based codec
zmbvZip Motion Blocks Video

audio codecs

Audio codec nameDescription
ac3Dolby Digital (AC-3)
adpcm_*Adaptive PCM formats - see supplementary table
flacFree Lossless Audio Codec (FLAC)
g726G.726 ADPCM
libfaacAdvanced Audio Coding (AAC) - using FAAC
libgsmETSI GSM 06.10 full rate
libgsm_msMicrosoft GSM
libmp3lameMPEG-1 audio layer 3 (MP3) - using LAME
mp2MPEG-1 audio layer 2 (MP2)
pcm_*PCM formats - see supplementary table
roq_dpcmId Software RoQ DPCM
sonicexperimental FFmpeg lossy codec
soniclsexperimental FFmpeg lossless codec
wmav1Windows Media Audio v1
wmav2Windows Media Audio v2

PCM/ADPCM format supplementary table

PCM/ADPCM codec nameDescription
pcm_s32lesigned 32-bit little-endian
pcm_s32besigned 32-bit big-endian
pcm_u32leunsigned 32-bit little-endian
pcm_u32beunsigned 32-bit big-endian
pcm_s24lesigned 24-bit little-endian
pcm_s24besigned 24-bit big-endian
pcm_u24leunsigned 24-bit little-endian
pcm_u24beunsigned 24-bit big-endian
pcm_s16lesigned 16-bit little-endian
pcm_s16besigned 16-bit big-endian
pcm_u16leunsigned 16-bit little-endian
pcm_u16beunsigned 16-bit big-endian
pcm_s8signed 8-bit
pcm_u8unsigned 8-bit
pcm_alawG.711 A-LAW
pcm_mulawG.711 μ-LAW
pcm_s24daudsigned 24-bit D-Cinema Audio format
pcm_zorkActivision Zork Nemesis
adpcm_ima_qtApple QuickTime
adpcm_ima_wavMicrosoft/IBM WAVE
adpcm_ima_dk3Duck DK3
adpcm_ima_dk4Duck DK4
adpcm_ima_wsWestwood Studios
adpcm_ima_smjpegSDL Motion JPEG
adpcm_4xm4X Technologies
adpcm_xaPhillips Yellow Book CD-ROM eXtended Architecture
adpcm_eaElectronic Arts
adpcm_ctCreative 16->4-bit
adpcm_swfAdobe Shockwave Flash
adpcm_sbpro_4Creative VOC SoundBlaster Pro 8->4-bit
adpcm_sbpro_3Creative VOC SoundBlaster Pro 8->2.6-bit
adpcm_sbpro_2Creative VOC SoundBlaster Pro 8->2-bit
adpcm_thpNintendo GameCube FMV THP
adpcm_adxSega/CRI ADX

No comments:


Blog Archive

About Me

My photo
HD Multimedia Technology player