예제 #1
0
def fanout(c):
    command = fanout_utils.format_and_strip(
        c, """
ffmpeg -v warning -nostats -nostdin -y -analyzeduration 50000000
	-i {{ pull_url }}

	-c:a copy
	-c:v copy

	-map 0:v:0 -b:v:0 2800k
{% if 'SD' in video_tracks %}
	-map 0:v:1 -b:v:1 800k
{% endif %}
{% if 'Slides' in video_tracks %}
	-map 0:v:2 -b:v:2 100k
{% endif %}

	-map 0:a:0 -b:a:0 96k -metadata:s:a:0 language="Untranslated"
{% if 'Translated' in audio_tracks %}
	-map 0:a:1 -b:a:1 96k -metadata:s:a:1 language="Translated"
{% endif %}
{% if 'Translated-2' in audio_tracks %}
	-map 0:a:2 -b:a:2 96k -metadata:s:a:2 language="Translated-2"
{% endif %}

	-f dash
	-window_size 201 -extra_window_size 10
	-seg_duration 3
	-dash_segment_type webm
	-init_seg_name 'init_$RepresentationID$.webm'
	-media_seg_name 'segment_$RepresentationID$_$Number$.webm'
	-adaptation_sets '{{ adaptation_sets | join(" ") }}'
	{{ dash_write_path }}/{{ stream }}/manifest.mpd
""")
    fanout_utils.call(command)
예제 #2
0
def fanout_webm(context):
    command = fanout_utils.format_and_strip(
        context, """
ffmpeg -v warning -nostats -nostdin -y -analyzeduration 3000000
	-i {{ pull_url }}

	{% for audio_track in audio_tracks %}
		{% for codec in ['mp3', 'opus'] %}
			-c:v copy
			-c:a copy

			{% if audio_track == 'Native' %}
				-map 0:a:{{ 0 if codec == 'mp3' else 1 }}
			{% elif audio_track == 'Translated' %}
				-map 0:a:{{ 2 if codec == 'mp3' else 3 }}
			{% elif audio_track == 'Translated-2' %}
				-map 0:a:{{ 4 if codec == 'mp3' else 5 }}
			{% endif %}


			-f {{ codec }}
			-content_type {{ 'audio/mpeg' if codec == 'mp3' else 'audio/ogg' }}
			-password {{ icecast_password }}
			icecast://{{ push_endpoint }}/{{ stream }}_{{ audio_track | lower }}.{{ codec }}
		{% endfor %}
	{% endfor %}
""")
    fanout_utils.call(command)
예제 #3
0
파일: thumbnail.py 프로젝트: n0emis/cm
def fanout(context):
    command = fanout_utils.format_and_strip(
        context, """
ffmpeg -v warning -nostats -nostdin -y
	-i {{ pull_url }}

	-map 0:v:0
	-c:v copy -an
	-f image2 -update 1 {{ thumbnail_write_path }}/{{ stream }}/poster.jpeg

	-map 0:v:1
	-c:v copy -an
	-f image2 -update 1 {{ thumbnail_write_path }}/{{ stream }}/thumb.jpeg
""")
    fanout_utils.call(command)
예제 #4
0
파일: hls.py 프로젝트: fkusei/cm
def fanout(c):
	command = fanout_utils.format_and_strip(c, """
ffmpeg -v warning -nostats -nostdin -y -analyzeduration 3000000
	-i {{ pull_url }}
	-c:v copy
	-c:a copy

	{{ maps | join("\n\t") }}

	-hls_time 6
	-hls_list_size 200
	-hls_segment_filename "{{ hls_write_path }}/{{ stream }}/{{ starttime }}-%d_%v.ts"
	-hls_flags +delete_segments+omit_endlist+independent_segments
	-var_stream_map '{{ varmaps | join(" ") }}'
	"{{ hls_write_path }}/{{ stream }}/chunks_%v.m3u8"
""")
	fanout_utils.call(command)
예제 #5
0
def generate_master_playlists(c):
	for video_track, audio_track in itertools.product(c.video_tracks, c.audio_tracks):
		playlist_context = c + {
			"video_track": video_track,
			"audio_track": audio_track,
		}

		master_playlist = fanout_utils.format_and_strip(playlist_context, """
#EXTM3U
#EXT-X-VERSION:3

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Untranslated",DEFAULT={{ 'YES' if audio_track == 'Native' else 'NO' }}

{% if 'Translated' in audio_tracks %}
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Translation 1",DEFAULT={{ 'YES' if audio_track == 'Translated' else 'NO' }},URI="chunks_{{ first_audio_stream_index+0 }}.m3u8"
{% endif %}
{% if 'Translated-2' in audio_tracks %}
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="Translation 2",DEFAULT={{ 'YES' if audio_track == 'Translated-2' else 'NO' }},URI="chunks_{{ first_audio_stream_index+1 }}.m3u8"
{% endif %}

{% if video_track in ['HD'] %}
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=5000000,RESOLUTION=1920x1080,CODECS="avc1.4d0028,mp4a.40.2",AUDIO="audio"
chunks_0.m3u8
{% endif %}
{% if 'SD' in video_tracks and video_track in ['HD', 'SD'] %}
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=800000,RESOLUTION=1024x576,CODECS="avc1.4d0028,mp4a.40.2",AUDIO="audio"
chunks_1.m3u8
{% endif %}
{% if 'Slides' in video_tracks and video_track in ['HD', 'SD', 'Slides'] %}
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=100000,RESOLUTION=1024x576,CODECS="avc1.4d0028,mp4a.40.2",AUDIO="audio"
chunks_2.m3u8
{% endif %}
""")

		master_playlist_file = os.path.join(
			c.hls_write_path,
			c.stream,
			"%s_%s.m3u8" % (audio_track.lower(), video_track.lower())
		)

		print("Writing Master Playlist-File %s" % master_playlist_file)
		with open(master_playlist_file, "w") as f:
			f.write(master_playlist)
예제 #6
0
파일: webm.py 프로젝트: voc/cm
def fanout_webm(context):
	command = fanout_utils.format_and_strip(context, """
ffmpeg -v warning -nostats -nostdin -y -analyzeduration 3000000
	-i {{ pull_url }}

	{% for audio_track in audio_tracks %}
		{% for video_track in video_tracks %}
			-c:v copy
			-c:a copy

			{% if video_track == 'HD' %}
				-map 0:v:0
			{% elif video_track == 'SD' %}
				-map 0:v:1
			{% elif video_track == 'Slides' %}
				-map 0:v:2
			{% endif %}

			{% if audio_track == 'Native' %}
				-map 0:a:0
			{% elif audio_track == 'Translated' %}
				-map 0:a:1
			{% elif audio_track == 'Translated-2' %}
				-map 0:a:2
			{% endif %}

			-f webm
			-cluster_size_limit 3M
			-cluster_time_limit 3500
			-content_type video/webm
			-password {{ icecast_password }}
			icecast://{{ push_endpoint }}/{{ stream }}_{{ audio_track | lower }}_{{ video_track | lower }}.webm
		{% endfor %}
	{% endfor %}
""")
	fanout_utils.call(command)