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

The Simpsons: Cisco

HOWTO: make MS VS 2005 work with WPF etc.

WPF ("Windows Presentation Fundation", just another MS Windows GUI API from .NET 3.0 "WinFX", this time XML-based) is fully supported in Microsoft Visual Studio 2008 and newer.
If you use VS 2005, you'll not find an option to create a WPF project from the New Project dialog (WPF was released as part of .NET Framework 3.0, while VS 2005 is for .NET 2.0).

Here are the required steps to get an ability to build WPF projects with VS 2005.
  1. Download .NET Framework 3.5 SP1 (if you don't have an up-to-date .NET 3.x version installed yet).
  2. Download a small add-on for VS 2005:
    Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP
    Mirror: CNET | Download.com
    Note: MS has released that package as a CTP ("Community Technology Preview", MS' term for some kind of beta / preview SW releases); it's unsupported, so upgrade to VS 2008 or later is recommended.
  3. Install the downloaded MSI package.
    If the installer exits with an error (regarding the bad / already installed / newer .NET version), you should start it manually (i. e., from MS Windows Command Prompt, you know: <Win>+<R>, cmd, <Enter>) with a specific option:
    > cd P:\ath\To\Installer\Folder
    > msiexec /i vsextwfx.msi WRC_INSTALLED_OVERRIDE=1
    It allows to ignore that error and continue the installation process.
  4. After that, a new option titled Windows Application (WPF) should appear as part of (new!) .NET Framework 3.0 subcategory for C# language in the New Project dialog of the Studio.
    Enjoy!

See also:
  1. Visual Studio 2005 extensions for .NET Framework 3.0 (WF)
  2. Wikipedia: WCF / WPF / WF | .NET Framework