Python: Close Files If You’re Going To Open Them
I've been trying to archive some videos off Youtube lately, using yt-dlp. It's an amazing tool, but my target files have been episodes in parts. Usually four parts and Plex really hates jogging through... so what to do? Combine the files together with ffmpeg. The code was meant to be pretty simple (and 98% of it was written by ChatGPT... whoops)...
def concat_episodes(episode_name, concat_files): plfile = "file_list.txt" f = open(plfile, "w", encoding="utf-8") for filename in concat_files: f.write("file '" + filename + "'\r\n") concat_command = f"ffmpeg -stats -safe 0 -f concat -i {plfile} -c copy '{episode_name}'" print(concat_command) subprocess.run(concat_command, shell=True)
But no amount of wrangling would get ffmpeg to work. The concat filter kept throwing: Invalid data found when processing input. No amount of "-safe 0", relative paths or absolute paths worked! No permissions... no cwds or shell arguments. If I let the python script drop to the shell, then the same line pasted (since I printed it out) worked perfectly fine! What the?
OH RIGHT. I missed the memo that I should be closing a file so that it lands on disk... prior to trying to open it in another process!:
def concat_episodes(episode_name, concat_files): plfile = "file_list.txt" f = open(plfile, "w", encoding="utf-8") for filename in concat_files: f.write("file '" + filename + "'\r\n") f.close() concat_command = f"ffmpeg -stats -safe 0 -f concat -i {plfile} -c copy '{episode_name}'" print(concat_command) subprocess.run(concat_command, shell=True)
The file was still open and not flushed to disk... so ffmpeg would always open an empty file! This has been a public service announcement.
Random HDMI Capture Cards
I can't believe I'm calling these cards retro, but they are! They're all early 00s and the drivers are only for Windows XP and Vista? How random... I had no idea there were cheap PCI-E HDMI Capture cards back then. I would not have had any reason for them back then, and hardly do today, but I'd picked them up in a Hard Off somewhere across Japan for 1$ each and thought I should finally test them out.
DRECAP DC-HC1
First up is a DRECAP DC-HC1. It's tiny and came with a low-profile case bracket. I unscrewed the bracket and loosely placed it in my machine, making sure to NOT move the HDMI cable once connected.
Whilst looking for drivers... actually, prior to that, whilst trying to ID the card (there are no valid serial numbers or other identifying marks), I found other cards that also seemed to be identical. I then stumbled across this blog post which indicated that the base card was a Timeleak HD72A and that the drivers could be found here.
With the correct drivers installed, everything worked nicely!
KEIAN DM626 H3
The second card was identified via Yodobashi Camera product listing! How cool. Out of stock! Knowing the product name, I then went googling for drivers. It turns out the original site is long gone and, since their support page had ugly javascript, webarchive can't help to find drivers.
I stumbled across this blog post with great info on installation. It turns out you can use the Monster X3A drivers here for this card. The X3A only has one port, so it seems we'll only use the closest port to the motherboard? ... it actually turned out that any port on the card worked! Unfortunately, sound didn't.
Mucking around with Composite Signals
As that I couldn't get audio from the second card, I went with using the bracket of it on the first card! I wasn't ready to have a loose card hanging around inside my PC's case.
The HDMI port, by total fluke, lined up 98% and cables were securely connected. From there, I purchased this little beast for AU12$ on eBay...
And you know what? It works nicely! Here's a Sega Master System II hooked up. I've got a switch to toggle the PAL/NTSC pin, so when you see (and hear) it switch from PAL 60 to PAL you'll know why!
Nice... No more mucking around with other TVs... I can now use this to continue the long chain of Atari and Sega mods/repairs.
Christmas ’94, Tandy-Style!
This turned up on eBay and I couldn't resist! Recently I'd found stamp books and Australia Philotelic Assoc orders forms, amongst Lego Catalogue order forms (unfulfilled, I must admit!), but nothing from Tandy. I saw this for sale and new it needed to be preserved!
SALE ENDS CHRISTMAS EVE, 1994.