Question

I currently am accessing a streaming h264 file and want to save it off for the ability to slice frames. However, I'm having issues saving/opening the .flv file

When pointing to the URL in the address bar - I am told it's an x-flv file.

I then attempt to do the following to save a chunk of the stream.

 URL url = new URL("http://foo.bar.com/foo/bar");

            HttpURLConnection conn = (HttpURLConnection) url
                    .openConnection(proxy);

            conn.setRequestMethod("GET");

            File f = new File("C:\\tmpArea\\tmp.flv");
            FileWriter fr = new FileWriter(f);
            bw = new BufferedWriter(fr);

            BufferedReader br = new BufferedReader(new InputStreamReader(
                    (conn.getInputStream())));
            String output = "";
            int i = 0;
            while (((output = br.readLine()) != null) && i < 100000) {
                bw.write(output);
                i++;
            }

Upon doing this I've attempted to open the file in VLC Media Player and am told:

No suitable decoder module: VLC does not support the audio or video format "undf".

Unfortunately there is no way for you to fix this.

I then thought, well maybe it's not really an FLV file and that's on me. So I used a run of the mill hex-editor. Opening up the file in the HexEditor gives me the following information:

FLV onMetaData duration width height videodatarate framerate videocodecid audiodatarate audiosamplerate audiosamplesize stereo audiocodecid encoder Lavf52.10.6.0 filesize....

Is there a different way I should be trying to save off this data? Is there a conversion/codec issue I'm not seeing?

Was it helpful?

Solution

You are using a Reader and Writer, which are intended to read bytes and convert them to characters, to read a binary file that consists of bytes. The conversion from bytes to characters will corrupt the data. You should be using InputStream and OutputStream instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top