Notes
Tech Notes
handy mencoder/ffmpeg commands
compress a video: mencoder -ovc xvid -oac mp3lame -xvidencopts bitrate=750 -srate 8000 -o output.avi input.AVI
extract a clip: mencoder -ss 1284 -endpos 102 movie.avi -oac copy -ovc copy -o movie-clip.avi
remove audio from avi file: mencoder -ovc copy -nosound input.avi -o output.avi
strip audio from a video: ffmpeg -i input.3gpp -vn -acodec libmp3lame -o output.mp3
resize video: ffmpeg -i input.flv -s 720x480 -aspect 4:3 output.flv
flip (rotate) video 90 degrees: ffmpeg -i input.mp4 -vf "transpose=0,hflip=0" -b:v ###k output.mp4
convert ogv to avi: mencoder -idx -ovc lavc -oac mp3lame -o output.avi
convert mpeg to flv: ffmpeg -i -deinterlace -ar 44100 -r 25 -qmin 3 -qmax 6
convert mpg to avi: ffmpeg -i test.mpg -sameq test.avi
convert avi to mp4: ffmpeg -i test.avi -b 1000k -async 1 output.mp4
convert flv to mp4: ffmpeg -i test.flv -b 600k test.mp4
Strip audio or video:
ffmpeg -i input.mp4 -acodec copy -vn output.m4a
ffmpeg -i input.mp4 -vcodec copy -an output.mp4
combine audio and video:
ffmpeg -i input.mp4 -i input.mp3 -acodec copy -vcodec copy output.mp4
(NOTE: the average bitrate for ffmpeg conversions is 200k. to preserve quality, probe the original movie to find the original bitrate using ffmpeg -i test.mpg. then specify that bitrate in the conversion with -b 5000k. Or else just use the "-sameq" flag to preserve quality)
To deinterlace with ffmpeg, add the -deinterlace option during conversion: ffmpeg -i test.mpg -deinterlace -sameq test.avi
For converting my VHS tapes recorded with Hauppauge WinTV through the s-video, this command is the best I have concocted so far:
ffmpeg -y -i test.mpg -deinterlace -vcodec mpeg2video -b 6200k -ab 192k test2.mpg
To combine flv files, this worked well (asusming all at the same resolution):
mencoder -forceidx -of lavf -oac copy -ovc x264 -o output.flv input1.flv input2.flv input3.flv
--------------------------------- RIP DVDs ----------------------------------------
mencoder can also be used to rip dvd titles folllowing this excellent guide and these three commands:
1. mplayer dvd://1 -chapter 3 -vf cropdetect
this command lets you detect the crop values needed to trim out the black borders around the video (ie, -vf crop=720:420:0:0). Start at a later chapter because mencoder needs video that is not empty or black around the edges.
2. mencoder dvd://1 -vf crop=704:480:8:0,scale=720:480 -ovc xvid -xvidencopts bvhq=1:chroma_opt:quant_type=mpeg:bitrate=1200:pass=1 -oac copy -o /dev/null
this command executes the first pass (insert crop values in crop=____ and scale=_____, and select bit rate
3. mencoder dvd://1 -vf crop=704:480:8:0,scale=720:480 -vf pp=lb -ovc xvid -xvidencopts bvhq=1:chroma_opt:quant_type=mpeg:bitrate=1200:pass=2 -alang en -oac mp3lame -lameopts br=96:cbr:vol=6 -o output.avi
and this is the second pass
Note on scale: The scale numbers must be divisible by 16. For 4:3 DVDs, using 720:480 works best. For 16:9 DVDs (widescreen), use 704:304.
note: select the DVD title via dvd://1, where 1 is the DVD title. if you want to play all chapters in the first command, remove the chapter flag.
double note: if interlacing is a problem in the resulting video, add the flag "-vf pp=lb" to the second pass, as shown above.
------------------------ AUDIO/VIDEO Sync issues ------------------------------------
if the output audio is not synced with the video, what has worked for me is adding the flag "-async 1" when doing the conversion. some other possibilities (vsync and itsoffset) did not work for me, but are included here for completeness.
-async samples_per_second
Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps, the parameter is the maximum samples per second by which the audio is changed. -async 1 is a special case where only the start of the audio stream is corrected without any later correction.
-vsync parameter
Video sync method. 0 Each frame is passed with its timestamp from the demuxer to the muxer 1 Frames will be duplicated and dropped to achieve exactly the requested constant framerate. 2 Frames are passed through with their timestamp or dropped so as to prevent 2 frames from having the same timestamp -1 Chooses between 1 and 2 depending on muxer capabilities. This is the default method.
you can also manually adjust the offset via -itsoffet 0.5 (offset audio 1/2 second):
-itsoffset offset
Set the input time offset in seconds. [-]hh:mm:ss[.xxx] syntax is also supported. This option affects all the input files that follow it. The offset is added to the timestamps of the input files. Specifying a positive offset means that the corresponding streams are delayed by 'offset' seconds.
------------------------------------------------------------------------------------------------
this command will extract a segment of video from a larger file:
ffmpeg -y -i input.avi -ss 30 -t 10 -vcodec copy -acodec copy output.avi
where "-ss" is the start position in seconds, and "-t" is the duration
extract and convert video stream: ffmpeg -y -i MVI_2168.AVI -f mpeg -r 25 -b 800k -ar 22050 -ss 5 -t 65 test.avi
extract images from frames: ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
to list available codecs and output formats, use "ffmpeg -formats|more". "D" means that format can be decodec, "E" means encoded. when using -vcodec libxvid, an aspect ratio must be specified or else "Invalid pixel aspect ratio" error will result. the option "-fs 5000000" will limit the output file to 5 MB in size.
i was getting some erros with ffmpeg, like "incorrect parameters such as bitrate" and "timebase not supported by mpeg 4 standard", but I was typing the command wrong (using -sameq didn't work, but using -vcodec copy -acodec copy worked).
some potentially good ffmpeg guides:
http://jaredforsyth.com/content/convert-videos-ffmpeg
http://ffmpeg.org/ffmpeg-doc.html
----------------------------------------------------------------------------------------------
What encoders do I have?
mencoder -oac help
mencoder -ovc help
----------------------------------------------------------------------------------------------
other commands
join avi: cat p1.avi p2.avi > total.avi
----------------------------------------------------------------------------------------------
a simple script to convert many files from flash to mp4:
#!/bin/bash
for file in *.flvdo
ffmpeg -i $file `basename $file .flv`.mp4
done
| < Prev | Next > |
|---|
Last Updated (Sunday, 08 January 2012 02:41)
Designed by i-cons, modified by Judson.