Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3753614
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:25:08+00:00 2026-05-19T09:25:08+00:00

I am trying to get a video stream from point A (2.1 android phone)

  • 0

I am trying to get a video stream from point A (2.1 android phone) to point B (my server) in real time. How would I do it? Detailed below are my attempts (a little long, but concise!)


The goal is to get an hour long video recorded with the phone to the server without pausing/stopping the stream. a delay of up to several minutes isn’t a problem. I’ve tried three approaches

  1. thread a FileInputStream that reads from the
    FileDescriptor of the video
    destination
  2. call MediaRecoder.setOutputFile on
    the FD of a ‘sender’ socket. this
    socket connects to a
    LocalSocketServer, whose destination
    is a ‘receiver’ socket.
  3. open a socket to my server and
    giving setOutputFile its FD

unfortunately both attempts have failed.

  1. Only registers 24 bytes whenever i
    call FileInputStream.available(),
    and the actual number of bytes only
    after i call Recorder.stop()
  2. gives me this beautifully useless
    stacktrace

    ERROR/AndroidRuntime(18532): Caused by: java.lang.RuntimeException: start failed.
    ERROR/AndroidRuntime(18532): at android.media.MediaRecorder.start(Native Method)
    ERROR/AndroidRuntime(18532): at com.example.demovideo.DemoVideo.initializeCamera(…)
    …

  3. same error 2

code snippets (parts omitted)

1)

fileOut = new FileOutputStream(pathToFile);
...
recorder.setOutputFile(fileOut.getFD());
recorder.prepare()
recorder.start()

// in an Async Thread
fileIn = FileInputStream(fileOut.getFD);
while (recording) {   
    fos.flush();
    Log.w("---", "bytesAvailable: " + fileIn.available()); //always returns 24
    Thread.sleep(1000);
}

2)

// in a Thread
server = new LocalServerSocket(SOCKET_ADDRESS);
    while (true){
        receiver = server.accept();
        if (receiver != null){
        InputStream input = receiver.getInputStream();
            ... // processing would go here
    }   }

sender = new LocalSocket();
sender.connect(new LocalSocketAddress(SOCKET_ADDRESS));
recorder.setOutputFile(sender.getFileDescriptor());
...
recorder.prepare();
recorder.start(); // <- error
  1. properly saves an uncorrupted video
    to sd
  2. works if I use
    setOutputFile(pathToFile) instead.
    the sockets also work when i run
    sender.getOutputStream().write(message.getBytes());
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:25:08+00:00Added an answer on May 19, 2026 at 9:25 am
    1. I created a mobile-to-server video streaming app with this approach and it worked. So this should be the right approach. Later when I was not part of the project anymore I got reports that this approach did not work with some newer phones – most notably Samsung Galaxy S. The problem was that this phones flushed video data sparingly, just once a minute maybe. What phone are you using to test this?

    2. & 3. MediaRecorder is a wrapper around a native library. I assume that this library wants a concrete file to write to not a pipe. On a file-system level files & pipes look the same, but one can not have random access to a pipe (seeking).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an app to stream video from an ip-camera to android
I'm trying to get the RTSP video stream play in my Android App using
I'm trying to write video stream from my Galaxy Tab to server. according to
I am trying to stream video from Wowza to Android. I tried setting a
I'm trying to get video thumbnails from Vimeo, but for some reason, I cannot
I'm working with PyQt and trying to get video from a webcam to play
I'm trying to get the video data from this youtube playlist feed and add
So, I'm trying to get a video to play from an HTTP url. To
I am trying to get all of the video elements and their attributes from
I'm trying to play video from youtube using this code but I get this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.