LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Using ffmpeg for cut first 1 minute of flac files (https://www.linuxquestions.org/questions/linux-software-2/using-ffmpeg-for-cut-first-1-minute-of-flac-files-866234/)

sina_saeedi82 03-03-2011 09:53 AM

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?

David the H. 03-03-2011 10:20 AM

Use the -t option to specify the amount of time to encode, as specified in the ffmpeg man page.

sina_saeedi82 03-03-2011 11:12 AM

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.

H_TeXMeX_H 03-03-2011 12:06 PM

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


PDock 03-03-2011 03:37 PM

Quote:

Originally Posted by sina_saeedi82 (Post 4277870)
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.

sina_saeedi82 03-09-2011 08:21 AM

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.


All times are GMT -5. The time now is 04:06 PM.