gpt4 book ai didi

FFMPEG - 如何将多个 RTMP 流录制到多个文件中

转载 作者:行者123 更新时间:2023-12-04 23:00:37 28 4
gpt4 key购买 nike

我尝试了以下方法,但它不起作用。

ffmpeg -i rtmp://83.229.210.89/RAZTV/BTVraztv1 -map 0 -b:v 900k -vcodec libx264 -acodec aac -b:a 256k -strict -2 -t 3600 /media/TV_1T_3T_6/ffmpegtest/ort.mp4 -i rtmp://mirtv.cdnvideo.ru/mirtv-live/mirtv600.sdp -map 1 -b:v 900k -vcodec libx4 -acodec aac -b:a 256k -strict -2 -t 3600 /media/TV_1T_3T_6/ffmpegtest/mir.mp4 -i rtmp://chanson.cdnvideo.ru/chanson-live/shansontv.sdp -map 2 -b:v 900k -vcodec libx264 -acodec aac -b:a 256k -strict -2 -t 3600 /media/TV_1T_3T_6/ffmpegtest/shansontv.mp4 -i rtmp://83.229.210.89:1935/TROTV/BTVtro0 -map 3 -b:v 900k -vcodec libx264 -acodec aac -b:a 256k -strict -2 -t 3600 /media/TV_1T_3T_6/ffmpegtest/tro.mp4

看起来它卡在第二条流上并且没有移动。求救请帮忙。
我有 4 个流 URL。我希望他们同时录制。
With one ffmpeg command:
I want: rtmp://83.229.210.89/RAZTV/BTVraztv1 to record into file: /media/TV_1T_3T_6/ffmpegtest/ort.mp4

I want: rtmp://mirtv.cdnvideo.ru/mirtv-live/mirtv600.sdp to record into file: /media/TV_1T_3T_6/ffmpegtest/mir.mp4

I want: rtmp://chanson.cdnvideo.ru/chanson-live/shansontv.sdp to record into file: /media/TV_1T_3T_6/ffmpegtest/shansontv.mp4

I want: rtmp://83.229.210.89:1935/TROTV/BTVtro0 to record into file: /media/TV_1T_3T_6/ffmpegtest/tro.mp4

我现在得到的日志是:
ffmpeg version 2.2.4 Copyright (c) 2000-2014 the FFmpeg developers
built on Jul 6 2014 21:42:17 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab --enable-libvpx --enable-libmp3lame
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.102 / 2. 5.102
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
[flv @ 0x24981c0] Stream discovered after head already parsed
Input #0, flv, from 'rtmp://83.229.210.89/RAZTV/BTVraztv1':
Metadata:
Server : NGINX RTMP (github.com/arut/nginx-rtmp-module)
displayWidth : 720
displayHeight : 576
fps : 25
profile :
level :
Duration: 00:00:00.00, start: 1826.816000, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 699 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
Stream #0:1: Audio: aac, 48000 Hz, stereo, fltp, 128 kb/s
Stream #0:2: Data: none
[flv @ 0x261c7e0] Stream discovered after head already parsed
[flv @ 0x261c7e0] negative cts, previous timestamps might be wrong
Last message repeated 8 times
Input #1, flv, from 'rtmp://mirtv.cdnvideo.ru/mirtv-live/mirtv600.sdp':
Metadata:
author :
copyright :
description :
keywords :
rating :
title :
presetname : Custom
creationdate : Fri Jul 11 03:34:37 2014
:
videodevice : AVerMedia Hybrid TV Video Capture
avclevel : 30
avcprofile : 66
videokeyframe_frequency: 5
audiodevice : ?8=. 2E>4 (#AB@>9AB2> A ?>445@6
audiochannels : 1
audioinputvolume: 100
Duration: N/A, start: 0.000000, bitrate: 1038 kb/s
Stream #1:0: Video: h264 (Baseline), yuv420p(tv), 720x576 [SAR 1:1 DAR 5:4], 972 kb/s, 25 fps, 25 tbr, 1k tbn, 50 tbc
Stream #1:1: Audio: mp3, 44100 Hz, mono, s16p, 65 kb/s
Stream #1:2: Data: none

最佳答案

WhooHooo,我明白了这个问题!所以这是修复。在我的情况下,FFMPEG 卡在有问题的流之一上,因此不会继续开始录制列表中的其余流。基本上使用 FFMPEG,您必须在单独的线程中为每个流执行命令。基本上在你的 jar 中设置 main 方法来启动单独的线程,然后分别开始为每个流录制。这样,如果 ffmpeg 无法连接到其中一个并挂起,它不会中断其余流的记录。

package igor.recorder.ffmpeg;

import java.io.IOException;
import java.io.InputStream;

public class RecordRazTV extends Thread {

String streamUrl="rtmp://83.229.210.89/RAZTV/BTVraztv1";
String recordingPath="/media/TV_580_3T_9/raztv";
String recordCommand = "";
String streamAliasFileName="";

public void run() {
System.out.println("Igors Log >> Inside the thread!");
streamAliasFileName = recordingPath.substring(recordingPath.lastIndexOf("/") + 1);
recordCommand = "ffmpeg -i " + streamUrl + " -b:v 900k -vcodec libx264 -acodec aac -b:a 256k -strict -2 -t 3600 /media/TV_1T_3T_6/ffmpegtest/raztv.mp4";
Process p;
try {
System.out.println("Igors Log >> Executing Runtime for FFMPEG: " + recordCommand);
p = Runtime.getRuntime().exec(recordCommand);
System.out.println("Igors Log >> Done executing Runtime for FFMPEG");
InputStream in = p.getErrorStream();
int c;
while ((c = in.read()) != -1)
{
System.out.print((char)c);
}
in.close();
interrupt();
} catch (IOException e) {
e.printStackTrace();
}

}

}

http://www.russiangoogletv.com

关于FFMPEG - 如何将多个 RTMP 流录制到多个文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24690806/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com