5

I have used the command

ffmpeg -i input.webm -q:v 10 -c:a copy out.mp4

I also tried using avconv instead of ffmpeg.

The conversion is successful but the quality is bad. Also it takes a lot of time. It also does not play with Windows Media Player. (The reason for this is the mpegv1 to which the file is converted.) How do I add an option to convert it to mpegv2?

Following is the command line output:

avconv version 0.8.16-4:0.8.16-0ubuntu0.12.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Sep 16 2014 18:33:49 with gcc 4.6.3 
[matroska,webm @ 0xe737a0] Estimating duration from bitrate, this may be inaccurate
Input #0, matroska,webm, from 'test.webm':
  Duration: 00:00:08.57, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: vp8, yuv420p, 1536x768, PAR 1:1 DAR 2:1, 1k fps, 1k tbr, 1k tbn, 1k tbc (default) 
    Stream #0.1: Audio: vorbis, 44100 Hz, stereo, s16 (default)
[buffer @ 0xee38e0] w:1536 h:768 pixfmt:yuv420p
Output #0, mp4, to 'c2.mp4':
  Metadata:
    encoder         : Lavf53.21.1
    Stream #0.0: Video: mpeg4, yuv420p, 1536x768 [PAR 1:1 DAR 2:1], q=2-31, 200 kb/s, 1k tbn, 1k tbc (default)
    Stream #0.1: Audio: libvorbis, 44100 Hz, stereo (default)
Stream mapping:
  Stream #0:0 -> #0:0 (vp8 -> mpeg4)
  Stream #0:1 -> #0:1 (copy)
Press ctrl-c to stop encoding
frame= 8572 fps=342 q=10.0 Lsize=   90902kB time=8.56 bitrate=86984.0kbits/s dup=8438 drop=0    
video:90823kB audio:0kB global headers:0kB muxing overhead 0.086778%
slhck
  • 235,242
dfordevy
  • 147

3 Answers3

8

Several problems here:

  • You are using an old version of avconv from the Ubuntu 12.04 repos.
  • This version does not have an H.264 encoder (libx264) compiled into it.
  • That's why it chooses MPEG-4 Part II video instead, using the mpeg4 encoder. While it still uses the same .MP4 container, MPEG-4 Part II is not as efficient as H.264.
  • Your command uses -q:v 10, which is quite low quality. The range is from 1–31, where 1 is the best, and ideally you want something around 2–5.
  • You cannot copy Vorbis audio to MP4 containers, so -c:a copy will not work.

So, to fix this, I'd recommend one of two options:

  1. Keep using avconv. Install apt-get install libavcodec-extra-53 on Ubuntu 12.04 and libavcodec-extra-54 on Ubuntu 14.04 to get x264 support for avconv.
  2. Use a recent ffmpeg instead. Download a recent ffmpeg build (click on the Linux Static Builds link). Extract the ffmpeg binary somewhere and use this.

Then run the following command (and replace ffmpeg with avconv depending on what your choice is):

ffmpeg -i input.webm -c:v libx264 -crf 20 -c:a aac -strict experimental out.mp4

The CRF controls the quality, where 18–28 are sensible choices. Lower is better, and 23 is default. You may set the audio bitrate with -b:a 128k or similar to your liking.

If you want to speed up the conversion you can use -preset and set it to one of ultrafast, superfast, veryfast, faster, fast, e.g. -preset fast. Note that setting this will increase your file size.

The H.264 encoding guide for ffmpeg is pretty helpful and should also apply to avconv (but no guarantees on that).

As for MPEG-2, have a look at this question: How to make an MPEG2 video file with the highest quality possible using FFMPEG? — and don't forget to choose -c:a libmp3lame as audio instead.

slhck
  • 235,242
7

ffmpeg version 1.2.6-7:1.2.6-1~trusty1

ffmpeg -i one.webm -r 10 -cpu-used 5 -c:v libx264 -crf 20 -c:a aac -strict experimental -loglevel error /tmp/one.mp4

This works very well. Converted 1 hour video in 10 minutes.

dfordevy
  • 147
-2

Try ffmpeg -i input.webm -sameq out.mp4

As alternatives, you can try FFMC: http://www.noobslab.com/2013/04/latest-ff-multi-converter-for-ubuntu.html or pre-compiled Miro: http://www.getmiro.com/download/for-ubuntu/

Overmind
  • 10,308