Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

2017-03-30

HOWTO: base64 manipulations in Linux

Do you want to decode some base64-encoded strings (or any other data), or convert some binary file to text (in base64)?
It's quite easy to do that in Debian GNU/Linux: base64 utility is a part of coreutils package (that package has a "required" priority, i. e., it's an essential package for the system to work).

When you finish typing your strings, don't forget to press <Enter> followed by <Ctrl> + <D> (or <Ctrl> + <D> twice, if you don't like newlines).
$ base64
Hello, world!
SGVsbG8sIHdvcmxkIQo=
$ 
$ base64 -d
SGVsbG8sIHdvcmxkIQo=
Hello, world!
But it may be safer to use file input-output, e. g.:
$ base64 -d in.txt > out.dat

References:
  1. man base64
  2. GNU Coreutils: base64 invocation
  3. Base64 - Wikipedia

See also:

2016-11-23

2016-06-09

HOWTO: fix mic settings on Acer Aspire 3810T notebook in Linux

Once upon a time... You try a Linux Skype version (e. g., 4.3.0.37-1 for Debian) on Acer Aspire 3810T notebook and no sound is heard from the internal microphone.

The microphone is not muted in AlsaMixer (alsamixer); in PulseAudio Volume Control (pavucontrol) mic looks OK too.

Let's record some mic sound using Audacity audio editor... Here is a screenshot:
As you can see, the right channel ("R") is simply inverted left channel ("L"); let's call that "R=-L".

Let's look at the system environment details...
$ uname -a
Linux Notebook1 4.5.0-1-amd64 #1 SMP Debian 4.5.1-1 (2016-04-14) x86_64 GNU/Linux

$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version k4.5.0-1-amd64.

$ dmesg | grep Acer
[    0.000000] DMI: Acer Aspire 3810T/Aspire 3810T, BIOS V1.28 08/10/2010
...

$ dmesg | grep snd_hda_codec_realtek
[    3.796475] snd_hda_codec_realtek hdaudioC0D0: autoconfig for ALC269: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[    3.796496] snd_hda_codec_realtek hdaudioC0D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    3.796510] snd_hda_codec_realtek hdaudioC0D0:    hp_outs=1 (0x15/0x0/0x0/0x0/0x0)
[    3.796522] snd_hda_codec_realtek hdaudioC0D0:    mono: mono_out=0x0
[    3.796531] snd_hda_codec_realtek hdaudioC0D0:    dig-out=0x1e/0x0
[    3.796540] snd_hda_codec_realtek hdaudioC0D0:    inputs:
[    3.796550] snd_hda_codec_realtek hdaudioC0D0:      Mic=0x18
[    3.796559] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x12

$ dmesg | grep HDA
[    3.854039] input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card0/input13
[    3.855277] input: HDA Intel Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input14
[    3.855365] input: HDA Intel Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input15
[    3.855451] input: HDA Intel HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1b.0/sound/card0/input16

$ cat /proc/asound/pcm
00-00: ALC269 Analog : ALC269 Analog : playback 1 : capture 1
00-01: ALC269 Digital : ALC269 Digital : playback 1
00-03: HDMI 0 : HDMI 0 : playback 1

$ cat /sys/module/snd_hda_intel/parameters/model
(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)
Nothing interesting, except the Realtek ALC269 audio codec.

Thus, it's time to look at the microphone itself.
Terminal markings (DATA, VDD, CLK, GND) suggest it's a digital microphone (not analog one), and it looks like a mono (1-channel) one.

Fortunately, there is a way to fix the problem: you should create a modprobe configuration file with appropriate settings for Intel HDA driver kernel module.

If you're interested, you can get some info about some kernel modules:
$ /sbin/modinfo snd-hda-intel
...
$ /sbin/modinfo snd-hda-codec-realtek
...
But let's get back to the configuration.
Create, e. g., a /etc/modprobe.d/sound.conf file and put an appropriate configuration string (i. e., options snd-hda-intel model=MODEL, where MODEL is a specific model string) into it:
$ sudoedit /etc/modprobe.d/sound.conf
...
Let's try some model names that look usable.
  1. "laptop-amic".
    Some minor changes in dmesg output:
    $ dmesg | grep snd_hda_codec_realtek
    ...
    [    3.803435] snd_hda_codec_realtek hdaudioC0D0:    inputs:
    [    3.812954] snd_hda_codec_realtek hdaudioC0D0:      Mic=0x18
    [    3.817411] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x19
    [    3.817414] snd_hda_codec_realtek hdaudioC0D0:      Internal Mic=0x12
    
    And major effects on mic sound output:
    Yes, funny enough, it's a stereo low-level noise, and there's no intelligible sound (!); and that's not strange: "amic" stands for "analog microphone", so it's just a useless option for digital ones.
  2. "laptop-dmic".
    R=-L (no significant changes).
  3. "alc269-dmic".
    R=L.
  4. "alc271-dmic".
    R=-L (no significant changes).
  5. "inv-dmic".
    Some audio signal in the left channel, and no signal (zero level) in the right one (R=0).
Conclusion: "inv-dmic" represents the real configuration (if you want pseudo-stereo, you can also try "alc269-dmic"); so here is my suggested config:
$ cat /etc/modprobe.d/sound.conf
options snd-hda-intel model=inv-dmic

$ cat /sys/module/snd_hda_intel/parameters/model
inv-dmic,(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)
External links:
      1. https://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio-Models.txt
      2. https://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio.txt
      3. https://www.kernel.org/doc/Documentation/sound/alsa/alsa-parameters.txt
    1. https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/sound/pci/hda/patch_realtek.c (kernel/git/torvalds/linux.git - Linux kernel source tree)
  1. ALSA - Debian Wiki
  2. HdaIntelSoundHowto - Community Help Wiki (Ubuntu)

2016-05-20

Software: gpm, a mouse service for Linux console

There's a nice piece of software called gpm (general purpose mouse).
It's a mouse server for Linux console. (BTW, touchpads are supported too).

In Debian (and its derivatives like Ubuntu), it's very easy to start using it by simple installation from package repositories:
# apt-get install gpm
And you should see a rectangular mouse pointer soon ;)

In case it gets stuck, you can try restarting the gpm service this way:
# service gpm restart
or, a more generic command if you don't use Debian:
# /etc/init.d/gpm restart
See also: HOWTO: reload mouse driver in Linux

External links:
---
Last updated: 2016-07-04

2016-04-29

HOWTO: force filesystem check on reboot in a Linux system

Usually, only a superficial file system check is performed automatically on boot up, and it's sufficient; but sometimes it could be handy to force a full file system check (i. e., to run the Linux fsck utility) to ensure the FS is really OK.
  1. Classic init (SysVinit): just reboot the system with a special option:
    # shutdown -rF now
  2. systemd init: much more interesting: at the boot time, you need to append a special kernel command line parameter (e. g., you can specify it at the GRUB command line):
    linux /boot/vmlinuz root=UUID=... ro fsck.mode=force

P. S. It should then check all the filesystems enabled for checking in /etc/fstab.

References:
  1. man shutdown
  2. man systemd-fsck
  3. man fstab
  4. man fsck

2016-01-27

HOWTO: play MIDI files with VLC in Debian

It's very easy! And should also work for Ubuntu (and other Debian derivatives).
  1. First of all, make sure you have already installed the VLC media player:
    # apt-get install vlc
  2. Install the FluidSynth plugin:
    # apt-get install vlc-plugin-fluidsynth
  3. Enjoy!
    You can open your file either with the VLC GUI, or from the CLI, e. g.:
    $ vlc ~/Music/MyFavoriteSong.midi

2015-12-28

HOWTO: preventing aptitude from breaking the APT package setup

Initial conditions:
  • usually, you use apt-get (from the apt package) for Debian package maintenance (installing, removing, upgrading etc.);
  • sometimes you launch aptitude (aptitude package) to do some work;
  • after doing some work with apt-get, you notice that aptitude hasn't caught up with the current package state (i. e., it wants to install / remove some package(s) just from the start).
Solution: hide (or delete) the outdated package states file from aptitude (note: it'll overwrite an old backup, "/var/lib/aptitude/pkgstates.old", if present):
$ cd /var/lib/aptitude
# mv pkgstates pkgstates.old
P. S. This should also work for Debian derivatives (e. g. Ubuntu).

2015-08-01

Overview: barcode reading software in Linux

Tested in Debian Jessie:
# apt-get install dmtx-utils zbar-tools

2014-07-01

Outdated important software packages in Debian unstable


Debian bug numbers get added if known. The packages are organized in collections by date. Updated ones should get striked out.

2014-06-18

HOWTO: reload mouse driver in Linux

Sometimes your mouse device (it can be even a touchpad or a trackball) can unexpectedly get stuck [maybe it's a new bug that should be reported?!] in the middle of your work (or maybe it just didn't get recognized after plugging/unplugging/replugging it in).
In such cases, reloading the mouse driver may help (e. g., for PS/2 mouse driver, Linux kernel module is called "psmouse"):
# modprobe -r -v psmouse
# modprobe -v psmouse
You can also get info on any kernel driver modules installed in your system to support different mouse types (e. g., for serial mice, the kernel module is called "sermouse"), and also check if it's currently loaded:
$ ls /lib/modules/$(uname -r)/kernel/drivers/input/mouse
...  sermouse.ko  ...
$ /sbin/modinfo sermouse
...
$ lsmod | grep sermouse
...
Notes:
  1. you can check the dmesg log for any strange symptoms:
    $ dmesg | grep psmouse
    ...
    [    9.0123456] psmouse ... lost synchronization, throwing 2 bytes away.
  2. the trick will fail if the needed kernel module is built-in (probably only reboot can help);
  3. sometimes it's some X11 driver which causes problems (please check /var/log/Xorg.0.log);
  4. if you use your mouse in console mode, perhaps it's good to check the post about gpm.
---
Last updated: 2016-05-20

2014-06-10

HOWTO: work around SATA HDD hotplug problem (in Linux)

Sometimes some SATA controllers do not recognize an attached HDD if it was hot-plugged after the Linux system has been booted. Fortunately, there're some simple workarounds (note: it should work for some PATA controllers too).
  1. A standard "soft" solution (should work by default):
    1. Connect the HDD to the SATA controller (and make sure it doesn't get auto-recognized by the system).
    2. Force a rescan of SCSI buses:
      # for h in /sys/class/scsi_host/host*/scan; do echo "- - -" > $h; done
    3. Ensure the drive has been recognized (check the dmesg logs, run lsblk etc.) and enjoy it!
  2. A more "aggressive" method
    (note: some old SATA controller made by VIA Technologies and managed by sata_via kernel driver is used here for sample purposes; should work with any recent 2.6+ Linux kernel versions):
    1. To prevent any data loss, flush caches & unmount all the mounted partitions for all the drives connected to any VIA SATA controller(s) installed on the affected system!
    2. Remove the kernel driver module (verbosity is helpful sometimes):
      # modprobe -v -r sata_via
    3. Physically attach (or detach) any drives to the VIA SATA controller.
    4. Re-insert the kernel module:
      # modprobe -v sata_via
    5. Enjoy!
References:
  1. Scanning Storage Interconnects - RHEL7 Storage Administration Guide
---
Last updated: 2014-06-20

2014-01-20

Nonsensical minor long-running bug in Ubuntu

The file containing a default Ubuntu wallpaper is still named 'warty-final-ubuntu.png' (in honor of the first Ubuntu release, 4.10 "Warty Warthog"), but this PNG image actually became a JPEG one sometime in 2008!
The following "bug" still affects the "ubuntu-wallpapers" package versions found in the current Ubuntu stable (13.10 "Saucy Salamander") and development release (14.04 LTS "Trusty Tahr") repositories:
https://bugs.launchpad.net/bugs/296538
Nobody cares. Enjoy! :)

2013-12-27

Cool method to test analog & digital (DVB-T) TV receivers?

There seems to be a cool unconventional method to test your analogue (PAL / SECAM) or digital (DVB-T) TV receiver (set-top box, unit, tuner etc.);
all you need is a PC running Linux with X11 and a video card with analog VGA output (preferably not very old one),
just read the following article (by Fabrice Bellard, 2005):
(I've not tested it personally yet, but it looks promising enough).

2013-11-25

dd utility: the rescue versions

Apart from the traditional implementations of a Unix dd utility (e. g., one found in the GNU Core Utilities), there are some special versions of it, dedicated for rescuing the data from damaged (badly readable) disks:
  1. GNU ddrescue (by Antonio Diaz Diaz);
    seems to be the best choice from these two ones [1, 2];
    there's a GUI log viewer for it (ddrescueview), and also some other helper utilities (ddrutility);
  2. dd_rescue (by Kurt Garloff);
    there's also a wrapper script for it called dd_rhelp.
The Debian distribution software archives, starting from version 7.0 ("Wheezy"), have only the GNU ddrescue; you can install it the following way:
# apt-get install gddrescue
The convenient way to use this utility is to make an image (a binary dump) of the whole defective disk (FDD, HDD, CD, DVD etc.) with its help, and then apply data recovery / content extraction programs (e. g., TestDisk) directly to the disk image.

Anyway, regular backups & redundant data storage solutions should save you from data recovery problems :-)

References:
  1. Disk drive recovery: ddrescue, dd_rescue, dd_rhelp - System Administration Bits of Knowledge (by John Gilmore)
  2. Damaged Hard Disk - CGSecurity
---
Last updated: 2013-12-08

2013-09-30

LCD display optimized video mode: CVT-R & Linux

Many modern LCD displays (ones with 60 Hz vertical refresh frequency) should support an improved video mode with reduced blanking intervals (CVT-R), which can save some signal bandwidth and reduce the cost of the cabling (sometimes you can use a single-link DVI / HDMI cable instead of a dual-link one to support some of the high-definition resolutions; due to reduced signal bandwidth, a longer, cheaper cable with a non-perfect shielding can be used with reduced risk of electromagnetic interference).
Unfortunately, the best mode sometimes can be missing from the display's EDID ("extended display identification data" accessed by computer through DDC), so your computer won't be able set the best mode automatically, and you'll need to do some manual configuration.
(The sample commands are for Debian GNU/Linux 7.0 "Wheezy", but should work for many other systems).
  1. First of all, find out the native resolution (e. g., 1920 x 1080) and refresh rate (should be a multiple of 60 Hz: 60 Hz, 120 Hz etc.) for your display.
  2. Try to calculate a suitable video mode string using cvt utility (from the xserver-xorg-core Debian package); 60 Hz is the default refresh rate, so it can be omitted:
    $ cvt -r 1920 1080
    # 1920x1080 59.93 Hz (CVT 2.07M9-R) hsync: 66.59 kHz; pclk: 138.50 MHz
    Modeline "1920x1080R"  138.50  1920 1968 2000 2080  1080 1083 1088 1111 +hsync -vsync
    $ cvt -r 1920 1080 120
    # 1920x1080 119.88 Hz (CVT) hsync: 137.14 kHz; pclk: 285.25 MHz
    Modeline "1920x1080R"  285.25  1920 1968 2000 2080  1080 1083 1088 1144 +hsync -vsync
  3. Check the current video mode of your display through the display's menu (and write down those values somewhere for reference). If the actual clock values are higher than calculated by cvt, then it's reasonable to test the freshly calculated video mode.
  4. For quick video mode changes, you can use xrandr utility (from the x11-xserver-utils Debian package):
    $ xrandr
    Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
    DVI1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 456mm x 123mm
       1920x1080      60.0*+ 
       1024x768       60.0  
       800x600        60.3     56.2  
       640x480        59.9  
    VGA1 disconnected (normal left inverted right x axis y axis)
    HDMI1 disconnected (normal left inverted right x axis y axis)
    $ xrandr --output DVI1 --mode 800x600
    $ xrandr --newmode "1920x1080R"  138.50  1920 1968 2000 2080  1080 1083 1088 1111 +hsync -vsync
    $ xrandr --addmode DVI1 1920x1080R
    $ xrandr --output DVI1 --mode 1920x1080R
    
  5. For permanent effect, you'll need to change X11 settings by putting the generated modeline into the proper section of the /etc/X11/xorg.conf config file:
    Section "Monitor"
        Identifier     "Monitor0"
        VendorName     "Vendor1"
        ModelName      "Model2"
        HorizSync       30.0 - 150.0
        VertRefresh     50.0 - 160.0
        Option         "DPMS" "true"
        Modeline       "1920x1080R"  138.50  1920 1968 2000 2080  1080 1083 1088 1111 +hsync -vsync
    EndSection
    
    Section "Screen"
        Identifier     "Screen0"
        Monitor        "Monitor0"
        DefaultDepth    24
        SubSection     "Display"
            Depth       24
            Modes      "1920x1080R"
        EndSubSection
    EndSection
    Don't forget to restart the X server for updated configuration to take effect.
  6. The video mode for Linux console probably can be changed using KMS (kernel mode setting); there's some good info about KMS settings on nouveau Wiki.

See also:

2013-08-31

HOWTO: configure the OS to use a 100 Hz refresh capable CRT monitor in Linux

  • Test environment.
    • Hardware
      • Monitor: Samsung SyncMaster 959NF
        • Test display resolution: 1024 * 768 @ 100 Hz
      • Video card: based on Nvidia GeForce2 MX400
        $ lspci | grep -i nvidia
        01:00.0 VGA compatible controller: NVIDIA Corporation NV11 [GeForce2 MX/MX 400] (rev b2)
      • CPU: x86-compatible (some old AMD Athlon one)
    • Software
      • OS: Debian GNU/Linux 7.0 "Wheezy" / i386
      • Video driver: nouveau
  • X11 graphical mode configuration.
    1. Use cvt utility to generate a modeline for X11:
      $ cvt 1024 768 100
      # 1024x768 99.97 Hz (CVT) hsync: 81.58 kHz; pclk: 112.25 MHz
      Modeline "1024x768_100.00"  112.25  1024 1096 1200 1376  768 771 775 816 -hsync +vsync
      
      Note: 100 Hz is a non-standard refresh rate for CVT.
      If CVT timings don't work for some ancient monitor, you can also try to use gtf utility to generate somewhat older GTF timings:
      $ gtf 1024 768 100
      
        # 1024x768 @ 100.00 Hz (GTF) hsync: 81.40 kHz; pclk: 113.31 MHz
        Modeline "1024x768_100.00"  113.31  1024 1096 1208 1392  768 769 772 814  -HSync +Vsync
      
      
      Both cvt & gtf utilities are part of xserver-xorg-core Debian package.
    2. Change X11 settings by putting the generated modeline into the proper section of the /etc/X11/xorg.conf file:
      Section "Monitor"
          Identifier     "Monitor0"
          VendorName     "Samsung"
          ModelName      "SyncMaster"
          HorizSync       30.0 - 110.0
          VertRefresh     50.0 - 160.0
          Option         "DPMS" "true"
          Modeline       "1024x768_100.00"  112.25  1024 1096 1200 1376  768 771 775 816 -hsync +vsync
      EndSection
      
      Section "Screen"
          Identifier     "Screen0"
          Monitor        "Monitor0"
          DefaultDepth    24
          SubSection     "Display"
              Depth       24
              Modes      "1024x768_100.00"
          EndSubSection
      EndSection
    3. Restart the X server for updated configuration to take effect.
  • Here are the sample settings for non-X11 user interfaces, put into /etc/default/grub (the GRUB2 config).
    For modified settings to make effect, don't forget to execute update-grub2 as superuser and then reboot.
    ...
    GRUB_CMDLINE_LINUX="video=VGA-1:1024x768M@100"
    ...
    # The resolution used on graphical terminal
    # note that you can use only modes which your graphic card supports via VBE
    # you can see them in real GRUB with the command `vbeinfo'
    GRUB_GFXMODE=1024x768
    ...
    Notes:
    1. The Linux command line option mentioned aboves allows to set a desirable video mode for virtual console using kernel mode setting (KMS).
      There's more info about KMS settings on nouveau Wiki.
    2. Display refresh rate doesn't seem to be specifiable for GRUB bootloader graphical mode. This initial graphic mode depends heavily on VBE.
    3. Other caveats: video play in console framebuffer (i. e., using mplayer) has not seemed to work for me in this test setup.

See also:

2013-05-09

HOWTO: get hardware sensors info (temperature, fan speed, voltage etc.) in Linux

(Tested in Debian Wheezy).
  1. Install the lm-sensors software package:
    # apt-get install lm-sensors
  2. Run the interactive hardware monitoring chip detection script:
    # sensors-detect
    Usually, it asks a lot of questions, and you can automatically answer 'yes' on them (but be careful: on some systems a full scan can cause some problems, e. g., a false chip detection or even a system hang):
    # yes | sensors-detect
  3. After choosing to add the needed module names automatically to the /etc/modules config file, it's good to check it for duplicate entries (and possibly other garbage).
  4. Reboot (or try to load the newly added kernel modules manually).
  5. Finally, just execute the following command to print the sensors information:
    $ sensors

2013-04-11

HOWTO: convert audio CD image (FLAC + CUE) to MP3 tracks in Linux

Imagine you've archived your favourite audio CD into FLAC/CUE pair format (or maybe you've purchased some album in that digital downloadable lossless audio format, who knows), and now you want to convert it to the standard MP3 files for playing that album in your good old digital music player.

Let the files be processed in Debian GNU/Linux environment (sample commands tested in Debian 7.0 "Wheezy", and should also work for all Debian-based distros, e. g. Ubuntu, Mint etc.; Bash shell is assumed to be installed & used by default).

First of all, you should install all the necessary tools: FLAC (for decoding FLAC to WAV), LAME (to convert WAV to MP3), cuetools (to parse the CUE sheet) and shntool (to cut the big WAV file into smaller tracks according to the CUE sheet breakpoints).
# apt-get install flac lame cuetools shntool
Then the conversion process itself begins.
$ flac -d MyMusic.flac
$ cuebreakpoints MyMusic.cue | shnsplit MyMusic.wav
$ rm MyMusic.wav
$ for file in split-track*.wav; do lame -V0 $file; done
$ rm split-track*.wav
The output files are by default MP3 VBR V0, 44.1 KHz, Joint Stereo; it should be decent for most situations.
After conversion, you can process split-track*.mp3 files with your favourite media tagger application.
Enjoy.

2013-04-07

Default Sudo lecture

Here is a standard Sudo lecture, which can be seen at the user's first sudo run time (the following is an unmodified quote extracted from the sudo-$VERSION/plugins/sudoers/check.c source file found in the original sudo 1.8.6p7 source tarball):
#define DEFAULT_LECTURE "\n" \
    "We trust you have received the usual lecture from the local System\n" \
    "Administrator. It usually boils down to these three things:\n\n" \
    "    #1) Respect the privacy of others.\n" \
    "    #2) Think before you type.\n" \
    "    #3) With great power comes great responsibility.\n\n"
References:
  1. Sudo Main Page

2013-03-10

HOWTO: losslessly convert FLV video to MP4 in Linux (Debian)

Well, let's imagine we have a Flash Video (FLV/F4V) container file (possibly "unseekable" or with other minor problems) containing MPEG-4 AVC video & AAC (or MP3) audio.

We'll convert ("remux") it to MP4 without any transcoding (re-encoding), so it'll be very fast, and using only the free tools (available in the official Debian GNU/Linux repositories).

Note: unfortunately, old FLV videos containing VP6 and Sorenson video formats can't be remuxed into MP4 format; if you don't want re-encoding, you can try to remux them into MKV (Matroska); if you just want to fix the seek problems, you can just try FLV-to-FLV remuxing.

  • Method #1 (recommended): use ffmpeg (it's the main utility from the FFmpeg project).
    Install the "ffmpeg" package:
    # apt-get install ffmpeg
    Convert a FLV file to MP4, preserving audio & video:
    $ ffmpeg -i input.flv -codec copy output.mp4
    And even optimizing it for faster loading:
    $ ffmpeg -i input.flv -codec copy -movflags faststart output_optim.mp4
    To extract audio only:
    $ ffmpeg -i input.flv -codec copy -vn output_a.mp4
    To extract video only:
    $ ffmpeg -i input.flv -codec copy -an output_v.mp4
    Note: you can also use M4A (audio) / M4V (video) file extensions for output, if you like those Apple formats.
  • Method #2 (alternative): using avconv (it's a part of Libav project, a fork of FFmpeg).
    Install the "libav-tools" package:
    # apt-get install libav-tools
    Convert a FLV file to MP4, preserving audio & video:
    $ avconv -i input.flv -codec copy output.mp4
    To extract audio only:
    $ avconv -i input.flv -codec copy -vn output_a.mp4
    To extract video only:
    $ avconv -i input.flv -codec copy -an output_v.mp4
  • Method #3 (a somewhat ugly one): using MEncoder (a part of the MPlayer project).
    Install MEncoder:
    # apt-get install mencoder
    Convert a FLV file to MP4:
    $ mencoder input.flv -ovc copy -oac copy -of lavf -o output.mp4
    Note: according to the warning from MEncoder itself, output file can be corrupt:
    ** MUXER_LAVF *****************************************************************
    REMEMBER: MEncoder's libavformat muxing is presently broken and can generate
    INCORRECT files in the presence of B-frames. Moreover, due to bugs MPlayer
    will play these INCORRECT files as if nothing were wrong!
    *******************************************************************************
    So probably it suggests that you should better try the MEncoder's favorite AVI format:
    $ mencoder input.flv -ovc copy -oac copy -o output.avi
    (But that's not what we want here, right?)

Source software packages availability for Debian releases:
  • ffmpeg: up to Debian 6 "Squeeze", and then again from 9 "Stretch" (also in 8 "Jessie" backports);
  • libav: starting from 7 "Wheezy" (also in 6 "Squeeze" backports), up to 8 "Jessie";
  • mplayer: up to 7 "Wheezy", and then from 9 "Stretch".

And yes, it should work for Ubuntu too; any current FFmpeg version should also work in other GNU/Linux or *BSD distros, MS Windows, Apple Mac OS X etc.

References:
  1. ffmpeg Documentation
  2. Libav documentation : avconv
  3. 6.1. Selecting codecs and container formats - Chapter 6. Basic usage of MEncoder (MPlayer - The Movie Player documentation)
  4. Wikipedia:
    1. Flash Video
    2. MPEG-4 Part 14
    3. M4V
    4. H.264/MPEG-4 AVC
    5. Advanced Audio Coding
    6. Audio Video Interleave
---
Last updated: 2017-12-28