0
def startRecording(channel, start, length, episode, show):
        tunerInstance = tuneChannel(channel)
        sched_cmd = ['at', '-t', start]
        command = 'ffmpeg -i /dev/ceton/ctn91xx_mpeg0_%s -c copy -t %s /mnt/primary-backup-drive/Backup/Recordings/%s-%s-%s.mp4' % (tunerInstance, length, show, episode, channel)
        p = Popen(sched_cmd, stdin=PIPE)
        p.communicate(command)

I am getting the following error with this function:

  File "./cetonTune.py", line 70, in startRecording
    p.communicate(command)
  File "/usr/lib/python3.8/subprocess.py", line 1013, in communicate
    self._stdin_write(input)
  File "/usr/lib/python3.8/subprocess.py", line 962, in _stdin_write
    self.stdin.write(input)
TypeError: a bytes-like object is required, not 'str'

Any help would be greatly appreciated!

  • Does this answer your question? https://stackoverflow.com/a/13332300/1032785 – jordanm Aug 26 '22 at 21:45
  • Use the `encoding` argument to specify encoding, so it's not a byte stream. – Barmar Aug 26 '22 at 21:53
  • Uploaded the full code to github: https://github.com/spaceWrench380/infinitvPythonRecorder/blob/main/cetonTune.py – Richie Carnes Aug 26 '22 at 22:05
  • I added the encoding to the command variable and it has resolved the issue! Thank you so much for the suggestion and help! `command = 'ffmpeg -i /dev/ceton/ctn91xx_mpeg0_%s -c copy -t %s /mnt/primary-backup-drive/Backup/Recordings/%s-%s-%s.mp4' % (tunerInstance, length, show, episode, channel) command_b = bytes(command,'utf-8') p = subprocess.Popen(sched_cmd, stdin=subprocess.PIPE) p.communicate(command_b)` – Richie Carnes Aug 27 '22 at 04:02

1 Answers1

0

@Barmar Thank you for the suggestion, this has resolved the issue as noted below:

 command = 'ffmpeg -i /dev/ceton/ctn91xx_mpeg0_%s -c copy -t %s /mnt/primary-backup-drive/Backup/Recordings/%s-%s-%s.mp4' % (tunerInstance, length, show, episode, channel)
    command_b = bytes(command,'utf-8')
    p = subprocess.Popen(sched_cmd, stdin=subprocess.PIPE)
    p.communicate(command_b)