[opensuse] BASH: wma to mp3, stuck trying mplayer to named pipe to lame? Help?
BASH/Audio gurus, I'm working on a script that I hoped would eliminate the intermediate wav file in the process of converting my wma files to mp3. I created a named pipe with "mkfifo mppipe" (named for mplayer-pipe). What I am trying to do in the script is: WMAFILE=$1 MP3FILE=${WMAFILE%.*}.mp3 WAVFILE=/home/david/music/mppipe lame --preset extreme ${WAVFILE} ${MP3FILE} mplayer -vo null -vc dummy -af resample=44100 -ao pcm:file=${WAVFILE} ${WMAFILE} When running the script like this, lame just hangs waiting on the data and never passes control to mplayer. If I try it the other way around, to start writing to the pipe before calling lame like this: mplayer -vo null -vc dummy -af resample=44100 -ao pcm:file=${WAVFILE} ${WMAFILE} lame --preset extreme ${WAVFILE} ${MP3FILE} Then mplayer just hangs and never starts playing. Doing things without the pipe and just using an intermediate wave file works just fine like this: WMAFILE=$1 MP3FILE=${WMAFILE%.*}.mp3 WAVFILE=/home/david/music/imwave.wav mplayer -vo null -vc dummy -af resample=44100 -ao pcm:file=${WAVFILE} ${WMAFILE} lame --preset extreme ${WAVFILE} ${MP3FILE} mv $WAVFILE ${WMAFILE%.*}.wav I just kept the wave file this time to test..., I can always just delete it, but I thought the pipe would speed things up a bit. So how can I make use of the named pipe to eliminate the wave file? Does the named pipe really buy me anything as far as speed goes, etc.. or should I just use the wave file and delete it? I was hoping to find a way to have mplayer start writing and lame start encoding in parallel. Is this possible, or am I just nuts? Thanks. -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 2009-05-07 08:44, David C. Rankin wrote:
BASH/Audio gurus,
I'm working on a script that I hoped would eliminate the intermediate wav file in the process of converting my wma files to mp3. I created a named pipe with "mkfifo mppipe" (named for mplayer-pipe). What I am trying to do in the script is:
<snip> If you don't mind using another tool for the job, heres an example of converting wma to mp3 with ffmpeg: ffmpeg -i test.wma -acodec libmp3lame -ab 192k -ac 2 -ar 44100 test.mp3 Kind regards Sylvester Lykkehus -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Hallo,
If you don't mind using another tool for the job, heres an example of converting wma to mp3 with ffmpeg: ffmpeg -i test.wma -acodec libmp3lame -ab 192k -ac 2 -ar 44100 test.mp3
Das hat mich dazu animiert das ganze auch mal zu probieren um m4a nach mp3 zu verwandeln. Leider bricht ffmpeg ab mit einer Fehlermeldung: [libmp3lame @ 0x8084360]lame: output buffer too small (buffer index: 9404, free bytes: 388) Audio encoding failed Zu schade. Gruss Karl -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Karl Sinn wrote:
Hallo,
If you don't mind using another tool for the job, heres an example of converting wma to mp3 with ffmpeg: ffmpeg -i test.wma -acodec libmp3lame -ab 192k -ac 2 -ar 44100 test.mp3
Das hat mich dazu animiert das ganze auch mal zu probieren um m4a nach mp3 zu verwandeln. Leider bricht ffmpeg ab mit einer Fehlermeldung:
[libmp3lame @ 0x8084360]lame: output buffer too small (buffer index: 9404, free bytes: 388) Audio encoding failed
Zu schade.
Gruss Karl
Hmmm... Karl, I take it the translation is something like "it doesn't work and exits with an error.."? I found this: On: http://ffmpeg.arrozcru.org/forum/viewtopic.php?f=1&t=935 This seems to be fixed by going back to 3.98 or 3.97 versions of lame. Looks like a bug -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
David C. Rankin wrote:
Karl Sinn wrote:
Hallo,
If you don't mind using another tool for the job, heres an example of converting wma to mp3 with ffmpeg: ffmpeg -i test.wma -acodec libmp3lame -ab 192k -ac 2 -ar 44100 test.mp3 Das hat mich dazu animiert das ganze auch mal zu probieren um m4a nach mp3 zu verwandeln. Leider bricht ffmpeg ab mit einer Fehlermeldung:
[libmp3lame @ 0x8084360]lame: output buffer too small (buffer index: 9404, free bytes: 388) Audio encoding failed
Zu schade.
Gruss Karl
Hmmm... Karl,
I take it the translation is something like "it doesn't work and exits with an error.."? I found this:
On:
http://ffmpeg.arrozcru.org/forum/viewtopic.php?f=1&t=935
This seems to be fixed by going back to 3.98 or 3.97 versions of lame.
Looks like a bug
Looks like a bug that isn't really a bug: The encoding actually completes without a problem despite the output buffer too small error, see: http://drupal.org/node/376012 (quoted: May 7, 2009) Two notes: 1. The error message doesn't actually matter. Audio encoding has NOT failed and you will have a watchable output video in your destination directory. Annoying that it reports a failure when it actually hasn't failed. Explanation is on this page: http://howto-pages.org/ffmpeg/ The error message about the output buffer being too small is nothing important. It's merely a result of the way data is passed between ffmpeg and the external codec, LAME. 2. The FFMpeg guys say this is fixed in the latest source, though I can't verify that: http://archives.free.net.ph/message/20081119.105257.374f3774.en.html -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thu, May 7, 2009 at 9:15 AM, David C. Rankin
2. The FFMpeg guys say this is fixed in the latest source, though I can't verify that: http://archives.free.net.ph/message/20081119.105257.374f3774.en.html
Why not use mencoder to do what you need? It's part of Mplayer and should do the conversion just like ffmpeg, since ffmpeg is built into mencoder. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
I take it the translation is something like "it doesn't work and exits with an error.."? I found this:
:-) Perfect translation, I'm sorry I must have thought that this thread is on the german speaking list.
On:
http://ffmpeg.arrozcru.org/forum/viewtopic.php?f=1&t=935
This seems to be fixed by going back to 3.98 or 3.97 versions of lame.
Thanks for all the information. I checked the output file, and it does work also. So one more question: How can I apply this to all the m4a files in all subdirectories? Thanks Karl -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Karl Sinn wrote:
<snip>
Thanks for all the information. I checked the output file, and it does work also.
So one more question: How can I apply this to all the m4a files in all subdirectories?
Thanks Karl
Something like: find /path/to/m4a-files/ -name "*.m4a" -print0 | xargs -0 -i ffmpeg -i {} -acodec libmp3lame -ab 192k -ac 2 -ar 44100 {}.mp3 Note: Mind the word-wrap, the above is a single line. The command above encodes/converts the files in serial (one-by-one). The converted files will be placed in the same directory as the original, and their names will be ending in .m4a.mp3, you can rename them later if you wish (krename is a breeze if you'd like a gui for bulk renaming). Feel free to come up with alternatives :-) Kind regards Sylvester Lykkehus -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Sylvester Lykkehus wrote:
On 2009-05-07 08:44, David C. Rankin wrote:
BASH/Audio gurus,
I'm working on a script that I hoped would eliminate the intermediate wav file in the process of converting my wma files to mp3. I created a named pipe with "mkfifo mppipe" (named for mplayer-pipe). What I am trying to do in the script is:
<snip>
If you don't mind using another tool for the job, heres an example of converting wma to mp3 with ffmpeg: ffmpeg -i test.wma -acodec libmp3lame -ab 192k -ac 2 -ar 44100 test.mp3
Kind regards Sylvester Lykkehus
Sylvester, That Rocks! The output is about 5-7% smaller than using the method I did (I think the lead-in is shorter), but the conversion works just fine. Thanks. -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thu, 2009-05-07 at 08:29 -0500, David C. Rankin wrote:
Sylvester Lykkehus wrote:
On 2009-05-07 08:44, David C. Rankin wrote:
BASH/Audio gurus,
I'm working on a script that I hoped would eliminate the intermediate wav file in the process of converting my wma files to mp3. I created a named pipe with "mkfifo mppipe" (named for mplayer-pipe). What I am trying to do in the script is:
<snip>
If you don't mind using another tool for the job, heres an example of converting wma to mp3 with ffmpeg: ffmpeg -i test.wma -acodec libmp3lame -ab 192k -ac 2 -ar 44100 test.mp3
Kind regards Sylvester Lykkehus
Sylvester,
That Rocks! The output is about 5-7% smaller than using the method I did (I think the lead-in is shorter), but the conversion works just fine. Thanks.
Can we convince you to pass up the finished working script in a message tagged solved at the end of it? For posterity's sake? ;) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Mike McMullin wrote:
On Thu, 2009-05-07 at 08:29 -0500, David C. Rankin wrote:
Sylvester Lykkehus wrote:
On 2009-05-07 08:44, David C. Rankin wrote:
BASH/Audio gurus,
I'm working on a script that I hoped would eliminate the intermediate wav file in the process of converting my wma files to mp3. I created a named pipe with "mkfifo mppipe" (named for mplayer-pipe). What I am trying to do in the script is: <snip>
If you don't mind using another tool for the job, heres an example of converting wma to mp3 with ffmpeg: ffmpeg -i test.wma -acodec libmp3lame -ab 192k -ac 2 -ar 44100 test.mp3
Kind regards Sylvester Lykkehus Sylvester,
That Rocks! The output is about 5-7% smaller than using the method I did (I think the lead-in is shorter), but the conversion works just fine. Thanks.
Can we convince you to pass up the finished working script in a message tagged solved at the end of it? For posterity's sake? ;)
Sure, And I'll even try and make it look pretty;-) -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
In <4A028349.4040208@suddenlinkmail.com>, David C. Rankin wrote:
BASH/Audio gurus,
I'm working on a script that I hoped would eliminate the intermediate wav file in the process of converting my wma files to mp3. I created a named pipe with "mkfifo mppipe" (named for mplayer-pipe). What I am trying to do in the script is:
WMAFILE=$1 MP3FILE=${WMAFILE%.*}.mp3 WAVFILE=/home/david/music/mppipe
lame --preset extreme ${WAVFILE} ${MP3FILE} mplayer -vo null -vc dummy -af resample=44100 -ao pcm:file=${WAVFILE} ${WMAFILE}
When running the script like this, lame just hangs waiting on the data and never passes control to mplayer. If I try it the other way around, to start writing to the pipe before calling lame like this:
Right, making a pipe doesn't change how your shell works. It still waits for one command to finish before starting the next one. lame doesn't finish because the blocks trying to read data from the pipe -- no data is available.
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:file=${WAVFILE} ${WMAFILE} lame --preset extreme ${WAVFILE} ${MP3FILE}
Then mplayer just hangs and never starts playing. Doing things without the pipe and just using an intermediate wave file works just fine like this:
Similar here, but mplayer never finishes because it block trying to write data to the pipe -- pipes only have an internal buffer of 4k or so.
So how can I make use of the named pipe to eliminate the wave file?
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:file=${WAVFILE} ${WMAFILE} & lame --preset extreme ${WAVFILE} ${MP3FILE} It is a minor change, but required. Ending a command with a single '&' tells the shell to run it in the background (mostly) so the shell will start lame to consume the data created by mplayer in a streaming fashion. However, commands in the background may end up blocking when they try and write to your terminal. Having more that one process (shell + 1 or more background processes) writing to your terminal is a recipe for confusion at least. To prevent the blocking you might make more changes to the commands you write: nohup mplayer -vo null -vc dummy -af resample=44100 -ao pcm:file=${WAVFILE} ${WMAFILE} <>/dev/null >&0 2>&1 & lame --preset extreme ${WAVFILE} ${MP3FILE} (Alternatively, you might use screen to start both commands in separate terminals, so you can see the progress of either.) -- Boyd Stephen Smith Jr. ,= ,-_-. =. bss@iguanasuicide.net ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/
On Thu, 7 May 2009 21:09:15 Boyd Stephen Smith Jr. wrote:
In <4A028349.4040208@suddenlinkmail.com>, David C. Rankin wrote:
BASH/Audio gurus,
I'm working on a script that I hoped would eliminate the intermediate wav file in the process of converting my wma files to mp3. I created a named pipe with "mkfifo mppipe" (named for mplayer-pipe). What I am trying to do in the script is:
[...] Why not use ffmpeg? You can convert directly from wma to mp3 in one step (in better than real time)... Regards, Rodney. -- =================================================== Rodney Baker VK5ZTV rodney.baker@iinet.net.au ===================================================
Rodney Baker wrote:
On Thu, 7 May 2009 21:09:15 Boyd Stephen Smith Jr. wrote:
In <4A028349.4040208@suddenlinkmail.com>, David C. Rankin wrote:
BASH/Audio gurus,
I'm working on a script that I hoped would eliminate the intermediate wav file in the process of converting my wma files to mp3. I created a named pipe with "mkfifo mppipe" (named for mplayer-pipe). What I am trying to do in the script is:
[...]
Why not use ffmpeg? You can convert directly from wma to mp3 in one step (in better than real time)...
Regards, Rodney.
Boyd, Rodney, Thanks for your help! I'm kicking myself for not thinking about backgrounding the process. After I went to be I was actually thinking about using a subshell in the script to try and make it work, but I like your solution. Rodney, yep, this old dog is learning a new trick. Sylvester provided the ffmpeg solution that works great. I need to read up a bit more on ffmpeg because the single ffmpeg conversion seem to chop the lead-in down just a bit that is noticeable when starting playback from amarok, but when played with noatun there isn't any noticeable difference?? -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Hello, On Thu, 07 May 2009, David C. Rankin wrote:
BASH/Audio gurus,
I'm working on a script that I hoped would eliminate the intermediate wav file in the process of converting my wma files to mp3. I created a named pipe with "mkfifo mppipe" (named for mplayer-pipe). What I am trying to do in the script is:
WMAFILE=$1 MP3FILE=${WMAFILE%.*}.mp3 WAVFILE=/home/david/music/mppipe
lame --preset extreme ${WAVFILE} ${MP3FILE} mplayer -vo null -vc dummy -af resample=44100 -ao pcm:file=${WAVFILE} ${WMAFILE}
A non-obvious variant, that took me too a bit of experimenting. Let the bash handle file descriptors! *g*: lame --preset extreme \ <( mplayer -msglevel all=-1 -novideo -vc null -vo null \ -ao pcm:waveheader:file=/dev/stdout \ -af volnorm,resample=44100 "${WMAFILE}" ) \ "$MP3FILE" Cool, innit? And lame shows something like: Encoding /dev/fd/63 to t.mp3 (if $MP3FILE is "t.mp3" ;) and it shows the normal progess stuff. (you might prefer mplayer -af ... over ffmpeg because of available filters, after all...) What also works, but without progress from lame: mplayer -msglevel all=-1 -novideo -vc null -vo null \ -ao pcm:waveheader:file=/dev/stdout \ -af volnorm,resample=44100 "${WMAFILE}" \ | lame --preset extreme - "$MP3FILE" The relevant mplayer-options are "-msglevel all=-1" and "-ao pcm:file=/dev/stdout" ('-' does not work). HTH (if not in this usecase, some other time), -dnh -- emacs, pr.n. An inferior operating system noted for the lack of a proper editor. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (8)
-
Boyd Stephen Smith Jr.
-
David C. Rankin
-
David Haller
-
Karl Sinn
-
Larry Stotler
-
Mike McMullin
-
Rodney Baker
-
Sylvester Lykkehus