Power & Source of Big Ideas

How can I play an MP3?

Moderators: chensy, FATechsupport

I am sitting here at the root prompt on a Nanopi NEO with Ubuntu 15.10 loaded from the FriendlyARM file.
I can get sound by running the speaker-test program, but I cannot play MP3 files.
I have downloaded and built mpg123 but all it does is complain that it cannot open the default sound device.

For people who CAN play MP3's on this hardware, with this O/S, how did you do it,please?
> I can get sound by running the speaker-test program,
>
So you have connected speaker already and it gives sound.

Try "omxplayer -p -o local song.mp3", it worked for me on Pi Zero [I posted on "seeing" sound via oscilloscope, but later I connected earphones and could hear the music (badly because I did it without diodes and capacitors as described in Adafruit posting)]. Maybe "Changing the GPIO ALTs" from that posting is needed on NanoPi Neo as well.

Code: Select all

Usage: omxplayer [OPTIONS] [FILE]
Options :
...
         -o / --adev  device            audio out device      : e.g. hdmi/local
...
         -p / --passthrough             audio passthrough
...


Hermann.

https://twitter.com/HermannSW/status/761354223300861952
Image
Try "omxplayer -p -o local song.mp3", it worked for me on Pi Zero
Thank you. Unfortunately the "Pi" family is a very different beast from the H3-based NanoPi devices - despite a slight similarity in the name.

Code: Select all

FriendlyARM-root: omxplayer
-bash: omxplayer: command not found
FriendlyARM-root: apt-get install omxplayer
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package omxplayer
The thing that crushes the Nano*** devices and it would appear all the H3 boards is the lack of software and libraries. So although the hardware is great and the price is excellent, when you cost-in the time needed to get anything to work, they fall behind. Because they are different from Pi's, it's not such an easy thing to simply port stuff across.
> So although the hardware is great and the price is excellent, when you cost-in the time needed to get anything to work, they fall behind. Because they are different from Pi's, it's not such an easy thing to simply port stuff across.
>
You are right.

Recently I learned how to install more that can be done by default on Nanopi Ubuntu in this posting:
http://www.friendlyarm.com/Forum/viewtopic.php?f=49&t=206&p=765#p765

I did that on one of my Nanopi Neo, but omxplayer could not be installed. I do not remember whether it could be installed on Raspberry Pi Zero via apt-get, or whether I built it. Just cloned it from github:
https://github.com/popcornmix/omxplayer

Executed "./prepare-native-raspbian.sh" as being told in README.md and then did "make ffmpeg". After quite some downloads ffmpeg's "configure" errors out:

Code: Select all

...
      --enable-decoder=opus \
      --cross-prefix=arm-linux-gnueabihf-
arm-linux-gnueabihf-gcc is unable to create an executable file.
C compiler test failed.

...


So for playing mp3 on Nanopi M1/Neo you need to do the Wily changes from the posting I pointed to, and then try one of the players returned by "apt-cache search mp3".

Or you start with playing .wav files with installed "aplay".

Hermann.
Hi,

I finally found a way to play MP3 songs on Nanopi Neo!

I had not so good experiences with ffmpeg on other computers in the past.
But I just followed the instructions on this page and all was fine:
https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

I had to "configure" with leaving out two libraries I could not find or install:

Code: Select all

apt-get -y install autoconf automake build-essential libfreetype6-dev   libsdl1.2-dev libtheora-dev libtool libvdpau-dev l
ibvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev


Then for MP3 support what is described under section "libmp3lame" without any problems.

And finally "ffmpeg" compilation leaving out the libraries I had not installed, but including "libmp3lame":

Code: Select all

PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure   --prefix="$HOME/ffmpeg_build"   --pkg-config-flags="--static"   --extra-cflags="-I$HOME/ffmpeg_build/include"   --extra-ldflags="-L$HOME/ffmpeg_build/lib"   --bindir="$HOME/bin"   --enable-gpl   --enable-libfreetype   --enable-libmp3lame   --enable-libtheora   --enable-libvorbis   --enable-nonfree


And then I played the first MP3 song, without any high or low pass filters with really good headphone sound quality(!). I just checked same song with omxplayer on Raspberry Pi Zero, and I can identify the song, but quality is really bad. That seems to be the reason why in Adafruit posting pointed to further above they did use high/low pass filters. Maybe Nanopi Neo has the needed filter already built in?

Code: Select all

root@FriendlyARM:~/ffmpeg_sources/ffmpeg# ./ffplay ../../Porcelain.mp3 
ffplay version N-81451-g8a78fc5 Copyright (c) 2003-2016 the FFmpeg developers
  built with gcc 5.2.1 (Ubuntu 5.2.1-22ubuntu2) 20151010
  configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --enable-gpl --enable-libfreetype --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-nonfree
  libavutil      55. 29.100 / 55. 29.100
  libavcodec     57. 54.100 / 57. 54.100
  libavformat    57. 48.100 / 57. 48.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 54.100 /  6. 54.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mp3, from '../../Porcelain.mp3':    0KB sq=    0B f=0/0   
  Metadata:
    title           : Porcelain
    artist          : Moby
    album           : Play
    date            : 2004
    comment         : Amazon.com Song ID: 20796195
    track           : 3
  Duration: 00:04:00.27, start: 0.025057, bitrate: 210 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 210 kb/s
    Metadata:
      encoder         : LAME3.97
    Side data:
      replaygain: track gain - -7.000000, track peak - unknown, album gain - unknown, album peak - unknown,


The good sound was made possible by this new "finger adapter" for the headphones ;-)
Image

Have fun with NanoPi Neo MP3 playing,

Hermann.
Youtube video -- even with volume reduced to 50% it is so loud ;-)

'Nanopi Neo "ffplay"s MP3 via PAM8403 Stereo Audio Amplifier on 89 dB 8 Ω 3W loudspeakers'
phpBB [video]


Hermann.
Today my new (13$) Nanopi M1 arrived, only 13 days after order ;-), and a heatsink for one of my Nanopi Neos.

I removed SD card from one of the Neos and inserted into M1 (they use same OS image).
Then I powered M1 via GND/5V via UART pins (micro USB is definitely possible as well).
And I plugged in earphones into 3.5 audio jack and started "ffplay" as above.
I got good quality MP3 sound immediately on the earphones, as long as I started with volume ≤0.5 ;-)

Hermann.
Image
it's working!!!!!

phpBB [video]
Hi all,
Would you please tell to me how you get sound from Neo? :(
i don't know what configuration needed to play sound or record test. :(
is this necessary to use PAM8403 module? I mean can we connect LineR & LineL of Neo , directly to a simple earphone ( without PAM8403 module)?
what about record sound?
I mixed up :roll:
I will appreciate if someone give a simple schematic or a picture of connections.
Thanks. :)
> Would you please tell to me how you get sound from Neo? :(
>
either with headphones or with amplifier and loudspeakers.

> i don't know what configuration needed to play sound or record test. :(
>
you need some tool to play sound, "ffplay" allows to play .mp3 sound.

> is this necessary to use PAM8403 module?
>
no.

> I mean can we connect LineR & LineL of Neo , directly to a simple earphone ( without PAM8403 module)?
>
Yes, see "finger adapter" photo in this posting above (I do have two v1.0 Neos, pins are different for v1.1 Neo):
http://www.friendlyarm.com/Forum/viewtopic.php?f=47&t=264#p794

> what about record sound?
>
I never did that with the Neo, it is easy with the M1 because that has builtin microphone.

Hermann.
Hi Hermann. I would like to ask you a thing. You compiled ffmpeg inside the board, but how to build it in a desktop system using the friendly arm cross compiler?

G
Hi,

I only once did cross compile the kernel modules successfully:
http://www.friendlyarm.com/Forum/viewtopic.php?f=47&t=240#p801

Since most stuff can be either installed or compiled on the board itself I never had the need to cross compile again for Nanopi. Therefore I cannot help on how to cross compile ffmpeg.

But since you can easily compile ffmpeg as described on the board I don't see the need to cross compile it.

Hermann.
Just did ffplay a .mp3 file on M1 with earphones and did run "top" in another shell.
ffplay uses 26% of a single core:

Code: Select all

top - 11:09:46 up 17 min,  2 users,  load average: 1.45, 1.19, 0.79
Tasks:  78 total,   1 running,  77 sleeping,   0 stopped,   0 zombie
%Cpu0  :  0.0 us,  3.1 sy,  0.0 ni, 96.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  : 10.9 us,  1.0 sy,  0.0 ni, 88.1 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  :  4.0 us,  1.0 sy,  0.0 ni, 94.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  0.0 us,  6.1 sy,  0.0 ni, 93.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:    507328 total,   126396 used,   380932 free,    14192 buffers
KiB Swap:        0 total,        0 used,        0 free.    61580 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND     
  375 root      20   0  124324   6764   3860 S  26.3  1.3   0:57.33 ffplay     
  414 root      20   0    2804   1020    712 R   2.9  0.2   0:04.07 top         
...


Code: Select all

$ bc -ql
400-96.9-88.1-94.9-93.9
26.2


Hermann.

Who is online

In total there are 11 users online :: 0 registered, 0 hidden and 11 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 11 guests