Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Modern Pragmatist
Aug 20, 2008
Is there a command line utility for determining resolution and codec of a video file in linux? I'm attempting to write a script that will run as a cron job and convert video files that meet certain criteria.

Adbot
ADBOT LOVES YOU

dont skimp on the shrimp
Apr 23, 2008

:coffee:

Modern Pragmatist posted:

Is there a command line utility for determining resolution and codec of a video file in linux? I'm attempting to write a script that will run as a cron job and convert video files that meet certain criteria.
file should suffice, I think.

Modern Pragmatist
Aug 20, 2008

Zom Aur posted:

file should suffice, I think.

How have I been using linux for 10 years and never once heard of this :confused:

Thank you.

waffle iron
Jan 16, 2004

Modern Pragmatist posted:

How have I been using linux for 10 years and never once heard of this :confused:

Thank you.
If you're looking for a little more info, ffprobe should do the trick. It's packaged with ffmpeg.

ToxicFrog
Apr 26, 2008


You can also use mplayer, for example, mplayer -vo null -ao null -frames 0 foo.mkv, which is very noisy but also produces a lot of useful output:

code:
[mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0
[mkv] Track ID 2: audio (A_AAC), -aid 0, -alang eng
[mkv] Track ID 3: audio (A_AAC), -aid 1, -alang jpn
[mkv] Track ID 4: subtitles (S_TEXT/UTF8), -sid 0, -slang eng
[mkv] Will play video track 1.
Matroska file format detected.
VIDEO:  [avc1]  720x384  24bpp  29.970 fps    0.0 kbps ( 0.0 kbyte/s)
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
If you want something easier to parse in a shell script, toss -identify into the command line arguments as well.

politicorific
Sep 15, 2007
Question:
I would like to mount an nfs share when my wifi finally connections. I'm running Ubuntu. Adding it to the .bash_profile doesn't work because there's no network connectivity at logon. How can I capture the connection established event and have it run a script?

Could I somehow attempt to mount the share when I get an IP address via DHCP?



Also, when resuming from standby it takes about 20 seconds for my wifi to re-establish my connection. How can I speed this up?

dont skimp on the shrimp
Apr 23, 2008

:coffee:

politicorific posted:

Question:
I would like to mount an nfs share when my wifi finally connections. I'm running Ubuntu. Adding it to the .bash_profile doesn't work because there's no network connectivity at logon. How can I capture the connection established event and have it run a script?

Could I somehow attempt to mount the share when I get an IP address via DHCP?
You can write a script to mount the nfs share when networkmanager connects to a network and put it in /etc/NetworkManager/dispatcher.d/

There's a good how-to on the arch wiki: here.

politicorific posted:

Also, when resuming from standby it takes about 20 seconds for my wifi to re-establish my connection. How can I speed this up?
I guess you could use a static IP for the laptop, but other than that, I don't know. I don't use networkmanager myself.

politicorific
Sep 15, 2007
Shares mounted perfectly, thank you!

other people
Jun 27, 2004
Associate Christ
How do I associate video files with mplayer in Gnome/Nautilus v3? You can right click on files and do "Open with other application...", but that only shows GUI applications, and doesn't include any sort of option to locate a application yourself.

After some googling, I am aware of ~/.local/share/applications/mimeapps.list, but it seems to use .desktop files to make connections, and mplayer obviously doesn't have one of those (if it did, it would be selectable in nautilus already, I imagine). Do I have to learn how to make .desktop files?

I swear in Nautilus < 3.0 you were given the option to locate an application yourself :(.

dont skimp on the shrimp
Apr 23, 2008

:coffee:

Kaluza-Klein posted:

How do I associate video files with mplayer in Gnome/Nautilus v3? You can right click on files and do "Open with other application...", but that only shows GUI applications, and doesn't include any sort of option to locate a application yourself.

After some googling, I am aware of ~/.local/share/applications/mimeapps.list, but it seems to use .desktop files to make connections, and mplayer obviously doesn't have one of those (if it did, it would be selectable in nautilus already, I imagine). Do I have to learn how to make .desktop files?

I swear in Nautilus < 3.0 you were given the option to locate an application yourself :(.
I think you can just type whatever app you want in the "Open with other application..."-dialog, even if it doesn't have a .desktop file.

So just putting mplayer there should work, IIRC.


vvv⁻⁻⁻ Ugh, that's pretty annoying then.

dont skimp on the shrimp fucked around with this message at 21:16 on May 31, 2011

other people
Jun 27, 2004
Associate Christ

Zom Aur posted:

I think you can just type whatever app you want in the "Open with other application..."-dialog, even if it doesn't have a .desktop file.

So just putting mplayer there should work, IIRC.

Yeah, that is the problem. In v3, they seem to have removed any method of specifying the program name yourself. You are just given a list of known applications, and that is it.

Now I have made my own .desktop file and it shows up in the gnome-shell menu, but it doesn't show up in the list of applications to associate with. Very frustrating!


edit: After bothering the guys in freenode #gnome, it was suggested I mangle the totem.desktop file to do what I needed. Totem was uninstalled long ago, but I took it out of an rpm file. After copying the MimeType and Categories lines, the mplayer2.destktop file now lets me properly make an association!

http://pastebin.com/4hzAm7Bn

other people fucked around with this message at 15:29 on May 31, 2011

kyuss
Nov 6, 2004

Quick routing question:

My routing table:

code:
Kernel-IP-Routentabelle
Ziel            Router          Genmask         Flags   MSS Fenster irtt Iface
192.168.2.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0
10.1.106.0      0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
0.0.0.0         192.168.2.254   0.0.0.0         UG        0 0          0 wlan0
0.0.0.0         10.1.106.1      0.0.0.0         UG        0 0          0 eth0
I am unable to ping an adress like "10.1.2.1" as long as the "192.168.2.254" default route exists. After deleting it, everything's dandy until the next reboot.

Question is: how do I fix this the proper way? Would this help?

My /etc/network/interfaces is

code:
auto lo
iface lo inet loopback

allow-hotplug wlan0
iface wlan0 inet dhcp
         wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug eth0
iface eth0 inet static
address 10.1.106.100
netmask 255.255.255.0
gateway 10.1.106.1

kyuss fucked around with this message at 18:29 on May 31, 2011

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

You can't have two 'default' routes, only one can be the default. What you need is just a second route for 10.1.x.y

Something like
code:
$ route add -net 10.1.0.0 netmask 255.255.0.0 gw 10.1.160.1 dev eth0
Basically that says send all your traffic destined for 10.1.x.y to the router/gateway at 10.1.160.1, using eth0

To get the route to be 'persistant', or stick, you'll have to add it somewhere else (do your tests from the commandline until you find what works)

http://www.cyberciti.biz/tips/configuring-static-routes-in-debian-or-red-hat-linux-systems.html

kyuss
Nov 6, 2004

Bob Morales posted:

You can't have two 'default' routes, only one can be the default.
That's what I thought. But this:
code:
0.0.0.0         192.168.2.254   0.0.0.0         UG        0 0          0 wlan0
0.0.0.0         10.1.106.1      0.0.0.0         UG        0 0          0 eth0
shows that there are two default routes at the same time, or am I mistaken here?

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

kyuss posted:

That's what I thought. But this:
code:
0.0.0.0         192.168.2.254   0.0.0.0         UG        0 0          0 wlan0
0.0.0.0         10.1.106.1      0.0.0.0         UG        0 0          0 eth0
shows that there are two default routes at the same time, or am I mistaken here?

Technically, those are both default routes because of their destination of 0.0.0.0. I would imagine the metric is different between the two and thats wlan0 is getting the packets. But I'm not a networking expert.

Actually, the metric looks the same (you're using some language other than English), so maybe it was just the order they are loaded by the networking subsystem. Either way, if you add a more specific route for the eth0 network, it should fix the problem.

Bob Morales fucked around with this message at 18:56 on May 31, 2011

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

What does your network layout look like? Probably one interface is a wireless network in your house and the other is the internet?

Twlight
Feb 18, 2005

I brag about getting free drinks from my boss to make myself feel superior
Fun Shoe
you can put your routes in /etc/init.d/ then make a symlink to rc3.d and or rc5.d so they'll load on which ever runlevel you use.

Twlight fucked around with this message at 20:23 on May 31, 2011

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Twlight posted:

you can put your routes in /etc/init.d/ then make a symlink to rc3.d and or rc5.d so they'll load on which ever runlevel you use.
This is technically true, but also more or less what rc.local was designed for.

kyuss
Nov 6, 2004

Will put my route in rc.local, thanks guys :)

For the record, I have a ton of switches in a lab setup that I'm tasked to run some tests on.

I got tired from permanently switching chairs, so I put a notebook in the testing setup that sits both in the testing network (10.x.x.x) and the company WLAN (192.168.x.x).

When connecting from my work notebook via the company WLAN to the testing notebook, I have the aforementioned routing table on the testing machine.


I'm still curious about the multiple default route mechanics, though.

bort
Mar 13, 2003

A default route is the routing algorithm's last resort. If it can't find a specific route to a packet's destination in the table, it sends it to the default gateway. A second gateway will never be sent traffic unless the first one gets dropped from the table. This doesn't happen automatically and is a good example of why people use routing protocols.

Why it chose 192.168.2.254 as the primary is a good question. I would have assumed it would have chosen a physical interface or a lower IP first, but I don't know.

text editor
Jan 8, 2007
wrong thread

text editor fucked around with this message at 14:24 on Jun 1, 2011

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

ClosedBSD posted:

According to the wiki:

Completing all storybooks in both normal and hard modes earns 800,000 experience points.

and since you can take out and fill multiple copies of some of the books at a time, it honestly might be the easiest way to do it.

Wrong thread I think.

text editor
Jan 8, 2007

Bob Morales posted:

Wrong thread I think.

Yup, definitely was, my bad

Underflow
Apr 4, 2008

EGOMET MIHI IGNOSCO

Bob Morales posted:

Wrong thread I think.

Yeah, but because of the username I had to read it twice while wondering if I was somehow unaware of a whole chunk of insider technology nomenclature.

Twlight
Feb 18, 2005

I brag about getting free drinks from my boss to make myself feel superior
Fun Shoe

Misogynist posted:

This is technically true, but also more or less what rc.local was designed for.

And here I was doing more work than I needed to. Thanks Misogynist.

Dinty Moore
Apr 26, 2007

Modern Pragmatist posted:

Is there a command line utility for determining resolution and codec of a video file in linux? I'm attempting to write a script that will run as a cron job and convert video files that meet certain criteria.

As mentioned, you might be able to use mplayer, or just run 'ffmpeg -i [filename]', and it should provide you some info. Alternatively, try MediaInfo; it's available for Windows, Linux and OS X, with and without GUI, and should give you more detail than you can stomach.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Stupid backup question:

I have an older server with some hard drives in it that I guess I'll use for backups. Not crucial backups, so there's no tape drive or off-site backups or fire safes. Spare me the lecture.

One server I'm going back up is our Joomla test server. So there's the mysql database, and the actual web files. I will probably do the same for our Redmine server.

My question is, should I run the backup script from the backup server, or from the server I'm backing up? I know it doesn't really matter, but maybe it does, and it will save me headaches further down the road, doing it one way versus the other.

Pros for running from the backup server:
I can schedule the jobs to run sequentially. Don't want to overwhelm the server with those 30MB Joomla backups.
The jobs are all in one place, easier to manage

Cons for running from the backup server:
In theory if the server was turned off or had an error, I'm not backing up a single thing (maybe add an email notification to the script, no matter which server)

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Your pro/con list seems to cover the important stuff.

I ended up choosing to pull from the clients because it was a headache setting up the clients to push.

Modern Pragmatist
Aug 20, 2008

Dinty Moore posted:

As mentioned, you might be able to use mplayer, or just run 'ffmpeg -i [filename]', and it should provide you some info. Alternatively, try MediaInfo; it's available for Windows, Linux and OS X, with and without GUI, and should give you more detail than you can stomach.

So I actually ended up going the ffprobe route. file worked on some files but didn't reveal enough information about .mov files. I then tried out mediainfo but it was extremely slow. Now my script is working quite excellently.

One question though. When I run it using nohup it complains about my use of [[ ]] in a bash script. However, if I run it by preceding the command with bash it works.
code:
nohup bash -c 'movieinfo.sh > status.out' &
What is nohup using that would be different than when I run it from the commandline simply using:
code:
./movieinfo.sh > status.out

vikingstrike
Sep 23, 2007

whats happening, captain

Bob Morales posted:

Stupid backup question:

I have an older server with some hard drives in it that I guess I'll use for backups. Not crucial backups, so there's no tape drive or off-site backups or fire safes. Spare me the lecture.

One server I'm going back up is our Joomla test server. So there's the mysql database, and the actual web files. I will probably do the same for our Redmine server.

My question is, should I run the backup script from the backup server, or from the server I'm backing up? I know it doesn't really matter, but maybe it does, and it will save me headaches further down the road, doing it one way versus the other.

Pros for running from the backup server:
I can schedule the jobs to run sequentially. Don't want to overwhelm the server with those 30MB Joomla backups.
The jobs are all in one place, easier to manage

Cons for running from the backup server:
In theory if the server was turned off or had an error, I'm not backing up a single thing (maybe add an email notification to the script, no matter which server)

At work, I use a bit of code that checks to see if all mounts were successful to help address this. If the mounts failed, it goes ahead and emails me which share failed and skips the backup. (In the event that it does fail, I can just check what happened in the morning and initiate a manual backup afterwards.) I run the script from the backup server and just throw it in crontab.

nitrogen
May 21, 2004

Oh, what's a 217°C difference between friends?

politicorific posted:

Question:
I would like to mount an nfs share when my wifi finally connections. I'm running Ubuntu. Adding it to the .bash_profile doesn't work because there's no network connectivity at logon. How can I capture the connection established event and have it run a script?

Could I somehow attempt to mount the share when I get an IP address via DHCP?



Also, when resuming from standby it takes about 20 seconds for my wifi to re-establish my connection. How can I speed this up?


The old school way to do this is with autofs/automounter. apt-get autofs, and set your shares up in it with a 15 min timeout. They will mount on directory access, and unmount on inactivity.

kyuss
Nov 6, 2004

I was pissed off by Unity, so I decided to switch distributions.

I spent 89€ on a SSD and decided to play around a bit:

Fedora 15 - picked it over its Gnome3 desktop, liked it at first, but then it started to crash on me, especially after waking up from standby / hibernate. Installed the catalyst driver for my graphics card on a hunch, but this made things worse - got garbled graphics in menus. I felt much of this was due to Fedora being licensing nazis, so I decided leave it at that.

Linux Mint 11 - nice GUI, but it felt old after trying out Gnome3 for a few days. Tried to install Gnome3, had the GUI permanently crashing on me right after login, decided to try another distro.

Arch Linux - ugly text installer that kept giving me poo poo because I tried to change the partition layout. Had to manually pick a console font because I dared to change the keyboard layout to other than US - weird. Installation was very quick after that. First fuckup was at boot, Grub somehow got my partition layout wrong. Fixed it by hand. Second fuckup after changing to Grub2 - it had the wrong settings from Grub1. Fixed it again.

Installing xserver and Gnome3 on the other hand was a breeze. Had some trouble initially getting sound in flashplugin, because I didn't read its installation instructions carefully enough.

So far Arch feels lightning fast, and easily configurable. Hardware support seems great. Currently, I have to start Gnome3 manually via "startx", but I kinda like it, will propably leave it at that.

HolyDukeNukem
Sep 10, 2008

kyuss posted:

I was pissed off by Unity, so I decided to switch distributions.

I spent 89€ on a SSD and decided to play around a bit:

Fedora 15 - picked it over its Gnome3 desktop, liked it at first, but then it started to crash on me, especially after waking up from standby / hibernate. Installed the catalyst driver for my graphics card on a hunch, but this made things worse - got garbled graphics in menus. I felt much of this was due to Fedora being licensing nazis, so I decided leave it at that.

Linux Mint 11 - nice GUI, but it felt old after trying out Gnome3 for a few days. Tried to install Gnome3, had the GUI permanently crashing on me right after login, decided to try another distro.

Arch Linux - ugly text installer that kept giving me poo poo because I tried to change the partition layout. Had to manually pick a console font because I dared to change the keyboard layout to other than US - weird. Installation was very quick after that. First fuckup was at boot, Grub somehow got my partition layout wrong. Fixed it by hand. Second fuckup after changing to Grub2 - it had the wrong settings from Grub1. Fixed it again.

Installing xserver and Gnome3 on the other hand was a breeze. Had some trouble initially getting sound in flashplugin, because I didn't read its installation instructions carefully enough.

So far Arch feels lightning fast, and easily configurable. Hardware support seems great. Currently, I have to start Gnome3 manually via "startx", but I kinda like it, will propably leave it at that.

welcome to arch linux! make sure to check out yaourt. It's basically another repository for unsupported software, and I mean any unsupported software. I love having arch since you know what you have on your computer and feels like it reduces the bloat on the machine. Ubuntu just doesn't feel right especially apt compared to pacman.

text editor
Jan 8, 2007

kyuss posted:

So far Arch feels lightning fast, and easily configurable. Hardware support seems great. Currently, I have to start Gnome3 manually via "startx", but I kinda like it, will propably leave it at that.

https://wiki.archlinux.org/index.php/Start_X_at_Boot if you want it to be automatic, just don't do it the .bash_profile way unless you want it to start X after you login via command line

HolyDukeNukem
Sep 10, 2008

ClosedBSD posted:

https://wiki.archlinux.org/index.php/Start_X_at_Boot if you want it to be automatic, just don't do it the .bash_profile way unless you want it to start X after you login via command line

he could just add gdm or whatever login manager he wants into rc.conf. That will start X for login which is really all that is important for most people.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

kcncuda71 posted:

he could just add gdm or whatever login manager he wants into rc.conf. That will start X for login which is really all that is important for most people.

Right, this is a much better way to do it:

https://wiki.archlinux.org/index.php/Display_Manager

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
Does anyone know the details of how filefrag works with the verbose (-v) switch?

The man page says this:
pre:
OPTIONS
       ...
       -v     Be verbose when checking for file fragmentation.
This doesn't necessarily imply that I should get different results if I use -v, which I do if I look at a backup of the hard drive in my parents' computer:

pre:
# filefrag disk.img.xz 
disk.img.xz: 178 extents found
# filefrag -v disk.img.xz | tail
 176 5732352 438468608            32768 
 177 5765120 438501376            27837 eof
disk.img.xz: 14 extents found
When I think "verbose", I think "more output of the same data", not "do a more thorough analysis".

Ziir
Nov 20, 2004

by Ozmaugh
I have no idea what I did but I must have accidentally done something cause now when I use VIM my backspace key is in "insert mode" like in a text editor. You know, instead of deleting backwards it deletes whatever is at the pointer. How do I turn this off.

text editor
Jan 8, 2007

Ziir posted:

I have no idea what I did but I must have accidentally done something cause now when I use VIM my backspace key is in "insert mode" like in a text editor. You know, instead of deleting backwards it deletes whatever is at the pointer. How do I turn this off.

This is mostly a guess, but I think that is one of the vi-like behaviors in vim

adding:

code:
set nocompatible
to your .vimrc will probably fix that, but your vim won't act as much like vi (which may be a problem or a benefit, depending on what you're used to)

Adbot
ADBOT LOVES YOU

Ziir
Nov 20, 2004

by Ozmaugh
No, that didn't help. I swear I had it working like regular backspace even just one hour ago.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply