Ejemplo n.º 1
0
def fix_fourcc():
	"""
	%prog <source_file>

	Re-encode the video, but change the ffourcc to XVID
	"""
	parser = argparse.ArgumentParser(usage=trim(fix_fourcc.__doc__))
	parser.add_argument('source')
	options, args = parser.parse_args()

	re_encode(args.source, get_video_copy_options(), get_audio_copy_options())
Ejemplo n.º 2
0
def transcode():
	"""
	%prog <source_file>

	Transcode a video by copying the video, but encoding the audio
	into mp3 format.
	"""
	parser = argparse.ArgumentParser(usage=trim(fix_fourcc.__doc__))
	parser.add_argument('source')
	args = parser.parse_args()

	re_encode(args.source, get_video_copy_options(), get_mp3_options())
Ejemplo n.º 3
0
def handle_command_line():
	"""
	Query the NTP server for the current time.
	"""
	parser = argparse.ArgumentParser(usage=trim(handle_command_line.__doc__))
	parser.add_argument(
		'-6', '--ipv6', help="Force IPv6", action="store_true", default=False)
	parser.add_argument('server', help="IP Address of server to query")
	jaraco.logging.add_arguments(parser)
	args = parser.parse_args()
	jaraco.logging.setup(args)
	logging.root.handlers[0].setFormatter(logging.Formatter("%(message)s"))
	val = query(args.server, args.ipv6)
	dt = datetime.datetime.fromtimestamp(val)  # noqa
	log.info(lf('\tTime={dt}'))
Ejemplo n.º 4
0
def rip_subtitles():
	"""
	%prog <dvd_source>
	"""
	logging.basicConfig(level=logging.INFO)

	parser = argparse.ArgumentParser(usage=trim(encode_dvd.__doc__))
	#parser.add_argument('-t', '--titles', 'enter the title or titles to process (i.e. 1 or 1,5 or 1-5)' default='')
	parser.add_argument('-t', '--title', help='enter the dvd title number to process', default='')
	parser.add_argument('-s', '--subtitle', help='enter the subtitle ID')
	parser.add_argument('device', nargs='?')
	args = parser.parse_args()

	command = MEncoderCommand()

	device = args.device or raw_input('enter device> ')

	print('device is', device)
	command.set_device(device)

	videos_path = join(os.environ['PUBLIC'], 'Videos', 'Movies')

	default_title = infer_name(device)
	title_prompt = 'Enter output filename [%s]> ' % default_title
	user_title = raw_input(title_prompt) or default_title
	target = os.path.join(videos_path, user_title)

	command.source = ['dvd://%(title)s' % vars(options)]

	command['o'] = os.devnull

	command.audio_options = HyphenArgs(nosound=None)
	command.video_options = HyphenArgs(ovc='frameno')

	command['sid'] = args.subtitle or '0'

	command['vobsubout'] = target
	command['vobsuboutindex'] = command['sid']
	#command['vobsuboutid'] = 'en'

	command = tuple(command.get_args())
	errors = open(os.devnull, 'w')
	proc = subprocess.Popen(command, stderr=errors)
	proc.wait()
Ejemplo n.º 5
0
    # Make a 304 request on the same connection.
    status_line, actual_headers, actual_resp_body = test_client.get(
        '/custom/304', http_conn=http_connection,
    )
    actual_status = int(status_line[:3])
    assert actual_status == 304
    assert not header_exists('Content-Length', actual_headers)
    assert actual_resp_body == b''
    assert not header_exists('Connection', actual_headers)


@pytest.mark.xfail(
    reason=unwrap(
        trim("""
        Headers from earlier request leak into the request
        line for a subsequent request, resulting in 400
        instead of 413. See cherrypy/cheroot#69 for details.
        """),
    ),
)
def test_Chunked_Encoding(test_client):
    """Test HTTP uploads with chunked transfer-encoding."""
    # Initialize a persistent HTTP connection
    conn = test_client.get_connection()

    # Try a normal chunked request (with extensions)
    body = (
        b'8;key=value\r\nxx\r\nxxxx\r\n5\r\nyyyyy\r\n0\r\n'
        b'Content-Type: application/json\r\n'
        b'\r\n'
    )
Ejemplo n.º 6
0
def encode_dvd():
	"""
	%prog <dvd_source>

	Encode a DVD where the source is a DVD drive or RIP directory of a DVD.
	"""
	parser = argparse.ArgumentParser(usage=trim(encode_dvd.__doc__))
	#parser.add_argument('-t', '--titles', 'enter the title or titles to process (i.e. 1 or 1,5 or 1-5)' default='')
	parser.add_argument('-t', '--title', help='enter the dvd title number to process', default='')
	parser.add_argument('-s', '--subtitle', help='enter the subtitle ID')
	parser.add_argument('--test', help='just encode one chapter', default=False, action='store_true')
	parser.add_argument('-l', '--log-level', help='log level (debug, info, warning, error)',
		default='info')
	parser.add_argument('device', nargs='?')
	args = parser.parse_args()

	logging.basicConfig(level=getattr(logging, args.log_level.upper()))

	command = MEncoderCommand()

	device = args.device or raw_input('enter device> ')

	print('device is', device)
	command.set_device(device)

	videos_path = join(os.environ['PUBLIC'], 'Videos', 'Movies')

	default_title = infer_name(device)
	title_prompt = 'Enter output filename [%s]> ' % default_title
	user_title = raw_input(title_prompt) or default_title

	filename = '%(user_title)s.avi' % vars()
	target = os.path.join(videos_path, user_title)
	output_filename = os.path.join(videos_path, filename)

	command['o'] = output_filename

	dvd_title = args.title
	command.source = ['dvd://%(dvd_title)s' % vars()]
	if args.test:
		command['chapter'] = '2-2'

	command.audio_options = get_audio_copy_options()
	command.audio_args.update(aid='128')

	crop = cropdetect.get_crop(device, dvd_title)
	log.info('crop is %s', crop)
	command.video_filter = HyphenArgs(
		sws='2',
		vf=ColonDelimitedArgs(crop=crop),
		)

	command.video_options = get_mpeg4_options()

	if args.subtitle:
		command['sid'] = args.subtitle
		command['vobsubout'] = target
		command['vobsuboutindex'] = '0'

	assert not os.path.exists(command.other_options['o']), (
		'Output file %s already exists' % command.other_options['o']
	)

	errors = open(os.devnull, 'w')
	two_pass_handler = MultiPassHandler(command)
	for _pass in (two_pass_handler):
		_pass_args = tuple(_pass.get_args())
		log.debug('executing with %s', _pass_args)
		proc = subprocess.Popen(_pass_args, stderr=errors)
		proc.wait()