[avconv] Convert WMV to MP4

I just came across a great tool for converting .wmv files to .mp4 and various other formats. I needed to perform this this conversion because either my Panasonic DLNA equipped TV could not playback .wmv files or was it the fault of my QNAP DLNA server? However, .mp4 encoded files play without issue. In the past the tool of choice was ffmpeg, but it is now deprecated and it is suggested to use avconv not and in the near future:

`--> ffmpeg
ffmpeg version 0.8.4-6:0.8.4-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Nov  6 2012 16:51:11 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.

To check the available codecs on your system, the ‘-codecs’ option to avconv displays all supported codecs and whether it is possible to encode, decode and perform various other tasks as the legend shows. To the left of codec are the supported functions. For example:

`--> avconv -codecs | head -10 && avconv -loglevel quiet -codecs | egrep "(wmv)"
avconv version 0.8.4-6:0.8.4-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Nov  6 2012 16:51:11 with gcc 4.7.2
Codecs:
 D..... = Decoding supported
 .E.... = Encoding supported
 ..V... = Video codec
 ..A... = Audio codec
 ..S... = Subtitle codec
 ...S.. = Supports draw_horiz_band
 ....D. = Supports direct rendering method 1
 .....T = Supports weird frame truncation
 ------
 DEVSD  wmv1            Windows Media Video 7
 DEVSD  wmv2            Windows Media Video 8
 D V D  wmv3            Windows Media Video 9
 D V D  wmv3_vdpau      Windows Media Video 9 VDPAU
 D V D  wmv3image       Windows Media Video 9 Image

To convert our sample file: 1-25_681_webinar_2.wmv, 44MB in size, with the following characteristics:

`--> du -sh 1-25_681_webinar_2.wmv
44M     1-25_681_webinar_2.wmv

`--> avconv -i 1-25_681_webinar_2.wmv
avconv version 0.8.4-6:0.8.4-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Nov  6 2012 16:51:11 with gcc 4.7.2
[wmv3 @ 0xa50be0] Extra data: 8 bits left, value: 0
Input #0, asf, from '1-25_681_webinar_2.wmv':
  Metadata:
    title           : 1-25 681 webinar 2
    WMFSDKVersion   : 11.0.5721.5251
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 1
    VBR Peak        : 295
    Buffer Average  : 772
  Duration: 01:02:38.47, start: 0.000000, bitrate: 96 kb/s
    Stream #0.0(eng): Audio: wmav2, 44100 Hz, 1 channels, s16, 48 kb/s
    Stream #0.1(eng): Video: wmv3 (Main), yuv420p, 640x416, 37 kb/s, 15 tbr, 1k tbn, 1k tbc
At least one output file must be specified

to .mp4 we perform:

`--> sudo avconv -i 1-25_681_webinar_2.wmv -strict experimental 1-25_681_webinar_2.mp4

where the .wmv input file (-i) is encoded into .mp4 using the experimental ‘aac’ encoder (-stric experimental):

avconv version 0.8.4-6:0.8.4-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Nov  6 2012 16:51:11 with gcc 4.7.2
[wmv3 @ 0x1bd6be0] Extra data: 8 bits left, value: 0
Input #0, asf, from '1-25_681_webinar_2.wmv':
  Metadata:
    title           : 1-25 681 webinar 2
    WMFSDKVersion   : 11.0.5721.5251
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 1
    VBR Peak        : 295
    Buffer Average  : 772
  Duration: 01:02:38.47, start: 0.000000, bitrate: 96 kb/s
    Stream #0.0(eng): Audio: wmav2, 44100 Hz, 1 channels, s16, 48 kb/s
    Stream #0.1(eng): Video: wmv3 (Main), yuv420p, 640x416, 37 kb/s, 15 tbr, 1k tbn, 1k tbc
File '1-25_681_webinar_2.mp4' already exists. Overwrite ? [y/N] y
[buffer @ 0x1bd8860] w:640 h:416 pixfmt:yuv420p
[wmv3 @ 0x1bd6be0] Extra data: 8 bits left, value: 0
Output #0, mp4, to '1-25_681_webinar_2.mp4':
  Metadata:
    title           : 1-25 681 webinar 2
    WMFSDKVersion   : 11.0.5721.5251
    WMFSDKNeeded    : 0.0.0.0000
    IsVBR           : 1
    VBR Peak        : 295
    Buffer Average  : 772
    encoder         : Lavf53.21.0
    Stream #0.0(eng): Video: mpeg4, yuv420p, 640x416, q=2-31, 200 kb/s, 15 tbn, 15 tbc
    Stream #0.1(eng): Audio: aac, 44100 Hz, 1 channels, s16, 200 kb/s
Stream mapping:
  Stream #0:1 -> #0:0 (wmv3 -> mpeg4)
  Stream #0:0 -> #0:1 (wmav2 -> aac)
Press ctrl-c to stop encoding
frame=56377 fps=131 q=27.9 Lsize=  163756kB time=3758.47 bitrate= 356.9kbits/s
video:92153kB audio:69879kB global headers:0kB muxing overhead 1.064378%
178.31s user 8.23s system 43% cpu 7:12.13s total

I was surprised to see the resulting .mp4 was more than twice (160M) as large of the original!

`--> du -sh 1-25_681_webinar_2.*
160M    1-25_681_webinar_2.mp4
44M     1-25_681_webinar_2.wmv

Update: An anonymous commenter felt my pain and suggested I could have reduced the file size further by including the option “-tune film”. As of today and with the current version of avconv using ‘-tune film’ is no longer necessary. The resulting file size is smaller than in my initial post with this version of avconv:

avconv -version
avconv version 9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Aug 10 2014 18:16:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
avconv 9.16-6:9.16-0ubuntu0.14.04.1
libavutil 52. 3. 0 / 52. 3. 0
libavcodec 54. 35. 0 / 54. 35. 0
libavformat 54. 20. 4 / 54. 20. 4
libavdevice 53. 2. 0 / 53. 2. 0
libavfilter 3. 3. 0 / 3. 3. 0
libavresample 1. 0. 1 / 1. 0. 1
libswscale 2. 1. 1 / 2. 1. 1
[/sourcecode]

Here are the file sizes of the same file with and then without the use of ‘-tune film’ (which by the way is not in the man page, but accepted as a valid argument):

With option “-tune film”

avconv -i 1-25_681_webinar_2.wmv -strict experimental -tune film 1-25_681_webinar_2.mp4

...output truncated...
[libx264 @ 0x7d6080] ref B L1: 94.5%  5.5%
[libx264 @ 0x7d6080] kb/s:40.87
504.36s user 6.57s system 331% cpu 2:34.02s total

File sizes after conversion with “-tune film”

du -h 1-25_681_webinar_2.*
83M     1-25_681_webinar_2.mp4
44M     1-25_681_webinar_2.wmv
\rm -f 1-25_681_webinar_2.mp4

WITHOUT option “-tune film”

avconv -i 1-25_681_webinar_2.wmv -strict experimental 1-25_681_webinar_2.mp4
..output truncated...
[libx264 @ 0x15b1fa0] kb/s:39.45
505.83s user 7.31s system 329% cpu 2:35.65s total

File sizes after conversion WITHOUT “-tune film”

du -h 1-25_681_webinar_2.*
83M     1-25_681_webinar_2.mp4
44M     1-25_681_webinar_2.wmv

Thanks to the anonymous commenter and those working on avconv.

Advertisements
This entry was posted in *Nix and tagged , , , , . Bookmark the permalink.

4 Responses to [avconv] Convert WMV to MP4

  1. Anonymous says:

    Hi

    For reduce movie file size i used “-tune film” parameters like this:

    avconv -i /home/egomes/input/Transformers.wmv -strict experimental -tune film /home/egomes/output/Transformers.1080.out.mp4

    I hope help you

  2. Kevin Spring says:

    ffmpeg is not depreciated, avconv and ffmpeg are separate tools

    • swinful says:

      Hi Kevin,

      Thank you for your comment. See the output at the beginning of the post. At the time of this post the version of Ubuntu used marked ffmpeg as deprecated. And, in the current version of Ubuntu ‘ffmpeg’ is not provided. However, it can still be installed manually via source.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s