Skip to content

Instantly share code, notes, and snippets.

@vladkorotnev
Last active November 24, 2022 08:24
Show Gist options
  • Save vladkorotnev/a5aad734e29fc5a2ad128cc0724dda52 to your computer and use it in GitHub Desktop.
Save vladkorotnev/a5aad734e29fc5a2ad128cc0724dda52 to your computer and use it in GitHub Desktop.
D-VHS bitstream dump memo

Glitch setup

  1. Power on DIGA
  2. Plug in and power on TV Tuner, set DIGA to TS mode 2 input
  3. Power on DVHS and plug into TV Tuner
  4. Select iLink Dubbing from the menu and wait for error to appear. Clear the error and wait until TV picture appears again
  5. Go to DIGA TS mode settings
  6. Play tape, set TS mode to 1, exit fast and smash record
  7. If you're lucky it ignores the DRM flag and recording
  8. If you're even luckier timecode breaks and tape swaps don't stop the recording
  9. If you're the luckiest you can stop recording and start it again without running into any problems during the session

PC Transfer

  1. Insert BD-RE disc
  2. Select all on DIGA but below disc capacity
  3. Burn all the things!
  4. Place disc into PC
  5. MakeMKV -> File -> Backup into a folder on HDD, check DECRYPT
  6. for i in [backup]/STREAM/*.m2ts; do; ./fixm2ts.sh $i $(basename $i .m2ts); done

Clipping

Use LUA script for MPV, and set keep-open=yes in mpv.conf

-- Copyright (C) 2017 ParadoxSpiral
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Parabot. If not, see <http://www.gnu.org/licenses/>.
-- Encode a clip of the current file
local mp = require 'mp'
local options = require 'mp.options'
require 'os'
function basename(str)
local name = string.gsub(str, "(.*[/\\])(.*)", "%2")
return name
end
-- Options
local o = {
-- Key bindings
key_set_start_frame = "c",
key_set_stop_frame = "C",
key_start_encode = "ctrl+C",
-- Audio settings
audio_codec = "copy",
audio_bitrate = "192k",
-- Video settings
video_codec = "copy",
video_crf = "24",
video_pixel_format = "yuv420p10",
video_width = "", -- source width if not specified
video_height= "", -- source height if not specified
video_upscale = false, -- upscale if video res is lower than desired res
-- Misc settings
encoding_preset = "medium", -- empty for no preset
output_directory = "H:\\Media\\Video\\DVHS Ads",
clear_start_stop_on_encode = true,
block_exit = false, -- stop mpv from quitting before the encode finished, if false…
-- …mpv will quit but ffmpeg will be kept alive
}
options.read_options(o)
-- Global mutable variables
local start_frame = nil
local stop_frame = nil
function encode()
if not start_frame then
mp.osd_message("No start frame set!")
return
end
if not stop_frame then
mp.osd_message("No stop frame set!")
return
end
if start_frame == stop_frame then
mp.osd_message("Cannot create zero length clip!", 1.5)
end
local path = mp.get_property("path")
local out = o.output_directory.."/"..basename(path).."-clip-"..start_frame..
"-"..stop_frame..".mkv"
local width = mp.get_property("width")
local height = mp.get_property("height")
if o.video_width ~= "" and (o.video_width < width or o.video_upscale) then
width = o.video_width
end
if o.video_height ~= "" and (o.video_height < height or o.video_upscale) then
height = o.video_height
end
local saf = start_frame
local sof = stop_frame
if o.clear_start_stop_on_encode then
start_frame = nil
stop_fram = nil
end
local preset = ""
if o.encoding_preset ~= "" then
preset = "-preset "..o.encoding_preset
end
-- Check if ytdl is needed
local input
if not os.execute('ffprobe "'..path..'"') then
input = 'youtube-dl "'..path..'" -o - | ffmpeg -i -'
else
input = 'ffmpeg -i "'..path..'"'
end
-- FIXME: Map metadata properly, like chapters or embedded fonts
local command = input.." -ss "..saf.." -t "..sof-saf..
" -c:a "..o.audio_codec.." -c:v "..o.video_codec..
' "'..out..'"'
local time = os.time()
mp.osd_message("Starting encode from "..saf.." to "..sof.." into "..out, 3.5)
if o.block_exit then
os.execute(command)
mp.osd_message("Finished encode of "..out.." in "..os.time()-time.." seconds", 3.5)
else
-- FIXME: Won't work on Windows, because of special snowflake pipe naming
local ipc = mp.get_property("input-ipc-server")
local del_tmp = ""
if ipc == "" then
ipc = os.tmpname()
mp.set_property("input-ipc-server", ipc)
del_tmp = " && lua -e 'os.remove(\""..ipc.."\")'"
end
os.execute(command..' && echo "{ \\"command\\": [\\"show-text\\", \\"Finished encode of \''
..out..'\' in $(lua -e "print(os.time()-'..time..')") seconds\\", 3500] }" | socat - '
..ipc..del_tmp.." &")
end
end
-- Start frame key binding
mp.add_key_binding(o.key_set_start_frame, "clip-start",
function()
start_frame = mp.get_property("playback-time")
if not start_frame then
start_frame = 0
end
if tonumber(start_frame) < 1 then
start_frame = 0
end
mp.osd_message("Clip start at "..start_frame.."s")
end)
-- Stop frame key binding
mp.add_key_binding(o.key_set_stop_frame, "clip-end",
function()
stop_frame = mp.get_property("playback-time")
if not stop_frame then
mp.osd_message("playback-time is nil! (file not yet loaded?)")
else
mp.osd_message("Clip end at "..stop_frame.."s")
end
end)
-- Start encode key binding
mp.add_key_binding(o.key_start_encode, "clip-encode",
function()
encode()
end)
-- Reset start/stop frame when a new file is loaded
mp.register_event("start-file",
function()
start_frame = nil
stop_frame = nil
end)
# Correct dumps produced by DIGA to be cuttable with ffmpeg if there were resolution changes during recording
# Usage: fixm2ts.sh path/to/decrypted/m2tsfile.m2ts path/to/output/prefix (will output to "prefix-fix[stream#].m2ts")
while read line
do
ffmpeg -analyzeduration 4000M -probesize 4000M -fflags +genpts -r 29.97 -err_detect ignore_err -i $1 -map 0:$line -map 0:$(($line + 1)) -c:a copy -c:v copy $2-fix$line.m2ts
done <<< $(ffprobe -analyzeduration 4000M -probesize 4000M -v error -select_streams v -show_entries stream=index,codec_type -of compact=nokey=1 $1 | grep ^stream | sort | uniq | cut -d'|' -f2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment