|
|
@ -12,12 +12,12 @@ import com.frank.ffmpeg.R |
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Using FFmpeg to push stream |
|
|
|
* Using FFmpeg to push http-flv stream |
|
|
|
* Created by frank on 2018/2/2. |
|
|
|
* Created by frank on 2018/2/2. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class PushActivity : BaseActivity() { |
|
|
|
class PushActivity : BaseActivity() { |
|
|
|
|
|
|
|
|
|
|
|
private var editFilePath: EditText? = null |
|
|
|
private var editInputPath: EditText? = null |
|
|
|
|
|
|
|
|
|
|
|
private var editLiveURL: EditText? = null |
|
|
|
private var editLiveURL: EditText? = null |
|
|
|
|
|
|
|
|
|
|
@ -32,30 +32,22 @@ class PushActivity : BaseActivity() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun initView() { |
|
|
|
private fun initView() { |
|
|
|
editFilePath = getView(R.id.edit_file_path) |
|
|
|
editInputPath = getView(R.id.edit_file_path) |
|
|
|
editLiveURL = getView(R.id.edit_live_url) |
|
|
|
editLiveURL = getView(R.id.edit_live_url) |
|
|
|
editFilePath!!.setText(FILE_PATH) |
|
|
|
editInputPath!!.setText(INPUT_PATH) |
|
|
|
editLiveURL!!.setText(LIVE_URL) |
|
|
|
editLiveURL!!.setText(LIVE_URL) |
|
|
|
|
|
|
|
|
|
|
|
initViewsWithClick(R.id.btn_push_stream) |
|
|
|
initViewsWithClick(R.id.btn_push_stream) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun startPushStreaming() { |
|
|
|
private fun startPushStreaming() { |
|
|
|
//TODO the video format is flv |
|
|
|
val filePath = editInputPath!!.text.toString() |
|
|
|
val filePath = editFilePath!!.text.toString() |
|
|
|
|
|
|
|
val liveUrl = editLiveURL!!.text.toString() |
|
|
|
val liveUrl = editLiveURL!!.text.toString() |
|
|
|
Log.i(TAG, "filePath=$filePath") |
|
|
|
|
|
|
|
Log.i(TAG, "liveUrl=$liveUrl") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(filePath) && !TextUtils.isEmpty(filePath)) { |
|
|
|
if (!TextUtils.isEmpty(filePath) && !TextUtils.isEmpty(filePath)) { |
|
|
|
val file = File(filePath) |
|
|
|
|
|
|
|
if (file.exists()) { |
|
|
|
|
|
|
|
Thread(Runnable { |
|
|
|
Thread(Runnable { |
|
|
|
FFmpegPusher().pushStream(filePath, liveUrl) |
|
|
|
FFmpegPusher().pushStream(filePath, liveUrl) |
|
|
|
}).start() |
|
|
|
}).start() |
|
|
|
} else { |
|
|
|
|
|
|
|
showToast(getString(R.string.file_not_found)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -71,8 +63,8 @@ class PushActivity : BaseActivity() { |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
|
|
private val TAG = PushActivity::class.java.simpleName |
|
|
|
// storage/emulated/0/beyond.mp4 |
|
|
|
private const val FILE_PATH = "storage/emulated/0/hello.flv" |
|
|
|
private const val INPUT_PATH = "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" |
|
|
|
private const val LIVE_URL = "rtmp://192.168.17.168/live/stream" |
|
|
|
private const val LIVE_URL = "rtmp://192.168.17.168/live/stream" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|