LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 09-07-2005, 11:20 AM   #1
philippeP
LQ Newbie
 
Registered: Sep 2005
Location: Germany
Distribution: Debian sarge/etch
Posts: 18

Rep: Reputation: 0
multiple (equidistant) thumbnails for videos


Hi,

I wrote a small shell script to obtain an HTML page which nicely presents a set of pictures with thumbnail navigation, etc.
I would like to extend my program to treat videos. I know how to extract a single frame (or consecutive frames) of a video using mplayer/mencoder. However since a single thumbnail may not be enough to distinguish videos easily, I would have liked to show 5-10 thumbnails for each video, hence showing some progression of the movie.

The idea would be to have a single command line, in which I give as input a video file and the numbers of frames I want. Independently of the video's length, the program should find out which frame numbers to grab (e.g. video is 2min long with 25fps so those are 3000 frames. If I want 5 thumbnails, than the the program would output the frames numbered 1, 750, 1500, 2250 and 3000).

It doesn't seem like ffmpeg or transcode offer any better option than mplayer, but this could be because those tools offer so many options that I missed the one I need.


Any idea how this can be done at best? Is there a tool which would do something similar?

If not, then how would you do this at best? ("tcprobe" -> get number of frames, then do some shell(perl?) programming to obtain the desired frame numbers and finally call mplayer as many times as I have frames to extract).

Thanks for a possible hint/help.
PhilippeP

PS: I don't know perl, so another solution would be nice ;-)
 
Old 09-08-2005, 03:16 PM   #2
Snowbat
Member
 
Registered: Jun 2005
Location: q3dm7
Distribution: Mandriva 2010.0 x86_64
Posts: 338

Rep: Reputation: 31
Parsing the output of tcprobe seems a good idea but it won't show the total number of frames on some files I have here.

You could use mplayer to dump the frame stats to a text file and then parse the last line of that:
mplayer -benchmark -nosound -vo null Chap.mpg | grep V: > vframes.txt

Edit: It seems there are no newline characters so there is no last line as such. Parsing the last 128 bytes works for the file I'm testing here:
mplayer -benchmark -nosound -vo null Chap.mpg | grep 'V:' | tail -c 128 | cut -d '/' -f2 | cut -d ' ' -f1 > vframes.txt

Last edited by Snowbat; 09-08-2005 at 03:38 PM.
 
Old 09-09-2005, 04:25 AM   #3
Snowbat
Member
 
Registered: Jun 2005
Location: q3dm7
Distribution: Mandriva 2010.0 x86_64
Posts: 338

Rep: Reputation: 31
In the end I didn't bother with frames but used file size and mplayer -sb

Code:
#!/bin/sh

if [ $# -ne 2 ]
then
        echo "Usage: `basename $0` number /path/to/file"
  exit 1
fi

if [ $1 -gt 0 ] && [ $1 -lt 100 ]
then
        echo "Number accepted"
else
        echo "Unrealistic number"
        exit 1
fi

if test -f $2
then
        echo "Media file found"
else
        echo "File $2 not found"
        exit 1
fi

if ls *.jpg
then
        echo "Delete .jpg files in current directory first"
        exit 1
fi
FILESIZE=`ls -l $2 | awk '{print $5}'`
FRAMESREQ=`expr $1 + 1`
COUNT=1
while [ $COUNT -lt $FRAMESREQ ]
do
       OFFSET=`expr $FILESIZE / $FRAMESREQ \* $COUNT`
       echo $COUNT $OFFSET
       mplayer -sb $OFFSET -vo jpeg -frames 2 $2
       mv 00000001.jpg $COUNT.jpg
       COUNT=`expr $COUNT + 1`
done

exit 0
 
Old 07-10-2008, 05:33 PM   #4
docmattman
LQ Newbie
 
Registered: Jul 2008
Posts: 1

Rep: Reputation: 0
What is the command to use for extracting multiple consecutive images from a video file uses FFMPEG? I can extract 1 frame at a time, but I need to extract multiple consecutive frames.
 
  


Reply

Tags
bash, mplayer


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gthumb does not show thumbnails jeffbarish Linux - Software 2 09-14-2005 12:27 PM
Deleting thumbnails from /root/thumbnails directory moxieman99 Linux - Newbie 3 10-19-2004 04:45 PM
Thumbnails in GNOME jeffChuck Linux - Newbie 4 08-01-2004 04:46 AM
Video Thumbnails prompt Linux - Software 1 04-01-2004 06:06 PM
Nautilus Thumbnails RWild Linux - Software 0 07-18-2003 01:58 PM


All times are GMT -5. The time now is 09:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration