If you have the choice, JS version is easier. Plus, I don't have all the details of what you are trying to do, but videos are loaded client side so I think downloading videos server side only to check the duration is not the best option.
var video = $("#myVideo")[0];
var duration;
// Use of interval to fix issue http://stackoverflow.com/questions/2221029/problem-retrieving-html5-video-duration
var interval = window.setInterval(function() {
// Video not ready yet
if (video.readyState <= 0)
return;
duration = video.duration;
$("#myTitle").text('Duration : ' + duration.toFixed(2) + 's');
clearInterval(interval);
}, 200);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<video id="myVideo" width="300" height="150" src="http://media.jilion.com/videos/demo/midnight_sun_sv1_1_450p.mp4"></video>
<h3 id="myTitle"></h3>