197

I have just installed ffmpeg and I am trying to encode all my uploaded videos to .mp4 file. Most of the users currently upload .mov and I want to convert every video to .mp4.

I am running the command as follows:

ffmpeg -i movie.mov -vcodec copy -acodec cop out.mp4

But all I am getting is the following errors

ffmpeg version 0.8.5, Copyright (c) 2000-2011 the FFmpeg developers
  built on Aug 19 2012 11:38:20 with clang 3.1 (tags/Apple/clang-318.0.61)
  configuration: --enable-nonfree --enable-gpl --enable-version3 --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libfaac --enable-libxvid --enable-libx264 --enable-libvpx --enable-hardcoded-tables --enable-shared --enable-pthreads --disable-indevs --cc=clang
  libavutil    51.  9. 1 / 51.  9. 1
  libavcodec   53.  7. 0 / 53.  7. 0
  libavformat  53.  4. 0 / 53.  4. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 23. 0 /  2. 23. 0
  libswscale    2.  0. 0 /  2.  0. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'movie.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2012-03-28 07:13:20
  Duration: 00:00:26.23, start: 0.000000, bitrate: 12974 kb/s
    Stream #0.0(eng): Video: mjpeg, yuvj420p, 1280x720 [PAR 72:72 DAR 16:9], 12972 kb/s, 11.67 fps, 600 tbr, 600 tbn, 600 tbc
    Metadata:
      creation_time   : 2012-03-28 07:13:20
File 'out.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'out.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2012-03-28 07:13:20
    encoder         : Lavf53.4.0
    Stream #0.0(eng): Video: mjpeg, yuvj420p, 1280x720 [PAR 72:72 DAR 16:9], q=2-31, 12972 kb/s, 600 tbn, 600 tbc
    Metadata:
      creation_time   : 2012-03-28 07:13:20
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop, [?] for help
frame=  121 fps=  0 q=-1.0 size=   16408kB time=00:00:10.08 bitrate=13332.2kbitsframe=  306 fps=  0 q=-1.0 Lsize=   41543kB time=00:00:26.12 bitrate=13025.0kbits/s    
video:41538kB audio:0kB global headers:0kB muxing overhead 0.012531%
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
user1503606
  • 3,872
  • 13
  • 44
  • 78
  • 1
    Are you sure these are errors? This looks more like a log file to me. It even asks to overwrite the previous mp4: **File 'out.mp4' already exists. Overwrite ? [y/N] y** – Conrad Lotz Aug 19 '12 at 12:42
  • [Similar question](https://superuser.com/q/1155186/50345) in SuperUser. – legends2k Aug 21 '19 at 07:42

1 Answers1

367

The command to just stream it to a new container (mp4) needed by some applications like Adobe Premiere Pro without encoding (fast) is:

ffmpeg -i input.mov -qscale 0 output.mp4

Alternative as mentioned in the comments, which re-encodes with best quaility (-qscale 0):

ffmpeg -i input.mov -q:v 0 output.mp4
Luca Fagioli
  • 12,722
  • 5
  • 59
  • 57
Conrad Lotz
  • 8,200
  • 3
  • 23
  • 27
  • 86
    Since this turns up in the search results, I'll add the updated command for the ffmpeg as of writing: `ffmpeg -i input.mov -qscale 0 output.mp4` – StudioEvoque Jun 22 '13 at 12:24
  • 19
    @StudioEvoque what does the `-qscale 0` flag do? – CyberSkull Aug 10 '13 at 12:33
  • 10
    @CyberSkull `-qscale` sets the compression level. The lower the qscale value, the bet­ter the qual­ity. The avail­able qscale val­ues range from 1 (high­est qual­ity) to 31 (low­est qual­ity). – RonnyKnoxville Sep 08 '15 at 15:02
  • 2
    Wouldn't that be equivalent to just renaming the file to .mp4? – Miguel Bartelsman Nov 30 '16 at 12:37
  • @MiguelBartelsman, Good question. I've searched around, and I think the answer is that `ffmpeg -i in.mov -c copy out.mp4` is an example of using ffmpeg to [change the "container"](http://askubuntu.com/a/742564/55827) from .mov to .mp4. I don't think that's the same as renaming the file, but I don't know enough to explain why. I also don't know why that would be "better," except to say that I don't think the process involves any change to the data, i.e. no re-encoding, therefore no quality loss. – Baodad Feb 26 '17 at 00:39
  • 10
    @MiguelBartelsman @Baodad a container packages multiple video and audio streams, adds a header and a table-of-contents. The Quicktime (mov) and MPEG (mp4) container work quite different, technically. If you just rename a Quicktime file into mp4, you pretend it to be a MPEG video, but it still remains a Quicktime container. Please note: since you use the `copy` for the codec parameter, you tell FFMpeg to copy the actual media data, without any re-coding into another codec. – Ichthyo Mar 12 '17 at 17:16
  • 18
    @StudioEvoque beware! What you are proposing here is something **quite different** than the OP did and probably wanted. You don't give a codec spec, thus you ask FFMpeg to **transcode** the actual media data into the standard codec for associated with the MP4-container. Even if you use the hightest quality settings, transcoding will always loose some quality. Only when you use `-c copy` you ensure that the original media data as such is not touched, only the container changed – Ichthyo Mar 12 '17 at 17:20
  • @Ichthyo Thanks for the insight, I find multimedia formats to be quite difficult to understand – Miguel Bartelsman Mar 13 '17 at 01:04
  • 4
    It prints `Please use -q:a or -q:v, -qscale is ambiguous` – mrgloom Nov 11 '18 at 22:46
  • @mrgloom Make sure you also put a number after the `-q:a` or `-q:v`. For example (using the other comments,) I came up with a command that works. **Note that I had to use** `-strict -2` **for it to work!** The command is: `ffmpeg -i movie.mov -q:v 0 -strict -2 cut.mp4` (I'm on [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), `$ uname -a` outputs `Linux CAP-D-ENG-INT3 4.4.0-17134-Microsoft #345-Microsoft Wed Sep 19 17:47:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux`.) – bballdave025 Nov 27 '18 at 00:39
  • 2
    As per [this Stack Overflow answer](https://stackoverflow.com/questions/14430593/encoding-a-readable-movie-by-quicktime-using-ffmpeg/14437323#14437323) I had to add `-pix_fmt yuv420p` for the output file to work with QuickTime Player. – Asbjørn Ulsberg Sep 01 '19 at 23:00
  • 2
    '-q:v 0' is identical to '-q:v 1' since qscale range is [1..31], where qscale=1 corresponds to maximal quality. Therefore qscale=0 is out of range and is modified to qscale=1. – Shevach Riabtsev Sep 29 '19 at 16:42
  • If the source audio is encoded as raw PCM audio (for example, for a video from a digital camera) you may want to encode the audio but keep the video lossless. You can do this with: `ffmpeg -i MVI_0887.MOV -vcodec copy -acodec aac ~/MVI_0887.mp4`. This keeps the original video the same (so is an entirely lossless copy) while encoding the audio in a new format that is available in the MP4 format. – ayke Sep 20 '20 at 11:20
  • In recent ffmpeg version, with the default libx264 encoder for .mp4, using `-q:v 1` as proposed leads to a message "-qscale is ignored, -crf is recommended". To solve replace by `-crf 17` for visually lossless output. – tanius Dec 10 '22 at 19:14