Преглед изворни кода

force exiting after duration of video is over

David пре 10 година
родитељ
комит
76c65900c3
1 измењених фајлова са 9 додато и 3 уклоњено
  1. 9 3
      server/play-video.sh

+ 9 - 3
server/play-video.sh

@@ -77,13 +77,19 @@ VIDEOFORMAT=$VIDEOBGRA', width='$feed_width', height='$feed_height
 
 rm -f $feed_control_pipe
 
+str_duration=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$source");
+str_duration=${str_duration/.*};
+duration=$((str_duration+3)) #Just in case, add 3 secs after truncating
+echo "Duration of $source is $duration"
+
+
 if [ X$feed_rate != X -a X$feed_channels != X ] ; then
 	  (
-		echo 'audio feed ctr isaudio '$audio_feed_id
-		$gstlaunch -e $SRC ! \
+		echo "audio feed ctr isaudio $audio_feed_id"
+		timeout $duration $gstlaunch $SRC ! \
 		videorate ! $SCALE ! $VIDEOFORMAT ! $SHMSINK1 decoder. \
 		! queue ! audioconvert ! audioresample ! $AUDIOFORMAT ! fdsink fd=3 sync=true 3>&1 1>&2
-	  ) | nc $SNOWMIX_IP $SNOWMIX_PORT
+	  ) |  nc -q 1 $SNOWMIX_IP $SNOWMIX_PORT
 else
 	$gstlaunch -e -q $SRC ! \
 	  $SCALE		! \