Thursday, 7 August 2014

Ripping DVD with FFMPEG

This more a post to myself than to others, but even so, others might find it useful as well. Because sometimes having a DVD is inconvenient compared to your usual Matroska file saved on a HDD, I was looking for a simple way to encode the DVD. I have it decrypted and copied in a folder, but there are a bunch of 1 GiB VOB files, which is a) big, b) inconvenient. So the idea is, join the VOBs and transcode it into h264 (substitute theora, vp8 or dirac if you are more radical FLOSS supporter than me) and FLAC for audio. Actually simple search on the net presented me with an easy solution using FFMPEG (I kinda had problems with using the GUI ripping software), but it took some more research (reading the ffmpeg man pages) to find out how to rip more than one audio stream into the final file (I used a JAP/ENG DVD about Aikido).

So, without further ado, here's the command:

ffmpeg -i concat:VTS_01_1.VOB\|VTS_01_2.VOB\|VTS_01_3.VOB -map 0:v -map 0:a -c:v libx264 -crf 18 -vf yadif -c:a flac aikido.mkv

And some info:

  • The ffmpeg command is in ffmpeg package, from rpmfusion free. It's not in Fedora proper because of patent issues, I believe.
  • -i concat:VTS_01_1.VOB\|VTS_01_2.VOB\|VTS_01_3.VOB marks that input file is a direct join of the three VOB files listed, the backslash is to escape the "|" so that it's seen by ffmpeg instead of bash.
  • -map 0:v tells that ALL video streams are to be copied/transcoded.
  • -map 0:a tells that ALL audio streams are to be copied/transcoded.
  • -c:v libx264 tells that for video streams we'll use libx264 codec (i. e. we'll transcode to h264).
  • -crf 18 tells that we want to use Constant Rate Factor, value 18 (which might be a bit of overkill, but I don't want to sacrifice quality for space and I don't have the time tune it).
  • -vf yadif use YADIF deinterlacing, because I don't wanna keep interlacing in the video – I'll be playing it on a computer, after all.
  • -c:a flac tells we'll be using FLAC for audio streams. It's free and lossless. Again, it might be overkill, but I like to keep the original sound without using nonfree codec like AAC or AC3.

When I originally omitted the -map parameters, only single video and single audio stream were transcoded, so it's necessary if you want to transcode more audio streams or different stream than the first one.

Thursday, 26 June 2014

Connecting Linux machine to windows AD and mounting remote user dirs automagically ‒ how?

Dear lazy web,

I've been working for the last year as an informatics teacher at high school and I'm playing with the idea of trying to migrate a couple of machines (mine for the start, I still need to connect to remote win desktop for certain tasks :-D) fully to Linux which would work as well as the windows machines WRT network shares which are on a windows AD server that I don't have admin access to. There are couple of problems, some of which I was able to solve, some of which I have an idea how to solve and some of which I don't now at all how to solve, any pointers appreciated! I'm testing this on Fedora 20 by the way.

Joining the domain

This one took me a lot time to solve and I had a couple of times when I gave up. Mostly because I didn't know the AD server hostname and even when I found it, I still couldn't get it to work via the system-config-authentication, nor the config files in /etc. By chance I was lucky to run across a QA test case for joining the AD domain! Well, and that worked like a charm. So the trick is to run:

$ realm join --user=User

Logging in

Kinda superfluous for me, but a real need when there would be more users to use the computer. That was what I was originally trying to achieve. After joining the domain with the above example, it started to work magically. I don't remember if there was anything else that I needed to set up, probably not. But you definitely need oddjob-mkhomedir that sets up the environment when a new user (unknown to the local computer) logs in for the first time. I believe it should be installed automagically during the join. I've tried it in CLI and in LightDM, both worked by the time I successfully joined.

Mounting remote locations

Well, this is the last thing I was able to do. It does not require logging in, it does require joining the domain. You must fill your login credentials, though, if you don't have a guest share. I've run across a bug in gvfs-samba ‒ when I'm copying multiple files over the network, it hangs. So for the network shares I'm using Dolphin at the moment. The GUI managers I've tried work both in the same way, just go to the location bar, type smb://username@domain/share, you're asked for a password, then it mounts and you can use it. In Thunar, which uses gvfs, you need gvfs-samba package. You can also mount it in CLI:

gvfs-mount smb://username@domain/share

On my old notebook which was essentially multiple times upgraded old fedoras this also created a mount point in the filesystem (somewhere under /run/user/gvfs), in my new computer (which has fresh Fedora 20), this does not create a mount point in the filesystem. Quick search on the internet showed, I need gvfs-fuse package and its daemon running. Then it appears under /run/user/⟨uid⟩/gvfs/* which then can be easily symlinked for wine to appear as a drive if needed.

Mounting the shared network shares on login

Now, here's where I have vague idea that I could probably call something like gvfs-mount on login, the problem is that it needs password. Is there a way to pass the credentials from login credentials to the mount data? Or ask for them only for the first time and in gui (meaning the mount point is created automatically, the user is asked for login credentials which are then saved in his default keyring)? The path to network share should be same for all users.

Mounting user specific network shares on login

Now, the same as above, but the network path depends on the user, i.e. something like smb://username@domain/share/username.

Doing the above two for new users as well

How do I run a custom script when a local user is created during first remote login?

"Mounting" the network shares as drives in wine

Now, here I have an idea that some simple symlinking should do the trick, the network shares names should stay the same (even the directories they appear in the filesystem), so it shouldn't be a problem.

So, once again, any help, pointers, suggestions are very welcome, I'll try to keep this post updated with new information and new solutions.

UPDATE: Solution to user automount problem

So, with the help of people that commented in the comments section, I found a solution that's called pam_mount. I'm not sure how to do it the right way (TM), but here's what made it work for me:

  • Add auth optional before auth sufficient cached use_first_pass, so that the credentials are shared between pam mount and login to AD. I added it to /etc/pam.d/system-auth, I'm not sure that's the correct way though.
  • Add session optional so that pam_mount is executed at the start of the session. I added it to the end of the same file as above.
  • Edit /etc/security/pam_mount.conf.xml. Typical line would look like <volume user="*" sgrp="DOMAIN\domain users" fstype="cifs" server="" path="Shares/Usr_home/%(DOMAIN_USER)" mountpoint="/home/DOMAIN/%(DOMAIN_USER)/.ad/%(DOMAIN_USER)" />

And voila, it works. I only have one still unsolved issue with this, and that's I cannot get it not to use forceuid, forcegid and nounix mount options. I haven't tried yet, if it's a problem with pam_mount, or mount.cifs (i. e. if the server/client combination support cifs unix extensions like POSIX acls)...

Sunday, 9 February 2014

Why I don't like new UIs

I've recently had two experiences with UIs that are designed to be streamlined and user-friendly. And, frankly, to me they're anything but that.

Windows 8

For some reason I had to use it and well, it took me several minutes to figure out that the loading...-like screen is actually a log in screen and I need to click a nearly invisible single-coloured button to actually allow me to select (or write) a username and log in. Then it took me another several minutes to figure out how to find Desktop. During my work I was several times greeted with IE instead of Start menu (who the hell did have the idea to put an IE icon next to a sensitive corner that gets you to the start menuscreen?) and found out how to log out by sheer luck. Didn't figure how to shut down from logged user. Ugh, I have to tell, GNOME Shell is heaven compared to that.

Fedora 20 Installation

Everything is parallel. I have to say, I prefer the linearity of the old Anaconda. Just clicking next, next, next and nothing gets missed... Now, well, that's another question. The icons being single coloured didn't help much either. I just hate these new symbolic icons that the PC world of nowadays is plagued with. E. g. here on blogger I always confuse pencil with label. *Sigh*

But well, having to spend 30 mins on custom partitioning and only figuring the problem after reading a manual, when it was actually a something the installed could have told me itself, is a completely another story :( Why does the new anaconda tells me the partition is not correct, but does not tell me why. Why? Why? If it knows it's not correct, it should tell me the reason, not just pop up a bubble telling me something is wrong, that Fedora needs 5 Gigs of space (which was perfectly satisfied by the configured layout) but not telling me, that the problem is missing /boot/efi partition?! Something that's was obvious to the installer but not to the human encountering UEFI for the first time... Why it cannot tell me the error it encounters? Why? Why are all the new UIs pretending human is a brain-dead idiot with less intelligence than a well-trained monkey?

But to end it on positive note, F20 on Live USB is freakishly fast as well as the actual installation :-p