Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calculating video file duration

 
andrea gabrieli
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm searching a java library to calculate video file duration for all possible video formats (flv, mpeg, avi, mp4).
I've tried "getDuration()" (class player" into package javax.media) but it's wrong for my porpouse.

Peraphs jffmpeg (net.sourceforge.jffmpeg.VideoDecoder)?
Has someone ever tried it?
where can i Find some explampe code?

Thank you,
bye

Andrea
 
andrea gabrieli
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
resolved
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch and well done but please tell us how you did it.
 
andrea gabrieli
Greenhorn
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've used ffmpeg.exe. I execute this file and it returns a string with duration value inside.
There is ffmpeg version also for Mac and I select to execute ffmpeg.exe or ffmpeg according to os version.
Here the code:




Bye,
andrea
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. I have added code tags, which improve your post. Don’t use [b] or similar tags inside code tags.
 
Andrew Polansky
Ranch Hand
Posts: 310
18
Linux MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another excavation, heh heh.

The code is great. It generates the duration as a String in format like this: "00:05:04.55".

If somebody needs an integer which represents the duration as seconds, as I need, here is the code to do this:



"res" is the string containing the duration as a String, as it is in the Andrea's code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic