Purpose:
Make an Android app for streaming video and audio to your PC. Files should not be saved anywhere. Atm im works in java at both ends (android / PC) due to finds of the libstreamer and vlcj libraries.
Generally:
I got a video for work, but it does not play audio on a PC. I tried a different encoding for audio. When you try using AAC-VLC, an error message is issued in an unknown format. Does Aint get the same error using the AMRNB format, so do some audio have to go through or am I mistaken? I tried several different RTPS test links from G33Ktricks. Could not find one that does not work with vlcj PC. Logcat to run after connecting the PC to android pastebin
Question:
What am I missing for audio? If you canβt answer this, should I stand on the side of the android or PC to actually find the missing line?
Android:
im using libstreamer and examples from Spydroid to get this working. The code I startet with is in example 1 of the libstreamer package:
public class MainActivity extends Activity {
private final static String TAG = "MainActivity";
private SurfaceView mSurfaceView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mSurfaceView = (SurfaceView) findViewById(R.id.surface);
Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
editor.putString(RtspServer.KEY_PORT, String.valueOf(1234));
editor.commit();
SessionBuilder builder = SessionBuilder.getInstance();
builder.setSurfaceView(mSurfaceView);
builder.setPreviewOrientation(90);
builder.setContext(getApplicationContext());
builder.setAudioEncoder(SessionBuilder.AUDIO_AMRNB);
builder.setAudioQuality(new AudioQuality(8000,16000));
builder.setVideoEncoder(SessionBuilder.VIDEO_H264);
builder.setVideoQuality(new VideoQuality(480,320,10,500000));
builder.setCamera(CameraInfo.CAMERA_FACING_FRONT);
builder.build();
this.startService(new Intent(this,RtspServer.class));
}
}
PC
Using VLCJ for streaming. The code I startet with is in the official vlcj-master package - Example2:
public class Example2
{
private final JFrame frame;
private final EmbeddedMediaPlayerComponent mediaPlayerComponent;
public static void main( String[ ] args )
{
new NativeDiscovery().discover();
final String mrl = "rtsp://10.251.1.107:1234/trackID=0";
SwingUtilities.invokeLater( new Runnable() {
@Override
public void run( )
{
new Example2().start( mrl );
}
} );
}
public Example2( )
{
mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
frame = new JFrame( "vlcj quickstart" );
frame.setLocation( 0, 0 );
frame.setSize( 1400, 800 );
frame.setContentPane( mediaPlayerComponent );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setVisible( true );
}
private void start( String mrl )
{
String[] options = {"--ffmpeg-threads=1"};
EmbeddedMediaPlayer p = mediaPlayerComponent.getMediaPlayer();
p.playMedia( mrl, options );
}
}
SDP
From the android side:
RTSP/1.0 200 OK
Server: MajorKernelPanic RTSP Server
Cseq: 3
Content-Length: 366
Content-Base: 10.251.1.107:1234/
Content-Type: application/sdp
v=0
o=- 0 0 IN IP4 10.251.1.107
s=Unnamed
i=N/A
c=IN IP4 10.251.1.125
t=0 0
a=recvonly
m=audio 5004 RTP/AVP 96
a=rtpmap:96 AMR/8000
a=fmtp:96 octet-align=1;
a=control:trackID=0
m=video 5006 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=428015;sprop-parameter-sets=Z0KAFdoHgpoBtChNQA==,aM4G4g==;
a=control:trackID=1
SETUP 10.251.1.107:1234/trackID=0
Requested audio with 16kbps at 8kHz
source
share