matthieugrieger / mumbledj

A Mumble bot that plays audio fetched from various media sites.
MIT License
170 stars 59 forks source link

panic: fork/exec /usr/bin/ffmpeg: exec format error #140

Closed johnhoangn closed 8 years ago

johnhoangn commented 8 years ago

I'm running your mumbledj on a Raspberry Pi 2. Whenever someone adds to the queue, mumbledj kind of just "thinks" about it for a second and then disconnects while dumping an error log to the terminal.

It used to just chat to the channel: The audio download has failed. So I updated youtube-dl, added the ipv4 argument in the config, and updated ffmpeg using MichaelOutram's suggestion in this issue. When I go to check ffmpeg's version with ffmpeg -version I get: bash: /usr/bin/ffmpeg: cannot execute binary file

I then tried sudo chmod a=rx ffmpeg ffprobe before moving the files to /usr/bin yet it still doesn't execute.

arch returns arm7l (I think it's an L) if that could potentially help.

Here's the error log:

Configuration successfully loaded!
Channel doesn't exist or one was not provided, staying in root channel...
**panic: fork/exec /usr/bin/ffmpeg: exec format error**

goroutine 5 [running]:
main.(*AudioTrack).Play(0x10637f80)
/home/pi/mumbledj/youtube_dl.go:87 +0x3b8
main.FindServiceAndAdd(0x106363c0, 0x1060a425, 0x2b, 0x0, 0x0)
/home/pi/mumbledj/service.go:109 +0xb40
main.add(0x106363c0, 0x1060a425, 0x2b, 0x0, 0x0)
/home/pi/mumbledj/commands.go:215 +0x114
main.parseCommand(0x106363c0, 0x1068a0d0, 0x4, 0x1060a421, 0x2f)
/home/pi/mumbledj/commands.go:40 +0x240
main.(*mumbledj).OnTextMessage(0x4d1770, 0x1062ea00)
/home/pi/mumbledj/main.go:100 +0x19c
main.*mumbledj.OnTextMessage·fm(0x1062ea00)
/home/pi/mumbledj/main.go:252 +0x2c
github.com/layeh/gumble/gumbleutil.Listener.OnTextMessage(0x1065cc58, 0x1065cc60, 0x1065cc68, 0x1065cc70, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/home/pi/mumbledj/.vendor/src/github.com/layeh/gumble/gumbleutil/listener.go:39 +0x38
github.com/layeh/gumble/gumbleutil.(*Listener).OnTextMessage(0x1060a990, 0x1062ea00)
<autogenerated>:3 +0xb8
github.com/layeh/gumble/gumble.eventMultiplexer.OnTextMessage(0x10639f60, 0x10639f80, 0x1062ea00)
/home/pi/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/eventmultiplexer.go:62 +0x60
github.com/layeh/gumble/gumble.(*Client).handleTextMessage(0x10636060, 0x10632d90, 0x70, 0x70, 0x0, 0x0)
/home/pi/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/handlers.go:584 +0x968
github.com/layeh/gumble/gumble.(*Client).readRoutine(0x10636060)
/home/pi/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/client.go:185 +0x1b4
created by github.com/layeh/gumble/gumble.(*Client).Connect
/home/pi/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/client.go:118 +0x534

goroutine 1 [chan receive]:
main.main()
/home/pi/mumbledj/main.go:258 +0x103c

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/lib/go/src/runtime/asm_arm.s:1322 +0x4

goroutine 6 [select]:
github.com/layeh/gumble/gumble.(*Client).pingRoutine(0x10636060)
/home/pi/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/client.go:162 +0x2f8
created by github.com/layeh/gumble/gumble.(*Client).Connect
/home/pi/mumbledj/.vendor/src/github.com/layeh/gumble/gumble/client.go:119 +0x55c

goroutine 11 [IO wait]:
net.(*pollDesc).Wait(0x106f3338, 0x72, 0x0, 0x0)
/usr/lib/go/src/net/fd_poll_runtime.go:84 +0x3c
net.(*pollDesc).WaitRead(0x106f3338, 0x0, 0x0)
/usr/lib/go/src/net/fd_poll_runtime.go:89 +0x38
net.(*netFD).Read(0x106f3300, 0x1084e000, 0x1000, 0x1000, 0x0, 0x76cfaac8, 0x10823f6c)
/usr/lib/go/src/net/fd_unix.go:242 +0x390
net.(*conn).Read(0x1065c268, 0x1084e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/lib/go/src/net/net.go:121 +0xc8
crypto/tls.(*block).readFromUntil(0x106a5b80, 0x76cfbf88, 0x1065c268, 0x5, 0x0, 0x0)
/usr/lib/go/src/crypto/tls/conn.go:454 +0xe8
crypto/tls.(*Conn).readRecord(0x106581a0, 0x17, 0x0, 0x0)
/usr/lib/go/src/crypto/tls/conn.go:539 +0x248
crypto/tls.(*Conn).Read(0x106581a0, 0x106fb000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/lib/go/src/crypto/tls/conn.go:904 +0x160
net/http.noteEOFReader.Read(0x76cfc340, 0x106581a0, 0x10636c2c, 0x106fb000, 0x1000, 0x1000, 0x2ec870, 0x0, 0x0)
/usr/lib/go/src/net/http/transport.go:1270 +0x78
net/http.(*noteEOFReader).Read(0x108233a0, 0x106fb000, 0x1000, 0x1000, 0x10612000, 0x0, 0x0)
<autogenerated>:125 +0xec
bufio.(*Reader).fill(0x108163f0)
/usr/lib/go/src/bufio/bufio.go:97 +0x1d8
bufio.(*Reader).Peek(0x108163f0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/lib/go/src/bufio/bufio.go:132 +0xd4
net/http.(*persistConn).readLoop(0x10636c00)
/usr/lib/go/src/net/http/transport.go:842 +0x88
created by net/http.(*Transport).dialConn
/usr/lib/go/src/net/http/transport.go:645 +0xba0

goroutine 12 [select]:
net/http.(*persistConn).writeLoop(0x10636c00)
/usr/lib/go/src/net/http/transport.go:945 +0x320
created by net/http.(*Transport).dialConn
/usr/lib/go/src/net/http/transport.go:645 +0xbc8
matthieugrieger commented 8 years ago

After changing the permissions on ffmpeg are you able to properly execute ffmpeg -version?

johnhoangn commented 8 years ago

No, trying to execute ffmpeg at all returns bash: /usr/bin/ffmpeg: cannot execute binary file.

matthieugrieger commented 8 years ago

There must still be something wrong with your permissions then, I don't think this is related to MumbleDJ. How did you install ffmpeg?

johnhoangn commented 8 years ago

You're probably right. Much like the user in the issue I linked, I believe I messed up the installation because when I try sudo apt-get remove ffmpeg to delete and re-install it, it says the ffmpeg package was not installed to begin with.(Except for when I'm removing the outdated version of ffmpeg). I used Michael's instructions to the letter and I got the executable files into /usr/bin but I feel as if there's more to installing it than placing a couple of binaries into bin. I'm reading a compilation guide as I'm typing this.

matthieugrieger commented 8 years ago

Cool, let me know how it goes! On May 24, 2016 9:07 AM, "John" notifications@github.com wrote:

You're probably right. Much like the user in the issue I linked, I believe I messed up the installation because when I try sudo apt-get remove ffmpeg to delete and re-install it, it says the ffmpeg package was not installed to begin with. I used Michael's instructions to the letter and I got the executable files into /usr/bin but I feel as if there's more to installing it than placing a couple of binaries into bin. I'm reading a compilation guide as I'm typing this.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/matthieugrieger/mumbledj/issues/140#issuecomment-221321184

johnhoangn commented 8 years ago

I followed this guide to download libraries and stuff but when I !add a song it still returns exec format error, and when I try ffmpeg it also still says cannot execute binary file. I checked permissions on the files and their read and execute permissions are, in fact, checked. I should have the rights to them... Your thoughts?

Also, when I sudo the server join command, it says I do not have a Youtube API key defined in my environment variables but when I double checked config.gcfg, both of my Youtube and Soundcloud keys are at the bottom in the quotes, weird.

matthieugrieger commented 8 years ago

If you run the bot with sudo it changes the directory that it looks in for configuration files, so that's why you get that error. Running the bot with sudo isn't recommended.

Do you have avconv installed? It's a fork of ffmpeg that should be easier for you to install. If you're able to install that/already have it installed, just change the PlayerCommand configuration value in the config file from "ffmpeg" to "avconv" and it should work.

johnhoangn commented 8 years ago

I swapped the PlayerCommand to avconv like you suggested. Now Soundcloud links work but with youtube links it displays video information and then nothing happens. With some videos (unsure of why only some) it dumps:

youtube-dl --verbose --no-mtime --output /home/pi/.mumbledj/songs/hBZC4cEk7Hw.bestaudio --format bestaudio --prefer-ffmpeg https://youtu.be/hBZC4cEk7Hw 
[debug] System config: [u'--extract-audio']
[debug] User config: [u'--force-ipv4']
[debug] Command-line args: [u'--verbose', u'--no-mtime', u'--output', u'/home/pi/.mumbledj/songs/hBZC4cEk7Hw.bestaudio', u'--format', u'bestaudio', u'--prefer-ffmpeg', u'https://youtu.be/hBZC4cEk7Hw']
[debug] Encodings: locale UTF-8, fs UTF-8, out None, pref UTF-8
[debug] youtube-dl version 2016.05.21.2
[debug] Python version 2.7.3 - Linux-4.1.7-v7+-armv7l-with-debian-7.10
[debug] exe versions: avconv 9.14-6, avprobe 9.14-6, ffmpeg 0.8.17-6, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] hBZC4cEk7Hw: Downloading webpage
[youtube] hBZC4cEk7Hw: Downloading video info webpage
[youtube] hBZC4cEk7Hw: Extracting video information
[youtube] hBZC4cEk7Hw: Downloading MPD manifest
[debug] Invoking downloader on u'https://r1---sn-vgqs7nls.googlevideo.com/videoplayback?id=841642e1c124ec7c&itag=251&source=youtube&requiressl=yes&ms=au&mv=m&pl=16&mm=31&mn=sn-vgqs7nls&initcwndbps=10525
00&nh=IgpwcjAyLmlhZDI2KgkxMjcuMC4wLjE&ratebypass=yes&mime=audio/webm&gir=yes&clen=265182&lmt=1440401284066708&dur=14.821&sver=3&signature=597C2AF34534C5D53EE54A131738D64263D26C8D.19B3B99B7B57937BE5329E58EB31567A91A3DAC5&mt=1464113062&upn=AcdR5SUMqME&fexp=9406983,9416126,9416891,9422596,9428398,9431012,9432364,9433096,9433223,9433946,9435527,9435876&key=dg_yt0&ip=69.140.120.12&ipbits=0&expire=1464134888&sparams=ip,ipbits,expire,id,itag,source,requiressl,ms,mv,pl,mm,mn,initcwndbps,nh,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: /home/pi/.mumbledj/songs/hBZC4cEk7Hw.bestaudio
[download] 100%!o(MISSING)f 258.97KiB in 00:0079MiB/s ETA 00:000
[debug] ffmpeg command line: avprobe -show_streams file:/home/pi/.mumbledj/songs/hBZC4cEk7Hw.bestaudio
[ffmpeg] Destination: /home/pi/.mumbledj/songs/hBZC4cEk7Hw.mp3
WARNING: Your copy of ffmpeg is outdated, update ffmpeg to version 1.0 or newer if you encounter any errors.
[debug] ffmpeg command line: ffmpeg -y -i file:/home/pi/.mumbledj/songs/hBZC4cEk7Hw.bestaudio -vn -acodec libmp3lame -q:a 5 file:/home/pi/.mumbledj/songs/hBZC4cEk7Hw.mp3
ERROR: audio conversion failed: file:/home/pi/.mumbledj/songs/hBZC4cEk7Hw.bestaudio: could not find codec parameters
Traceback (most recent call last):
File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1782, in post_process
files_to_delete, info = pp.run(info)
File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/ffmpeg.py", line 294, in run
'audio conversion failed: ' + e.msg)
PostProcessingError

youtube-dl: exit status 1

I also noticed the execution line has --prefer-ffmpeg on it even though I changed the PlayerCommand to "avconv". Is this a problem?

In case you check out the URL... it was one of my users who posted that video as a test...

matthieugrieger commented 8 years ago

Yes, that is the issue actually. Good catch.

I'll release an update in a bit that should fix that.

matthieugrieger commented 8 years ago

Alright, try the newest release. It should fix the problem you were having.

johnhoangn commented 8 years ago

The error I posted doesn't show up anymore so at least something was fixed, but the audio still doesn't play after the video information is posted. I'm compiling libav 11 right now to update avconv, it's taking a while so I'll post back later if that works or not.

johnhoangn commented 8 years ago

Updated avconv to 11.6, youtube links still fail to play audio after the information post with no errors in the terminal. My Pi's directory tree is a mess and the SD card has less than 100 MB of free space so I'm thinking about resetting the thing. Do you have any ideas before I start from scratch again?

matthieugrieger commented 8 years ago

I'm assuming it's still an issue with either the ffmpeg installation or the avconv installation.

What distro are you using on your Pi? Raspbian?

johnhoangn commented 8 years ago

Yep, I'm running Raspbian. Last night I downloaded ffmpeg (using their git pull) and an avconv package (file ended in .gz if I remember correctly) and I compiled them using ./configure, make, and make install. Afterwards, I checked their read and execute permissions and sudo copied them to /usr/bin.

Now if I type ffmpeg or avconv I get:

ffmpeg version N-80082-g49640ae Copyright (c) 2000-2016 the FFmpeg developers 
built with gcc 4.6 (Debian 4.6.3-14+rpi1)
configuration:
libavutil         55.25.100 / 55.25.100
libavcodec    57.43.100 / 57.43.100
libavformat   57.37.100 / 57.37.100
libavdevice   57.0.101   / 57.0.101
libavfilter       6.46.100   / 6.47.100
libswscale     4.1.100     / 4.1.100
libswresample 2.0.101   / 2.0.101

and:

avconv version 11.6, Copyright (c) 2000-2014 the Libav developers built on May 24 2016 19:45:05 with gcc 4.6 (Debian 4.6.3-14+rpi1)
Hyper fast Audio and Video encoder
usage: avconv [options] [[infile options] -i infile]... {outfile options] outfile}...

Did I miss any steps or do something wrong? Perhaps I downloaded an incompatible package? Would they fail to compile if that were the case?

matthieugrieger commented 8 years ago

It looks like you have them installed properly, I can't think of anything wrong with your installation process.

Does it still not work?

johnhoangn commented 8 years ago

Yeah, still no luck. This project was actually in the works and handed to me half-way through so I think some paths or directories were improperly set. I'm going to factory restore and start from scratch. Thanks for the speedy update release and help up to this point.

matthieugrieger commented 8 years ago

No problem, let me know if you need any more help.

johnhoangn commented 8 years ago

I got it to work! ...But I can't find the config file. For some reason ~/.mumbledj isn't in $HOME. The first edit was made to the config within the extracted directory. So I think the installation took a copy of it so I have admin rights and the keys were inputted, but I have no idea where ~/.mumbledj/config/mumbledj.gcfg is. I assume I could re-run the make commands, but I would like to avoid doing that every edit.

EDIT: I remember I had to use sudo make install instead of make install because it was saying I didn't have permissions and you mentioned sudo changes where it looks for files; where would that be?

matthieugrieger commented 8 years ago

So the bot successfully finds the configuration file? If so, the file exists in ~/.mumbledj as that is where it looks.

One thing to note is that directories that start with a period do not show up by default in file managers or with ls. Try using ls -a to locate the directory if you haven't already.

If it really doesn't exist in your current user's home directory, then you could check /root/.mumbledj, although I doubt that it would be located there.

johnhoangn commented 8 years ago

Yeah you're right it was hidden. I just about to say I found it when you posted. Thanks though!

matthieugrieger commented 8 years ago

Awesome, glad everything is working now!