Showing posts with label video. Show all posts
Showing posts with label video. Show all posts

2017-12-28

HOWTO: grab online video stream with FFmpeg

Usually, it's quite easy to save some free online (live) video streams with FFmpeg.

Example: grabbing some HLS stream with MPEG-4 (H.264) video and AAC (or MP3) audio.
$ ffmpeg -i "http://some.streaming.server/favorite_stream.m3u8" -codec copy -f mpegts stream01.ts
(Generally, the output format can be guessed by extension automatically, so we can shorten the command line).
$ ffmpeg -i "http://some.streaming.server/favorite_stream.m3u8" -codec copy stream02.ts
The TS file is usually playable during download.
Usually, you can stop the grabbing operation at any time by pressing the <q> key.
After the stream dumping is finished, you can convert (remux) your video to a more familiar MP4 container format.
$ ffmpeg -i stream01.ts -codec copy stream01.mp4
(Usually, you'd prefer a playback-optimized output file).
$ ffmpeg -i stream02.ts -codec copy -movflags faststart stream02.mp4

Reference:

2017-12-25

HOWTO: optimize MP4 video for fast loading with FFmpeg

MP4 video loading can be accelerated (e. g., allowing playback of partially downloaded videos for end users) by moving the metadata (the "moov atom") to the beginning of the file. And that's a lossless procedure (no video, audio or subtitle data gets lost; may alter some metadata though)!
  1. Can be performed very fast and easily with the qt-faststart utility (targeted primarily at Apple QuickTime MOV files, but should work for most MP4 base media files too); you can find that utility in your favorite FFmpeg distribution.
    $ qt-faststart in01.mov out01.mov
    $ qt-faststart in02.mp4 out02.mp4
  2. More thorough (but a little bit slower) method involves the universal ffmpeg program to remux the original video:
    $ ffmpeg -i in10.mp4 -codec copy -movflags faststart out10.mp4
Reference:
---
Last updated: 2018-03-01

2017-02-28

Hardware test drive: old Fujitsu SCSI HDD

Old Fujitsu SCSI HDD spinning up & down...

2016-12-31

Digital camera notes: Sony MHS-CM5

Sony MHS-CM5 is a mobile HD camera.

Short specs:
video [MP4] resolution:
up to 1080p30 / 720p60 (1920x1080@30 fps, 1280x720@60 fps, 1280x720@30 fps etc.);
photo [JPG]:
up to 5 MP (max. 2592x1944).

Firmware notes.
  • Latest firmware version (known to me): "1.21".
  • How to check it: turn on the camera (open the LCD screen), and then quickly press and hold the "MENU" button; you'll see the FW version in the bottom right corner of the screen.
  • Firmare update file is usually named "SDV5591S.bin".
  • Quick firmware analysis suggests this Sony camera contains some hardware by Ambarella, which makes it somewhat related to GoPro.

Misc. notes. Sony PMB (Picture Motion Browser) software is abandoned. You can now use that partition of the camera's internal flash memory to store any other useful data ;)

External links:
---
Last updated: 2019-04-24

2015-11-30

Software: MediaInfo

Currently, MediaInfo is probably the best free & open-source utility for extracting technical info (metadata) from multimedia files (most frequently, containers with audio and video streams).
It's quite portable (runs on various Linux distributions, MS Windows, Apple Mac OS X, FreeBSD etc.; released regularly in source and compiled binary forms) and comes with CLI and GUI interfaces.

External links:

2015-09-30

HOWTO: get rid of packed B-frames in AVI (MPEG-4 Visual) video with FFmpeg

You've probably seen some AVI (Audio Video Interleave) files with MPEG-4 video (more specifically, MPEG-4 Visual / ASP, usually encoded by DivX or Xvid codecs) inside; they are often used for DVD-rips. Such AVI video files often contain "packed B-frames", which is not an optimal frame storage way, but just a workaround for the VfW (Video for Windows) framework shortcomings (i. e., bugs).
To ensure you have a "bad-style" MPEG-4 AVI file, you can check it with a media analyzer utility like MediaInfo (in this case, it'll show you something like "Muxing mode : Packed bitstream").
Fortunately, that wrong thing is easy to "unpack" with an up-to date version of FFmpeg (v2.7+):
$ ffmpeg -i in_bad.avi -codec copy -bsf:v mpeg4_unpack_bframes out_good.avi
The conversion is lossless (neither video nor audio quality is harmed; the file should remain compatible with the hardware players... or even become more compatible), but often can even reduce the resulting AVI container size.

BTW, after "bitstream unpacking", the MPEG-4 video stream becomes standards-compliant, so you can put it directly into the popular MP4 container without transcoding (but it requires the audio stream to be MP4-compatible too, e. g. MP3 is OK);
e. g., here are 2.5 3 remuxing examples using the same FFmpeg:
$ ffmpeg -i in10_good.avi -codec copy out10_good.mp4
$ ffmpeg -i in20_bad.avi -codec copy -bsf:v mpeg4_unpack_bframes out20_better.mp4
$ ffmpeg -i in20_bad.avi -codec copy -bsf:v mpeg4_unpack_bframes -movflags faststart out25_best.mp4

You can download the source code and binary builds of the current FFmpeg (for MS Windows, Apple Mac OS X and Linux) freely from the official site.
Usually, you will find a compatible version in the repositories of your favorite Linux distribution;
however, in Debian, it's available only starting from the release 9 "Stretch" (and fortunately, it's currently in the backports for 8 "Jessie" too; and for use in Ubuntu, you need release 15.10 "Wily Werewolf", at least):
# sudo apt-get install ffmpeg

References:
  1. FFmpeg
    1. FFmpeg Bitstream Filters Documentation
    2. Download FFmpeg
    3. FFmpeg Changelog
    4. #2913 (Bitstream filter to fix "invalid and inefficient vfw-avi packed B frames") – FFmpeg
  2. MediaInfo
  3. Debian Package Tracker - ffmpeg
  4. ffmpeg package : Ubuntu
  5. Wikipedia
    1. Ripping
    2. MPEG-4 Part 2
    3. DivX
    4. Xvid
    5. Audio Video Interleave
    6. Video for Windows
    7. Video compression picture types
    8. Inter frame
---
Last updated: 2017-12-28

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-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

2012-04-07

MultiMedia Players in Windows and Linux

For MS Windows, my favourite audio player is foobar2000 [official site / Wikipedia]
(I'm tired of Winamp [official site / Wikipedia], and especially of the Windows Media Player [Wikipedia]; some people may like something else, e. g. AIMP [official site / Wikipedia]).

---

For playing video, I use VLC media player [official site / Wikipedia], MPC-HC ("Media Player Classic - Home Cinema") [official site / Wikipedia] and (very rarely) MPlayer (incl. forks).

===

In GNU/Linux, there are 2 powerful media players I frequently use (mostly for playing video): VLC and mpv [official site / Wikipedia].
mpv is a popular fork of MPlayer [official site / Wikipedia] & mplayer2 (itself a fork of MPlayer; now abandoned); they say it has more features and more rapid development process than the original one.
Sometimes I used mplayer[2] with a (now abandoned) GUI called gnome-mplayer.
BTW, I neither like nor use GNOME Videos (formerly called Totem) [official site / Wikipedia].
And some users also like xine [official site / Wikipedia] and Kodi (formerly XBMC) [official site / Wikipedia].

---

There are some pretty console audio players: mpg123 (probably the best MP3 player around) [official site / Wikipedia], cmus ("C* Music Player") [official site / Wikipedia], moc ("music on console") [official site / Wikipedia], mp3blaster (now obsolete) etc., but I prefer mpv there :)

And now about GUI audio players. Some years ago I used XMMS ("X MultiMedia System") [official site / Wikipedia] (now discontinued) and Amarok [official site / Wikipedia] (it was too overweight for me). In the near past, I used Rhythmbox [official site / Wikipedia]; when Banshee [official site / Wikipedia] became the default player in Ubuntu, I was very disappointed (it was much more buggier than Rhythmbox and used that C# / Mono / .NET / etc. stuff); then I tried to use LXMusic (it uses XMMS2 [official site / Wikipedia] backend and has a minimalist GUI) for some time, used Exaile [official site / Wikipedia] a few times...
...and finally switched to Audacious [official site / Wikipedia]
(Audacious is a fork of (now defunct) Beep Media Player [official site / Wikipedia], which itself was a fork of XMMS; BTW, it supports Winamp skins; not to be confused with Audacity [official site / Wikipedia], a popular audio editor).

Some other popular players:
---
Last updated: 2016-12-11