LinuxQuestions.org
Visit Jeremy's Blog.
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 03-03-2011, 10:53 AM   #1
sina_saeedi82
LQ Newbie
 
Registered: Aug 2009
Posts: 6

Rep: Reputation: 0
Question Using ffmpeg for cut first 1 minute of flac files


I have so many flac files. I want to have 1 minute samples of the files in mp3 and a bitrate of 64. (First 1 minute of all files)
How can I do that with ffmpeg command?

Last edited by sina_saeedi82; 03-03-2011 at 10:55 AM.
 
Old 03-03-2011, 11:20 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,848

Rep: Reputation: 2012Reputation: 2012Reputation: 2012Reputation: 2012Reputation: 2012Reputation: 2012Reputation: 2012Reputation: 2012Reputation: 2012Reputation: 2012Reputation: 2012
Use the -t option to specify the amount of time to encode, as specified in the ffmpeg man page.
 
Old 03-03-2011, 12:12 PM   #3
sina_saeedi82
LQ Newbie
 
Registered: Aug 2009
Posts: 6

Original Poster
Rep: Reputation: 0
This works for converting flac to mp3:
ffmpeg -i file.flac -ab 32k -ac 1 -ar 22000 file.mp3

But this does not work:
ffmpeg -ss 00:00:00 -t 60 -i file.flac -ab 32k -ac 1 -ar 22000 file.mp3

The second converts all the file not first 1 minute.

I also want to the converted file be in mono. But -ac 1 makes file in stereo too.
 
Old 03-03-2011, 01:06 PM   #4
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
Decode the flac to wav, re-encode to mp3:

Code:
flac -d --until=01:00 input.flac
lame -b 32 -m m input.wav output.mp3
 
1 members found this post helpful.
Old 03-03-2011, 04:37 PM   #5
PDock
Member
 
Registered: Aug 2004
Distribution: Slack10 & curr. tried numerous
Posts: 189

Rep: Reputation: 37
Quote:
Originally Posted by sina_saeedi82 View Post
This works for converting flac to mp3:
ffmpeg -i file.flac -ab 32k -ac 1 -ar 22000 file.mp3

But this does not work:
ffmpeg -ss 00:00:00 -t 60 -i file.flac -ab 32k -ac 1 -ar 22000 file.mp3

The second converts all the file not first 1 minute.

I also want to the converted file be in mono. But -ac 1 makes file in stereo too.
-t is in the same hh:mm:ss.xxx format as -ss ; thus you were recording the first 60 hours.

`-t duration'
Restrict the transcoded/captured video sequence to the duration specified in seconds. hh:mm:ss[.xxx] syntax is also supported.

ppd


My bad: miss read the documentation however suggest trying alternative long format.

Last edited by PDock; 03-03-2011 at 04:42 PM. Reason: addition
 
Old 03-09-2011, 09:21 AM   #6
sina_saeedi82
LQ Newbie
 
Registered: Aug 2009
Posts: 6

Original Poster
Rep: Reputation: 0
I write this script to make 30 sec samples from my flac archive.
Code:
#!/bin/bash

for FILE in *;
do flac -d --until=00:40 --skip=00:10 "$FILE";
done

for FILE in *.wav;
do lame -b 32 -f -m m "$FILE" "$FILE.mp3";
done

#Remove .wav.mp3 from files and replace .mp3
find $1 -name '*.wav.mp3' | while read file; do
new=$(echo "$file" | sed s/'.wav.mp3/.mp3'/g)
mv "$file" "$new"
done

rm *.wav

x=$(basename `pwd`)
mkdir $x
mv *.mp3 $x
How can I change this script to run in recursive mode? Now I have to copy and paste the script in all the folders and run each one separate. I want it do all the jobs automaticly and I run it just one time.

Last edited by sina_saeedi82; 03-09-2011 at 09:24 AM.
 
  


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
k3b issue with flac files: doesn't recognise the length of files mark_alfred Linux - Software 4 06-22-2010 02:21 AM
cut mpegs with ffmpeg decembersoul Linux - Software 1 08-29-2005 11:59 PM
Internet Connection 20 minute cut-off linmith Slackware 37 02-07-2005 02:54 AM
Playing FLAC Files in Suse gemini2011 Linux - Software 15 12-20-2004 05:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:54 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