Feature: support push rtmp stream with http url

pull/221/head
xufuji456 2 years ago
parent bdb533b9e5
commit f25d25179a
  1. 2
      app/src/main/cpp/ff_http_pusher.cpp
  2. 22
      app/src/main/java/com/frank/ffmpeg/activity/PushActivity.kt
  3. 4
      app/src/main/res/values-en/strings.xml
  4. 4
      app/src/main/res/values/strings.xml

@ -23,6 +23,8 @@ int FFHttpPusher::open(const char *inputPath, const char *outputPath) {
return ret; return ret;
} }
// Flv video: h264 audio: aac/mp3
// If not h264, should transocde to h264
for (int i = 0; i < inFormatCtx->nb_streams; ++i) { for (int i = 0; i < inFormatCtx->nb_streams; ++i) {
AVStream *in_stream = inFormatCtx->streams[i]; AVStream *in_stream = inFormatCtx->streams[i];
const auto *codec = in_stream->codec->codec; const auto *codec = in_stream->codec->codec;

@ -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"
} }
} }

@ -30,8 +30,8 @@
<string name="audio_handle">Audio handle</string> <string name="audio_handle">Audio handle</string>
<string name="media_handle">Media handle</string> <string name="media_handle">Media handle</string>
<string name="video_handle">Video handle</string> <string name="video_handle">Video handle</string>
<string name="video_push">Video pusher</string> <string name="video_push">Http-flv stream</string>
<string name="video_live">Video living</string> <string name="video_live">RTMP living</string>
<string name="media_mux">Media mux</string> <string name="media_mux">Media mux</string>
<string name="media_extra_audio">Audio extract</string> <string name="media_extra_audio">Audio extract</string>

@ -30,8 +30,8 @@
<string name="audio_handle">音频处理</string> <string name="audio_handle">音频处理</string>
<string name="media_handle">音视频处理</string> <string name="media_handle">音视频处理</string>
<string name="video_handle">视频处理</string> <string name="video_handle">视频处理</string>
<string name="video_push">本地推流直播</string> <string name="video_push">http-flv推流</string>
<string name="video_live">实时推流直播</string> <string name="video_live">rtmp推流直播</string>
<string name="media_mux">音视频合成</string> <string name="media_mux">音视频合成</string>
<string name="media_extra_audio">提取音频</string> <string name="media_extra_audio">提取音频</string>

Loading…
Cancel
Save