As indicated in the comments, you should return
the string, not echo
it:
add_shortcode('yt', 'getYoutubeDetails');
function getYoutubeDetails($atts) {
extract(shortcode_atts(array(
'video' => ''
), $atts));
// Get YouTube data via the API
$JSON = file_get_contents("https://gdata.youtube.com/feeds/api/videos?q=$video&alt=json");
$JSON_Data = json_decode($JSON);
$views = $JSON_Data->{'feed'}->{'entry'}[0]->{'yt$statistics'}->{'viewCount'};
$views = number_format($views);
$duration = $JSON_Data->{'feed'}->{'entry'}[0]->{'media$group'}->{'yt$duration'}->{'seconds'};
$s = "<iframe width=\"1280\" height=\"720\" src=\"//www.youtube.com/embed/$video?showinfo=0&rel=0&modestbranding=1&theme=light&iv_load_policy=3&autohide=1&enablejsapi=1\" frameborder=\"0\" allowfullscreen></iframe>";
$s .= "<strong>Views:</strong> $views<br><strong>Duration:</strong> ";
$s .= sec2hms($duration);
$s .= "<br /><br />";
return $s;
}