6

I have created android application in which I have m3u8 streaming links. Now I want the user to record the video at any stage during video play and can stop also where I want. yet I googled it and no solution is available on stack overflow, and other android helping sites. I am New in this section Please help me as soon as possible. Now I am Stuck in this section. One Link I get but not helpful

How to record the http live streaming from an IP Cam

I made it a custom mediaplayer which is following and I just give m3u8 link to that media player and it play using default media player of android

  <FrameLayout
            android:id="@+id/videoSurfaceContainer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/videoplayer_title">

            <SurfaceView
                android:id="@+id/videoSurface"
                android:background="@android:color/transparent"
                android:layout_width="match_parent"
                android:layout_below="@+id/videoplayer_title"
                android:layout_height="200dp"
                />

            <ImageView
                android:id="@+id/videoplayer_icon"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:background="@android:color/transparent"
                android:visibility="gone"
                />

            <ProgressBar
                android:id="@+id/progressbar"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_gravity="center"
                android:layout_below="@+id/videoplayer_title"
                android:background="@android:color/transparent"
                android:visibility="gone"
                />
            <LinearLayout

                android:id="@+id/ll_controls_layout"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:background="@drawable/media_controls_bg"
                android:orientation="vertical"
                android:layout_gravity="bottom"
                android:visibility="visible">

                <RelativeLayout

                    android:layout_width="match_parent"
                    android:layout_height="40dp"


                    >

                    <ImageButton
                        android:id="@+id/pause"
                        android:layout_width="35dp"
                        android:layout_height="35dp"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="5dp"
                        android:background="@android:color/transparent"
                        android:src="@drawable/pause_btn" />


                    <SeekBar
                        android:id="@+id/mediacontroller_progress"
                        android:layout_width="match_parent"
                        android:minHeight="6dip"
                        android:layout_toRightOf="@+id/pause"
                        android:maxHeight="6dip"
                        android:thumb="@drawable/abc_switch_thumb_material"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:progressDrawable="@drawable/styled_progress"
                        android:paddingLeft="15dp"
                        android:paddingRight="15dp"
                        android:layout_toLeftOf="@+id/time_current"
                        android:layout_marginLeft="3dp"
                        android:indeterminate="false"
                        android:visibility="visible"/>

                    <TextView
                        android:id="@+id/time_current"
                        android:layout_width="40dp"
                        android:layout_height="wrap_content"
                        android:layout_centerHorizontal="true"
                        android:textColor="@android:color/white"
                        android:layout_centerVertical="true"
                        android:layout_toLeftOf="@+id/time"
                        android:paddingRight="3dp"
                        android:gravity="right"
                        android:textSize="10dp"
                        android:visibility="gone" />

                    <TextView
                        android:id="@+id/time"
                        android:layout_width="40dp"
                        android:layout_height="wrap_content"
                        android:textColor="@android:color/white"
                        android:gravity="left"
                        android:layout_toLeftOf="@+id/recording_btn"
                        android:layout_centerVertical="true"
                        android:textSize="10dp"
                        android:visibility="gone" />

                    <ImageButton
                        android:id="@+id/recording_btn"
                        android:layout_width="35dp"
                        android:layout_height="35dp"
                        android:layout_centerVertical="true"
                        android:background="@android:color/transparent"
                        android:layout_toLeftOf="@+id/fullscreen"
                        android:src="@drawable/startrecording_btn" />

                    <ImageButton
                        android:id="@+id/fullscreen"
                        android:layout_width="35dp"
                        android:layout_height="35dp"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="4dp"
                        android:layout_marginRight="5dp"
                        android:layout_alignParentRight="true"
                        android:background="@android:color/transparent"
                        android:src="@drawable/ic_media_fullscreen_stretch" />

                </RelativeLayout>
            </LinearLayout>
        </FrameLayout>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • Depending on how you actually play the video, you will need to access whatever track renderers are responsible for video and audio and then write that information to disk and finally combine them into a single file. If you already built a m3u8 player, then you have this information already. If not, first get it playing so that you can see what the data looks like when it comes in. – Ewald Feb 17 '16 at 07:10
  • I edit the code above and i eleborate more to you I just pass m3u8 link to media player and it play that video using default android media player only folwing code which play video player.setDataSource(this, Uri.parse(livechannelurl)); player.setOnPreparedListener(myContext); etc. is it possible from that method to record video at any stage during video play – humayoon siddique Feb 17 '16 at 07:21
  • No unfortunately it's not, you need to get to whatever is actually doing the rendering, because at that point you'd have access to the buffered data. I don't know if you can access the renderer on the default player though. Someone suggested you look at https://github.com/ionull/android-realtime-audio-recorder/blob/master/src/bz/tsung/media/audio/RehearsalAudioRecorder.java as a start - but that's something I know nothing about. – Ewald Feb 17 '16 at 07:27
  • Thanks for response but its not working – humayoon siddique Feb 24 '16 at 05:50
  • I haven't had time to dig into this - I'd like to know the answer as well. I'll see if I can get to it over the weekend - perhaps try a few things. – Ewald Feb 24 '16 at 07:57

0 Answers0