If the video is not a live stream, you can find a suitable answer in this piece of code that I wrote some time ago for a small media project. This is PHP, but you can apply the same concept to other languages.
public function actionAjaxSetThumbnailFromFrame()
{
if(!isset($_POST['Video'], $_POST['Video']['id']) || !isset($_POST['time']))
throw new CHttpException(400,'Invalid request.');
$video = Video::model()->findByPk($_POST['Video']['id']);
$path = Utils::generateUniquePath("thumbnail.jpg", Config::getParam('mediaPath'));
$command = "ffmpeg -itsoffset -{$_POST['time']} -i \"$video->filePath\" -vframes 1 -an -f image2 \"$path\"";
exec(
$command,
$out,
$retval
);
$thumbnail = new Image();
$thumbnail->name = basename($path);
$thumbnail->serverUrl = '';
$thumbnail->filePath = $path;
$thumbnail->relativeServerUrl = Utils::relativeUrlPath($path);
$thumbnail->save();
[...]
}
, .
ffmpeg (http://ffmpeg.org/), .
:
$command = "ffmpeg -itsoffset -{$_POST['time']} -i \"$video->filePath\" -vframes 1 -an -f image2 \"$path\"";
Java - :
String command = "ffmpeg -itsoffset -"+time+" -i \""+videoPath+"\" -vframes 1 -an -f image2 \""+screenshotPath+"\"";
Process child = Runtime.getRuntime().exec(command);
javascript ajax- .