
私はBluetoothアダプタと一緒にRaspberry Pi 0を使用しており、Bluetoothスピーカーでmp3ファイルを再生したいと思います。何度も試したところ、接続に成功しました。すべてが機能するように実行したコマンドの完全なリストは次のとおりです。
rfkill unblock 0
sudo hciconfig hci0 up
sudo hciconfig hci0 piscan
pulseaudio -k
pulseaudio -D
bluetoothctl -a
scan on
connect 30:95:E3:95:46:F7
exit
次に、次のgstreamerコマンドを使用してオーディオをスピーカーにストリーミングします。
gst-launch-1.0 filesrc location=song.mp3 ! pulsesink device=bluez_source.30_95_E3_95_46_F7
これにより、次のエラーが発生します。
pi@raspberrypi:~ $ gst-launch-1.0 filesrc location=song.mp3 ! pulsesink device=bluez_source.30_95_E3_95_46_F7
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstPulseSink:pulsesink0: The stream is in the wrong format.
Additional debug info:
gstaudiobasesink.c(1119): gst_audio_base_sink_preroll (): /GstPipeline:pipeline0/GstPulseSink:pulsesink0:
sink not negotiated.
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
song.mp3
通常のオーディオファイルで、携帯電話、vlc、およびWindows Media Playerで再生できます。スピーカーは私の電話でも動作します。
この問題を解決するにはどうすればよいですか?
答え1
私がやっていることには2つの問題があることがわかりました。
- Gstreamerは時々mp3ファイルをサポートします。 このリンクサポートする形式について。交換すると問題は
filesrc
解決しますが、audiotestsrc ! convertaudio
変換が必要な理由はよくわかりません。 bluez_sink
Bluetoothデバイスがオーディオターゲットであるため、代わりに使用する必要がありますbluez_source
。
これはスピーカーからオーディオを再生する最後のコマンドです。
gst-launch-1.0 audiotestsrc ! pulsesink device=bluez_sink.FC_58_FA_68_B4_8B