LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-12-2018, 02:49 PM   #1
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Rep: Reputation: Disabled
Using ffprobe to sort videos


I currently have a bash script to sort downloaded video files into separate sub dirs for TV shows and films.
There is a lot more to the script, however the main sort function for detecting short videos simply from file size is below:

Code:
find /home/Download/ -type f \( -iname \*.mkv -o -iname \*.avi -o -iname \*.wmv -o -iname \*.mp4 -o -iname \*.m4v \) -size -8000M -exec mv {} -f /home/Videos/Shortform/  \;
Of course it's easy for this form of sort to get it wrong, especialy if sorting files that are not 1080P.
I've recently found the following bit of code:

Code:
ffprobe -v quiet -of csv=p=0 -show_entries format=duration *
This returns the length of video files in seconds. Therefore it's a much better way of detecting TV shows from films, ie anything below 4,200 seconds (70mins) is a TV show, anything above is a film. Again not fool proof but better than doing it via file size.

What I'm attempting to work out is the syntax for how to initiate a mv command for any file that ffprobe returns a length in seconds under 4,200.

Many thanks for any help.
Tim
 
Old 04-12-2018, 04:54 PM   #2
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,950

Rep: Reputation: 513Reputation: 513Reputation: 513Reputation: 513Reputation: 513Reputation: 513
Why not try mediainfo - this gives copious info, so something like
Code:
mediainfo 'some film.mp4' | grep --max-count=1 Duration
might give
Quote:
Duration : 1h 56mn
 
Old 04-13-2018, 09:50 AM   #3
snowman81
Member
 
Registered: Aug 2006
Location: Michigan
Distribution: Ubuntu
Posts: 282

Rep: Reputation: 30
I recently wrote a script for something like this but I was using the audio channels as my key. Make your command into a variable and use if statements.

Code:
$duration = ffprobe -v quiet -of csv=p=0 -show_entries format=duration *

if [$duration -gt 70]....etc..
 
  


Reply


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
Why do some tools (e.g. ffprobe) split their output between sdtout and stderr ? markus-n Linux - General 6 01-07-2018 04:21 PM
Is there a sort of 2nd SSH daemon server, sort of JAILKIT, in the debian repositories frenchn00b Debian 5 06-20-2010 05:03 AM
Can I use GNU sort to sort one field in order, another in reverse? zombieite Linux - Newbie 4 04-27-2009 01:23 AM
selection sort compiles but does not sort the array as desired ganesha Programming 2 04-20-2008 08:44 AM
Is there a line limit with the sort utility? Trying to sort 130 million lines of text gruffy Linux - General 4 08-10-2006 09:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:55 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
Open Source Consulting | Domain Registration