import subprocess
album_name = ['08']
chapter_name = ['MisterSkinnylegs', 'GrandpaPigBoat', 'Shopping', 'MyBirthdayParty', 'DaddyMovieCamera', 'SchoolPlay']
lang_name = ['en', 'cr']
for idx in range(len(chapter_name)):
p = subprocess.Popen(['HandBrakeCLI', '--input', '/dev/sr0', '--title', '1', '--chapters', f'{idx+1}', '--audio', '1', '--output', f'/home/ok97465/dvd_rip/{album_name[0]}_{idx+1}_{chapter_name[idx]}_{lang_name[0]}.mp4', '--encoder', 'x264',
'--quality', '10', '--rate', '29.97', '-B', '129', '-X', '720'])
(output, err) = p.communicate()
p_status = p.wait()
for idx in range(len(chapter_name)):
p = subprocess.Popen(['HandBrakeCLI', '--input', '/dev/sr0', '--title', '1', '--chapters', f'{idx+1}', '--audio', '2', '--output', f'/home/ok97465/dvd_rip/{album_name[0]}_{idx+1}_{chapter_name[idx]}_{lang_name[1]}.mp4', '--encoder', 'x264',
'--quality', '10', '--rate', '29.97', '-B', '129', '-X', '720'])
(output, err) = p.communicate()
p_status = p.wait()