Difference between revisions of "ffmpeg"
From Noah.org
Jump to navigationJump to searchm |
|||
Line 3: | Line 3: | ||
== MJPEG == | == MJPEG == | ||
− | You can | + | You can check if your video is in '''MJPEG''' format using '''ffprobe'''. You should get the output '''codec_name=mjpeg'''. |
<pre> | <pre> | ||
− | ffmpeg -i | + | ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=nw=1 input.mov |
+ | </pre> | ||
+ | |||
+ | You can extract lossless individual JPEG images from an '''MJPEG''' file. Note the two form of syntax that may be required depending on the version of '''ffmpeg''' being used. | ||
+ | <pre> | ||
+ | ffmpeg -i input.mov -codec:v copy -bsf:v mjpeg2jpeg frame-%04d.jpg | ||
+ | </pre> | ||
+ | Alternate syntax: | ||
+ | <pre> | ||
+ | ffmpeg -i input.mov -vcodec copy frame-%04d.jpg | ||
+ | </pre> | ||
+ | |||
+ | == Extract best quality of still images from a video == | ||
+ | |||
+ | '''Note''', see [[#MJPEG]] for even better quality if the video is in '''MJPEG''' format. | ||
+ | |||
+ | See the options '''-qscale:v''' or the alias '''-q:v'''. | ||
+ | <pre> | ||
+ | ffmpeg -i input.mp4 -qscale:v 1 frame-%04d.jpg | ||
+ | # or | ||
+ | ffmpeg -i input.mp4 -q:v 1 frame-%04d.jpg | ||
+ | Note that some people say to use '''1''' for the quality value, but others say to use '''2'''. I found that '''1''' seemed to work. | ||
+ | <pre> | ||
+ | ffmpeg -i input.mp4 -qscale:v 2 frame-%04d.jpg | ||
+ | </pre> | ||
+ | |||
</pre> | </pre> | ||
Revision as of 03:34, 16 March 2019
MJPEG
You can check if your video is in MJPEG format using ffprobe. You should get the output codec_name=mjpeg.
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=nw=1 input.mov
You can extract lossless individual JPEG images from an MJPEG file. Note the two form of syntax that may be required depending on the version of ffmpeg being used.
ffmpeg -i input.mov -codec:v copy -bsf:v mjpeg2jpeg frame-%04d.jpg
Alternate syntax:
ffmpeg -i input.mov -vcodec copy frame-%04d.jpg
Extract best quality of still images from a video
Note, see #MJPEG for even better quality if the video is in MJPEG format.
See the options -qscale:v or the alias -q:v.
ffmpeg -i input.mp4 -qscale:v 1 frame-%04d.jpg # or ffmpeg -i input.mp4 -q:v 1 frame-%04d.jpg Note that some people say to use '''1''' for the quality value, but others say to use '''2'''. I found that '''1''' seemed to work. <pre> ffmpeg -i input.mp4 -qscale:v 2 frame-%04d.jpg
Create video from a sequence of images
If there is no format to the images you want to convert then you must use the pattern_type option:
ffmpeg -pattern_type glob -i "image-*.jpg" video.mov
ffmpeg -framerate 10 -pattern-type glob -i "*.jpg" -c:v libx264 -pix_fmt yuv420p -crf 23 output.mov