FFMPEG - How to record multiple RTMP streams into multiple files
I tried the following, but it does not work.
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
Looks like it hangs on a second stream and no movement. S.O.S. Please help.
I have 4 stream URLs. I want them to be recording together at the same time.
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
The log that I get right now is:
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
ffmpeg streaming multiple-instances
add a comment |
I tried the following, but it does not work.
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
Looks like it hangs on a second stream and no movement. S.O.S. Please help.
I have 4 stream URLs. I want them to be recording together at the same time.
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
The log that I get right now is:
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
ffmpeg streaming multiple-instances
Have you tried just running ffmpeg 4 different times ?
– Lawrence
Jul 11 '14 at 6:17
I did, for some reason only 2 would start recording. But separately all stream are working and recording fine. But I am starting recordings from within Java using: p = Runtime.getRuntime().exec(recordCommand);
– user3146313
Jul 11 '14 at 15:50
add a comment |
I tried the following, but it does not work.
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
Looks like it hangs on a second stream and no movement. S.O.S. Please help.
I have 4 stream URLs. I want them to be recording together at the same time.
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
The log that I get right now is:
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
ffmpeg streaming multiple-instances
I tried the following, but it does not work.
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
Looks like it hangs on a second stream and no movement. S.O.S. Please help.
I have 4 stream URLs. I want them to be recording together at the same time.
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
The log that I get right now is:
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
ffmpeg streaming multiple-instances
ffmpeg streaming multiple-instances
edited Jul 11 '14 at 6:14
user3146313
asked Jul 11 '14 at 5:57
user3146313user3146313
10112
10112
Have you tried just running ffmpeg 4 different times ?
– Lawrence
Jul 11 '14 at 6:17
I did, for some reason only 2 would start recording. But separately all stream are working and recording fine. But I am starting recordings from within Java using: p = Runtime.getRuntime().exec(recordCommand);
– user3146313
Jul 11 '14 at 15:50
add a comment |
Have you tried just running ffmpeg 4 different times ?
– Lawrence
Jul 11 '14 at 6:17
I did, for some reason only 2 would start recording. But separately all stream are working and recording fine. But I am starting recordings from within Java using: p = Runtime.getRuntime().exec(recordCommand);
– user3146313
Jul 11 '14 at 15:50
Have you tried just running ffmpeg 4 different times ?
– Lawrence
Jul 11 '14 at 6:17
Have you tried just running ffmpeg 4 different times ?
– Lawrence
Jul 11 '14 at 6:17
I did, for some reason only 2 would start recording. But separately all stream are working and recording fine. But I am starting recordings from within Java using: p = Runtime.getRuntime().exec(recordCommand);
– user3146313
Jul 11 '14 at 15:50
I did, for some reason only 2 would start recording. But separately all stream are working and recording fine. But I am starting recordings from within Java using: p = Runtime.getRuntime().exec(recordCommand);
– user3146313
Jul 11 '14 at 15:50
add a comment |
1 Answer
1
active
oldest
votes
WhooHooo, I understood the problem! So this is the fix. In my case FFMPEG was hanging on one of the problematic streams and thus wasn’t going forward to start recordings of the rest of the streams in the list. Basically with FFMPEG you have to execute command for each stream in a separate thread. Basically setup main method in your jar to start separate threads that would then start recording for each stream separately. This way if ffmpeg can’t connect to one of them and hangs, it won’t interrupt the recording of the rest of the streams.
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
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f781686%2fffmpeg-how-to-record-multiple-rtmp-streams-into-multiple-files%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
WhooHooo, I understood the problem! So this is the fix. In my case FFMPEG was hanging on one of the problematic streams and thus wasn’t going forward to start recordings of the rest of the streams in the list. Basically with FFMPEG you have to execute command for each stream in a separate thread. Basically setup main method in your jar to start separate threads that would then start recording for each stream separately. This way if ffmpeg can’t connect to one of them and hangs, it won’t interrupt the recording of the rest of the streams.
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
add a comment |
WhooHooo, I understood the problem! So this is the fix. In my case FFMPEG was hanging on one of the problematic streams and thus wasn’t going forward to start recordings of the rest of the streams in the list. Basically with FFMPEG you have to execute command for each stream in a separate thread. Basically setup main method in your jar to start separate threads that would then start recording for each stream separately. This way if ffmpeg can’t connect to one of them and hangs, it won’t interrupt the recording of the rest of the streams.
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
add a comment |
WhooHooo, I understood the problem! So this is the fix. In my case FFMPEG was hanging on one of the problematic streams and thus wasn’t going forward to start recordings of the rest of the streams in the list. Basically with FFMPEG you have to execute command for each stream in a separate thread. Basically setup main method in your jar to start separate threads that would then start recording for each stream separately. This way if ffmpeg can’t connect to one of them and hangs, it won’t interrupt the recording of the rest of the streams.
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
WhooHooo, I understood the problem! So this is the fix. In my case FFMPEG was hanging on one of the problematic streams and thus wasn’t going forward to start recordings of the rest of the streams in the list. Basically with FFMPEG you have to execute command for each stream in a separate thread. Basically setup main method in your jar to start separate threads that would then start recording for each stream separately. This way if ffmpeg can’t connect to one of them and hangs, it won’t interrupt the recording of the rest of the streams.
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
answered Jul 11 '14 at 17:53
user3146313user3146313
10112
10112
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f781686%2fffmpeg-how-to-record-multiple-rtmp-streams-into-multiple-files%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you tried just running ffmpeg 4 different times ?
– Lawrence
Jul 11 '14 at 6:17
I did, for some reason only 2 would start recording. But separately all stream are working and recording fine. But I am starting recordings from within Java using: p = Runtime.getRuntime().exec(recordCommand);
– user3146313
Jul 11 '14 at 15:50