Android Question playback video frames

KZero

Active Member
Licensed User
Longtime User
Hi,

i want to stream encrypted live video between 2 devices over the internet (without using RTMP or RTSP servers)

i used CamEx to extract camera frames bytes and encoded it to H264 using android MediaCodec

i want to playback these byte arrays or inputstream using exo player

- i couldn't find a way to get the ByteArrayDataSource as mentioned here
https://exoplayer.dev/doc/reference...d/exoplayer/upstream/ByteArrayDataSource.html


- i found another solution to build Datasource from Inputstream but i'm not able to port it using inline java
https://github.com/google/ExoPlayer/issues/4212

- i tried to save the encoded bytes and even the raw frame bytes to file and open it locally but this didn't work too , i think i have to write video header but i have no idea about it


any ideas would be appreciated
 

KZero

Active Member
Licensed User
Longtime User
If it doesn't play from the saved file then it will not work with ByteArrayDataSource as well. I also don't think that the InputStream solution in that link will help.

It will probably be easier to start with an unencrypted video.
I'm already trying with the unencoded and unencrypted frame bytes extracted directly from Camera1_Preview

and can't play them back when i write it to file with exo or with VLC player


B4X:
Sub Camera1_Preview (PreviewPic() As Byte)

    If BAB.length<15200*100 Then 'BAB is SLByteArrayBuffer
        BAB.AppendByte(PreviewPic,0,PreviewPic.Length)
        Else
        BytesToFile(File.DirInternal,"1.avi",BAB.ToByteArray)
       
VP.Prepare(VP.CreateFileSource(File.DirInternal,"1.avi"))
        Exo.Player=VP
        VP.Play
        BAB.Clear
    End If

End Sub

Sub BytesToFile (Dir As String, FileName As String, Data() As Byte)
    Dim out As OutputStream = File.OpenOutput(Dir, FileName, False)
    out.WriteBytes(Data, 0, Data.Length)
    out.Close
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top