H.264 Long GOP Encoding
1-pass encoding 
ffmpeg -i <input_file> -vcodec libx264 -b <video_bitrate> -g <gop_size> -bf 3 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab <audio_bitrate> output.mp4 
2-pass encoding 
ffmpeg -y -i <input_file> -pass 1 -vcodec libx264 -b <video_bitrate> -g <gop_size> -bf 3 -refs 6 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method umh -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 3 -flags2 +dct8x8+wpred+bpyramid+mixed_refs -trellis 1 -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8 -acodec libfaac -ab <audio_bitrate> output.mp4 
ffmpeg -y -i <input_file> -pass 2 -vcodec libx264 -b <video_bitrate> -g <gop_size> -bf 3 -refs 6 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method umh -subq 7 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 3 -flags2 +dct8x8+wpred+bpyramid+mixed_refs -trellis 1 -partitions +parti8x8+parti4x4+partp8x8+partp4x4+partb8x8 -acodec libfaac -ab <audio_bitrate> output.mp4 
D10 (aka Sony IMX) Encoding
ffmpeg -i <input_file> -vcodec mpeg2video -r 25 -pix_fmt yuv422p -minrate 50000k -maxrate 50000k -b 50000k -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -ps 1 -qmin 1 -qmax 3 -top 1 -bufsize 2000000 -rc_init_occupancy 2000000 -rc_buf_aggressivity 0.25 -an output.m2v 
Notes : 
- Only works for 25 fps content. 
- Change minrate, maxrate and b values to 30000k / 40000k / 50000k in order to produce 30/40/50 Mbps D10 essence. 
- Set bufsize and rc_init_occupancy values to 1200000 / 1600000 / 2000000 for 30/40/50 Mbps D10 essence. 
- Add the -padtop 32 option if you want to produce a 720x608 D10 image size from a 720x576 source. 
XDCAM HD 50Mbps in QuickTime (for Final Cut Pro import)
ffmpeg -i <input_file> -pix_fmt yuv422p -vcodec mpeg2video -flags +ildct+ilme -top 1 -dc 10 -flags2 +ivlc+non_linear_q -qmin 1 -lmin '1*QP2LAMBDA' -vtag xd5c -rc_max_vbv_use 1 -rc_min_vbv_use 1 -b 50000k -minrate 50000k -maxrate 50000k -bufsize 36408333 -bf 2 -aspect 16:9 -acodec pcm_s16be -f mov output.mov -newaudio 
DVCAM / DVCPRO25 / DVCPRO50 Encoding
ffmpeg -i <input_file> -pix_fmt yuv420p output_DVCAM.dv 
ffmpeg -i <input_file> -pix_fmt yuv411p output_DVCPRO25.dv 
ffmpeg -i <input_file> -pix_fmt yuv422p output_DVCPRO50.dv 
VC-3 (aka Avid DNxHD) Encoding
ffmpeg -i <input_file> -vcodec dnxhd -b <bitrate> -an output.mov 
Notes : 
- <bitrate> can take the following values : 36Mb, 60Mb, 90Mb, 120Mb, 185Mb ( please refer to the following table ). 
- Add the following option for interlaced modes : -flags +ildct 
- Add the following option for best quality mode ( very slow ! ) : -mbd rd 
Supported Resolutions : 
MPEG-2 I-frame only Highest Quality Encoding
ffmpeg -i <input_file> -vcodec mpeg2video -qscale 1 -qmin 1 -intra -an output.m2v 
MPEG-2 Long GOP Encoding
ffmpeg -i <input_file> -vcodec mpeg2video -b <video_bitrate> -g <gop_size> -bf 2 -b_strategy 1 -acodec mp2 -ab <audio_bitrate> -f vob output.mpg 
MJPEG in Highest Quality
ffmpeg -i <input_file> -vcodec mjpeg -qscale 1 -an output.avi 
D10 into QuickTime Wrapping
ffmpeg -i <input_file> -vcodec copy -acodec pcm_s16le -vtag mx5p -vbsf imxdump output.mov 
Notes : 
- This feature needs a patched version of FFmpeg not available in the current SVN, please contact Baptiste Coudurier for more information. 
- Set -vtag to mx3p / mx4p / mx5p for D10 30/40/50 PAL or mx3n / mx4n / mx5n for D10 30/40/50 NTSC. 
- Input D10 image size must be 720x608 ( use -padtop 32 option during D10 encoding if the original image size is 720x576 ). 
- Final Cut Pro compliant. 
MPEG-2 Program Stream Muxing
ffmpeg -genpts 1 -i ES_Video.m2v -i ES_Audio.mp2 -vcodec copy -acodec copy -f vob output.mpg 
Note : In order to mux multiple audio tracks into the same file : 
ffmpeg -genpts 1 -i ES_Video.m2v -i ES_Audio1.mp2 -i ES_Audio2.mp2 -vcodec copy -acodec copy -f vob output.mpg -newaudio 
Note : In order to remux a PS file with multiple audio tracks : 
ffmpeg -i input.mpg -vcodec copy -acodec copy -f vob output.mpg -acodec copy -newaudio 
MPEG-2 Program Stream Demuxing
ffmpeg -i input.mpg -vcodec copy -f mpeg2video ES_Video.m2v -acodec copy -f mp2 ES_Audio.mp2 
Note : This also works for files containing multiple audio tracks : 
ffmpeg -i input.mpg -vcodec copy -f mpeg2video ES_Video.m2v -acodec copy -f mp2 ES_Audio1.mp2 -acodec copy -f mp2 ES_Audio2.mp2 
MPEG-2 Start Timecode
ffmpeg -i <input_file> -timecode_frame_start <start_timecode> -vcodec mpeg2video -an output.m2v 
Note : Start timecode is set as number of frames. For instance, if you want to start at 18:12:36:15, you will have to set -timecode_frame_start to 1638915 ( for 25 fps content ). 
Audio Volume Modification
ffmpeg -i <input_file> -vol <audio_volume> -acodec <audio_codec> <output_file> 
Input Stream Selection
ffmpeg -i input.vob -map 0:2 -acodec aac -ab <audio_bitrate> -vn output.mp4 
Transcode audio stream #0:2. 
Sub-clip Creation
ffmpeg -i <input_file> -ss <timecode> -t <timecode> -vcodec copy -acodec copy <output_file> 
Make a Video File from a Single Frame
ffmpeg -loop_input -vframes <number_of_frames> -i <input_file> <output_file>
			
									
									
						How to work with FFmpeg
Re: How to work with FFmpeg
I wanted to thank you for this great read!!
<link removed>
			
													<link removed>
					Last edited by Neo on Thu Jun 16, 2011 8:08 pm, edited 1 time in total.
					
Reason: Link removed by admin
			
									
						Reason: Link removed by admin
Re: How to work with FFmpeg
Hi Cyclops!
Your posted informations are very useful one. Thank you
			
									
									
						Your posted informations are very useful one. Thank you

