1

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

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.

  • What do we do to use it in Ubuntu 14.04? – dfordevy Feb 7 '15 at 13:18
  • You can do exactly the same thing in Ubuntu 14.04 but with libavcodec-extra-54. As for the file being "still MP4v1", you need to tell me what exactly you did and upload the full command line output somewhere (e.g. pastebin.com). – slhck Feb 7 '15 at 13:21
  • I have pasted the output of: avconv -i input.webm -c:v libx264 -crf 20 -c:a aac -strict experimental test_1min_no_preset.mp4 here: pastebin.com/SQdbvM0Y. when I do file test_1min_no_preset.mp4, test_1min_no_preset.mp4: ISO Media, MPEG v4 system, version 1 – dfordevy Feb 9 '15 at 5:27
  • I don't think avconv or ffmpeg can write mp42 tags. Why do you actually need it? Is MP4v1 not good enough? – slhck Feb 9 '15 at 7:30
  • Any tag is ok for me but I just need that to play them using Windows Media Player. – dfordevy Feb 9 '15 at 7:33
4

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.

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

  • it says unrecognised option sameq – dfordevy Feb 5 '15 at 9:39
  • also ffmulticonverter did not do the conversion – dfordevy Feb 5 '15 at 9:45
  • Do not use sameq: superuser.com/questions/478549/…. It does not mean same quality, and recent versions of ffmpeg do not even have this option anymore (for good reasons). – slhck Feb 5 '15 at 11:04
  • 1
    superuser.com/help/formatting – slhck Feb 5 '15 at 16:02
  • 1
    @Overmind Comments use restricted formatting. Click the Help link next to the commenting window. Don't forget you have to @-ping users for them to receive a notification. – slhck Feb 6 '15 at 9:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.