LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 05-18-2012, 04:26 PM   #1
spezticle
Member
 
Registered: May 2010
Distribution: Ubuntu 10.04
Posts: 30

Rep: Reputation: 0
multithreading ffmpeg


so i've been using
Code:
for f in *.flac; do ffmpeg -i "$f" -acodec alac "${f/.flac/}".m4a; done
it works great to encode all the files that are .flac to apples lossless with the m4a container.

is there a way for me to tell it to run on multiple threads so i can encode more files, faster?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-19-2012, 09:03 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
no, multithreading will not work, but you can try multitasking. To do this you need to add a & at the end of the command:
for f in *.flac; do ffmpeg .... &; done
 
Old 05-20-2012, 02:04 AM   #3
lej
LQ Newbie
 
Registered: Aug 2011
Location: UK
Distribution: Slackware
Posts: 29

Rep: Reputation: Disabled
ffmpeg supports threads, see the -threads option. This is unlikely to provide a linear increase in performance, however. I would rather run one instance per cpu/core.

The problem with using a simple & is that you lose control over how many intances are started. Running more instances than you have cpus will slow things down. The shell doesn't have any builtin support for doing this, though there are ways to work around it.

Alternatively, you could always write a little Makefile and use make -j N. This will also have the advantage of skipping files that have already been encoded.

Code:
files:= $(patsubst %.flac,%.m4a,$(wildcard *.flac))

all: $(files)

%.m4a : %.flac
        @ffmpeg -i $< -acodec alac $@
edit: you need to make sure that the '@ffmpeg ...' line is indented with a tab, since the tab is expanded to spaces when posted/pasted.

Last edited by lej; 05-20-2012 at 02:55 AM.
 
2 members found this post helpful.
Old 05-21-2012, 09:17 PM   #4
lazardo
Member
 
Registered: Feb 2010
Location: SD Bay Area
Posts: 270

Rep: Reputation: Disabled
Versions > 8.10 are multi-threaded.

http://www.ffmpeg.org/

Cheers,
 
Old 05-22-2012, 01:04 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
actually ffmpeg itself may or may not be multithreaded, but it can process only one file. So based on the original post:
Quote:
is there a way for me to tell it to run on multiple threads so i can encode more files, faster
In general if you have several cores you can speed up the conversion by ffmpegs' internal multithreading. In case you want to convert several files this kind of multithreading will have no meaning because you can start all the conversions at the same time and they will surely eat up all your resources (this was described in my previous post).
As lej wrote you can write a simple makefile to control the number of instances, but using this together with multithreading will not give you the expected result.
 
  


Reply

Tags
ffmpeg, multithreading



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
ffmpeg.SlackBuild: line 194: cd: /tmp/SBo/package-ffmpeg/usr/man: No such file or dir darkstarbyte Linux - Software 7 12-29-2010 05:45 PM
Install FFMPEG and FFMPEG-PHP on fedora10 & 12 cks Linux - Server 2 09-17-2010 01:55 PM
Help me in installing ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encod mitesh.ever Red Hat 5 05-16-2009 12:14 PM
Does the latest version of ffmpeg not work with ffmpeg-php? whitey4900 Linux - Software 0 08-04-2008 05:16 PM

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

All times are GMT -5. The time now is 11:25 PM.

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