Permalink
Browse files

Added logs and new options in Streaming and Recording.

Changes introduced in the isabel_ffmpeg processes used for streaming and recording:
    o Added -xerror option, so when an error happens, they will be relaunched.
    o A log file is created in .isabel/logs/session.
  • Loading branch information...
1 parent ca3e9a6 commit 216dfb92b3022742fc0d4bd9a7f2865efbdb66bc @sanpago sanpago committed Jan 13, 2012
Showing with 36 additions and 16 deletions.
  1. +23 −8 components/MCU/kal/ffmpeg/ffmpeg.itcl
  2. +9 −4 components/MCU/kal/ffmpeg/streaming.itcl
  3. +4 −4 components/MCU/kal/mcu.itcl
@@ -42,7 +42,7 @@ class FFMpegStreamingMgrC {
# Methods to start and stop the isabel_ffmpeg application.
# $url - streaming
# $recfile - recording
- public method StartFFMpeg {url recfile frate _halfsize}
+ public method StartFFMpeg {url recfile frate _halfsize {logfile ""}}
public method StopFFMpeg {}
# Callback to execute when ffmpeg dies.
@@ -61,6 +61,9 @@ class FFMpegStreamingMgrC {
# Recording filename
private variable recording_filename
+ # Log filename
+ private variable log_filename
+
# Framerate
private variable framerate
@@ -96,7 +99,7 @@ body FFMpegStreamingMgrC::destructor {} {
#------------------------------------------------------------
-body FFMpegStreamingMgrC::StartFFMpeg {url recfile frate _halfsize} {
+body FFMpegStreamingMgrC::StartFFMpeg {url recfile frate _halfsize {logfile ""}} {
global env
if {$ffmpegExtObj != ""} {
@@ -107,12 +110,17 @@ body FFMpegStreamingMgrC::StartFFMpeg {url recfile frate _halfsize} {
set recording_filename $recfile
set framerate $frate
set halfSize $_halfsize
+ set log_filename $logfile
WriteTraceMsg "Streaming: Starting isabel_fmpeg application."
WriteTraceMsg "Streaming to URL = $targetURL"
WriteTraceMsg "Recording to file = $recording_filename"
WriteTraceMsg "Options: Framerate = $framerate fps / Grab Half Size = $halfSize"
+ if {$log_filename != ""} {
+ WriteTraceMsg "Log to file = $log_filename"
+ }
+
if {$targetURL == ""} {
if {$recording_filename == ""} {
#=== NOTHING TO DO
@@ -187,7 +195,11 @@ body FFMpegStreamingMgrC::RestartFFMpeg {} {
set _output_opts_f_str "-f mpegts $_output_opts"
set _output_opts_f_rec "-f avi $_output_opts"
- set _verbose_opt "-v 0"
+ if {$log_filename != ""} {
+ set _verbose_opt "-v 1"
+ } else {
+ set _verbose_opt "-v 0"
+ }
if {$targetURL == ""} {
if {$recording_filename == ""} {
@@ -197,20 +209,23 @@ body FFMpegStreamingMgrC::RestartFFMpeg {} {
} else {
#=== RECORDING
- set _cmd "$_FFMPEG_PATH $_verbose_opt $_input_opts_video $_input_opts_audio $_input_opts_map_sync $_output_opts_f_str pipe:1 | \
- $_FFMPEG_PATH $_verbose_opt -f mpegts -i pipe:0 -acodec copy -vcodec copy -f avi -y $env(HOME)/$recording_filename"
+ set _cmd "$_FFMPEG_PATH $_verbose_opt -xerror $_input_opts_video $_input_opts_audio $_input_opts_map_sync $_output_opts_f_str pipe:1 | \
+ $_FFMPEG_PATH $_verbose_opt -xerror -f mpegts -i pipe:0 -acodec copy -vcodec copy -f avi -y $env(HOME)/$recording_filename \
+ 2> $env(ISABEL_SESSION_LOGS_DIR)/$log_filename"
}
} else {
if {$recording_filename == ""} {
#=== STREAMING
- set _cmd "$_FFMPEG_PATH $_verbose_opt $_input_opts_video $_input_opts_audio $_input_opts_map_sync $_output_opts_f_str $targetURL"
+ set _cmd "$_FFMPEG_PATH $_verbose_opt -xerror $_input_opts_video $_input_opts_audio $_input_opts_map_sync $_output_opts_f_str $targetURL \
+ 2> $env(ISABEL_SESSION_LOGS_DIR)/$log_filename"
} else {
#=== STREAMING AND RECORDING
- set _cmd "$_FFMPEG_PATH $_verbose_opt $_input_opts_video $_input_opts_audio $_input_opts_map_sync $_output_opts_f_str pipe:1 | \
- $_FFMPEG_PATH $_verbose_opt -f mpegts -i pipe:0 -acodec copy -vcodec copy -f mpegts $targetURL -acodec copy -vcodec copy -f avi -y $env(HOME)/$recording_filename"
+ set _cmd "$_FFMPEG_PATH $_verbose_opt -xerror $_input_opts_video $_input_opts_audio $_input_opts_map_sync $_output_opts_f_str pipe:1 | \
+ $_FFMPEG_PATH $_verbose_opt -xerror -f mpegts -i pipe:0 -acodec copy -vcodec copy -f mpegts $targetURL -acodec copy -vcodec copy -f avi -y $env(HOME)/$recording_filename \
+ 2> $env(ISABEL_SESSION_LOGS_DIR)/$log_filename"
}
}
@@ -336,6 +336,12 @@ body StreamingManagerC::AutoStart {} {
body StreamingManagerC::Start {} {
global env
+ #----- Common
+
+ set _date [clock format [clock seconds] -format "%Y-%m-%d-%H-%M-%S"]
+
+ set _log_filename isabel_ffmpeg_streaming_recording_$_date.log
+
#----- Streaming
set _stw [$wroot.stream childsite]
@@ -366,7 +372,6 @@ body StreamingManagerC::Start {} {
Save dorecord $doRecord
if {$doRecord == "1"} {
- set _date [clock format [clock seconds] -format "%Y-%m-%d-%H-%M-%S"]
set record_filename isabel_session_$_date.avi
UpdateRecSize
} else {
@@ -387,13 +392,13 @@ body StreamingManagerC::Start {} {
if {$doStream == "1"} {
if {$doRecord == "1"} {
- component Cmd StartStreamingAndRecording $target_url $record_filename $_frate $halfSize
+ component Cmd StartStreamingAndRecording $target_url $record_filename $_frate $halfSize $_log_filename
} else {
- component Cmd StartStreamingAndRecording $target_url "" $_frate $halfSize
+ component Cmd StartStreamingAndRecording $target_url "" $_frate $halfSize $_log_filename
}
} else {
if {$doRecord == "1"} {
- component Cmd StartStreamingAndRecording "" $record_filename $_frate $halfSize
+ component Cmd StartStreamingAndRecording "" $record_filename $_frate $halfSize $_log_filename
}
}
@@ -76,7 +76,7 @@ class MCUComponentC {
# Streaming & Recording
#------------------
- public method StartStreamingAndRecording {url recfile frate halfsize}
+ public method StartStreamingAndRecording {url recfile frate halfsize {logfile ""}}
public method StopStreaming {}
private method ConfigureStreamingMCU {}
@@ -296,7 +296,7 @@ body MCUComponentC::ConfigureLseMCU {} {
#---------------------------------------------------------
-body MCUComponentC::StartStreamingAndRecording {url recfile frate halfsize} {
+body MCUComponentC::StartStreamingAndRecording {url recfile frate halfsize {logfile ""}} {
if {$mcudtobj == ""} return
if {$ffmpegobj == ""} return
@@ -311,11 +311,11 @@ body MCUComponentC::StartStreamingAndRecording {url recfile frate halfsize} {
if {$streamingState != "stopped"} return
- WriteTraceMsg "Streaming: Sending the session audio to the isabel_fmpeg application."
+ WriteTraceMsg "Streaming: Sending the session audio to the isabel_ffmpeg application."
ConfigureStreamingMCU
- $ffmpegobj StartFFMpeg $url $recfile $frate $halfsize
+ $ffmpegobj StartFFMpeg $url $recfile $frate $halfsize $logfile
}

0 comments on commit 216dfb9

Please sign in to comment.