How To Get Samsung Led Tv Pvr Recording As Mkv

Challenge

You have recording(s) made with your Samsung LED TV on a harddisk and you want to keep them as Matroska (mkv) files.

Prerequisites

  • Linux (I use ubuntu so you might have to do some substitutions)
  • git (apt-get install git)
  • (lots of) space

Solution

We need to do:

  • Mount the Samsung LED TV formatted disk
  • Decrypt the needed file(s)
  • Convert the needed file(s)

Mount disk

The Samsung LED TV formatted disks are formatted as a XFS filesystem and you have to be able to mount it.
It can be done on a Mac (search for fuse-xfs) and on Linux. I will explain the Linux version as I have not yet found
a decryption tool for the mac.

  • Put your USB harddisk with Samsung TV recordings in your linux machine
  • First you have to find which disk you have inserted. Use sudo fdisk -l and find the disk you have inserted. The output should look something like below and you should be able to recognize your disk.
1
2
3
4
5
6
7
8
9
10
11
$ sudo fdisk -l
Disk /dev/sde: 750.2 GB, 750156120064 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465148672 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3b7236e9
Device Boot Start End Blocks Id System
/dev/sde1 * 64 1465144064 732572000+ 7 HPFS/NTFS/exFAT
  • Use the disk found (in the example /dev/sde1)
  • Mount the XFS formatted disk
1
2
sudo mkdir /media/xfs
sudo mount -t xfs /dev/sde1 /media/xfs
  • See what’s there. You should see something like this..
1
2
3
4
5
6
7
$ ls /media/xfs
CONTENTS PVRDBVersion.mgr database
$ ls /media/xfs/CONTENTS/
.PVRPfmChkLog 20140131221505.mdb 20140202143211.enc FavoriteInfo.dev
20140131221505.ckf 20140131221505.mta 20140202143211.inf NewBoard4Rpsp.inf
20140131221505.enc 20140131221505.srf 20140202143211.mdb
20140131221505.inf 20140202143211.ckf 20140202143211.srf

The structure of the Samsung LED TV formatted disk is always like above.
The Items in the CONTENTS folder are probably different :-)

The *.srf files are the actual media files. These srf files are encrypted though.

Samsung is trying to make it difficult for us, but we are smarter!

Decrypt srf files

  • Enter drmdecrypt. I actually use my own fork because I changed a few bytes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#Get the git repository with the sources
git clone https://github.com/IvoNet/drmdecrypt.git
cd drmdecrypt
# Compile the code
gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -c aes.c -o aes.o
# Note Ignore warnings...!
gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -c DRMDecrypt.c -o DRMDecrypt.o
gcc -o drmdecrypt aes.o DRMDecrypt.o
#copy the created drmdecrypt file to your user/bin folder
cp drmdecrypt ~/bin
#try it out
drmdecrypt
===============================================================================
Samsung LED TV PVR Recording Decrypt (x64)
===============================================================================
Specify .srf file as 1st argument. The mdb file must also be present in the
current working directory
===============================================================================

So now you have the means to decrypt the .srf files to .ts files!

Convert ts to mkv

  • Get HandBrakeCLI
1
2
3
sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo aptitude update
sudo apt-get install handbrake-cli

So now you have the means to convert movies!

  • I use the following command to convert movies. You must of course search for your own best settings.
1
2
HandBrakeCLI -e x264 -q 20.0 -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,auto -R Auto,Auto -D 0.0,0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback
ffac3 -f mp4 -Y 1920 -X 1080 -4 --decomb --loose-anamorphic --modulus 2 -m --x264-preset ultrafast --h264-profile high --h264-level 4.1 --start-at duration:0 -i "20140131221505.ts" -o "output.mkv"

Done!

Automate

The first time you should do all of the above because you must install stuff but when done you don’t want to type a lot
so I would say… automate it :-)

  • You might want to create the following script in your bin folder. I called it samsungtv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
die () {
echo "$@"
exit 1
}
check1=`which drmdecrypt`
if [ "$check1" = "" ]
then
die "drmdecrypt is missing: https://github.com/IvoNet/drmdecrypt and follow instructions"
fi
check2=`which HandBrakeCLI`
if [ "$check2" = "" ]
then
die "HandBrakeCLI is missing: http://handbrake.fr/downloads2.php"
fi
check3="$1"
if [ "$check3" = "" ]
then
die "syntaxis: $0 [filename without extension] [time to start in seconds]"
fi
startat="$2"
if [ "$startat" = "" ]
then
startat=0
fi
drmdecrypt "$1.srf"
HandBrakeCLI -e x264 -q 20.0 -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,auto -R Auto,Auto -D 0.0,0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 -Y 1920 -X 1080 -4 --decomb --loose-anamorphic --modulus 2 -m --x264-preset ultrafast --h264-profile high --h264-level 4.1 --start-at duration:$startat -i "$1.ts" -o "$1.mkv"
  • Make it executable chmod 755 samsungtv
  • Now you can convert files by just mounting the disk, go into the CONTENT folder and use a command like: samsungtv 20140131221505
  • It will take care of the decryption and conversion in 1 go.

Discussion

June 10, 2014 - Thanks to Nick

You may also want to mention that on at least some Samsung TVs if not all recent
ones ? ie the one that I own Model UEF5064000AK, the TV will quite happily record
to a ext4 filesystem and not require the disk to be reformatted in XFS as would
be the case if the filesystem was FAT32 or NTFS.

December 25, 2014 - after a couple of mails

It seems that the drmdecrypt does not work for all models or for newer model of Samsung.
Please do not mail me with questions of how to fix them. Mails of that nature won’t be answered anymore.
You may of course mail me with a fix :-) or do a pull request on github.
I will give credit where credit is due…
The current version works for me, so good luck in making it work for you hehe.
Ivo.

Comments

Please have your discussions but don’t ask me for help anymore…