2

I have several m4v files, which I need to convert to webm.

I am using ffmpeg for doing so and have used commands such as:

ffmpeg -i myfiletoconvert.m4v output.webm

The conversion works fine, and the resolution is still the same, however the quality is just not the same.

What I actually would like is that the conversion is lossless. I would like the properties of the input file to be the same for the output file, so that I do not have a noticeable quality change.

How would I accomplish that?

6
  • 3
    Welcome to Ask Ubuntu! Can you share a bit more about the codecs you're using? M4V and WebM are just containers. (where WebM requires specific codecs) Unless your M4V file consists of Vorbis audio and VP8 video this is impossible to do lossless.
    – gertvdijk
    Feb 9, 2013 at 12:29
  • 1
    You can run ffmpeg -i myfiletoconvert.m4v -c copy output.webm so that the codecs are copied from the input to the output file.
    – green
    Feb 9, 2013 at 12:37
  • have you tried any of the preset files available wit ffmpeg. e.g libvpx-720p.ffpreset also try to set the bitrate as close as possible to input bitrate.
    – rajneesh
    Feb 9, 2013 at 15:01
  • 1
    @green7 webm is designed for VP8 video and Vorbis audio. I don't know how well it will work with other arbitrary formats.
    – llogan
    Feb 11, 2013 at 23:45
  • @rajneesh Matching bitrates is not recommended. Not all encoders are equal (and not all formats are equal) in terms of bitrate requirements.
    – llogan
    Feb 11, 2013 at 23:45

2 Answers 2

4

I would like the properties of the input file to be the same for the output file, so that I do not have a noticeable quality change.

You're going from a lossy codec to another lossy codec. That means you will lose quality no matter what, unless you set the target bit rate so high that the quality loss won't be noticeable (even if it's still there).

The downside is, of course, that the file size will increase. How much, you ask, will it increase? No one can tell. It depends on how good the quality of your input video is, and how easy the video is to encode.

To force a bit rate during conversion, do the following, e.g. for constant 1 MBit/s:

ffmpeg -i in.m4v -c:v libvpx -b:v 1M -c:a libvorbis out.webm

The libvpx encoder can also work with variable quality, using the -qmin, -qmax options:

ffmpeg -i in.m4v -c:v libvpx -qmin 10 -qmax 42 -c:a libvorbis out.webm

Use lower values for both parameters to achieve better quality. Usually FFmpeg would set them to 2/31, but WebM needs a different scale here AFAIK.

1

As of version 1.3.0, Dec 2013, libvpx supports lossless encoding through VP9.

Example usage:

ffmpeg -i in.m4v -vcodec libvpx-vp9 -lossless 1 out.webm

One gotcha is that webm only supports opus and vorbis audio, which is not going to be lossless. However, opus quality is excellent even at modest bitrates, so if you absolutely need a webm, that's the way to go. Just crank the audio bitrate with -b:a 512k or to whatever level you like.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .