I believe that this question is not the same as Lossless H.264 MP4 file created from images cannot be played in QuickTime because that question, and its answer, pertains to converting a series of PNG images. The accepted answer does not work in my case. It also suggests picking a non-zero value for crf whereas I want a 0 value.
I need to convert a bunch of MOV files to mp4 so I can import them into Apple Photos. I would like the conversion to be lossless.
I've tried the following command to convert a single file, with crf = 0 so that it is lossless:
ffmpeg -i in.mov -c:v libx264 -crf 0 -c:a aac -map_metadata 0 out.mp4
(in.mov is 400Mb, out.mp4 is about 600 Mb)
ffmpeg completes without issues but Quicktime cannot open the file (the file is incompatible with Quicktime Player), and Photos cannot import it. VLC can open it and playback without issue.
Setting crf to a value > 1 results in files that quicktime can open.
Any ideas?
Log from converting with crf 0
~/Documents/Movies/Originals/2011 ffmpeg -i clip-2011-11-19\ 15\;10\;42\ \(id\).mov -c:v libx264 -crf 0 -c:a aac -map_metadata 0 ~/Downloads/out.mp4 > ~/Downloads/log.txt
ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'clip-2011-11-19 15;10;42 (id).mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2011-11-20T18:19:29.000000Z
com.apple.proapps.originalFormat: AVCHD 720p25
com.apple.proapps.reel: NO NAME
com.apple.proapps.isGood: 0
com.apple.proapps.clipID: 000000000993d800e7c246220adc51964b39254c2e0e92c76a06b020d854bdb657d015d58964beeb a63c13f541815de16111047b0c330067ee9d8070d2c8fa22eeb097dd58e15461c1c0e7060096774eb9b636c79ce3e48
com.apple.quicktime.creationdate: 2011-11-19T15:10:42+0000
Duration: 00:01:27.36, start: 0.000000, bitrate: 37052 kb/s
Stream #0:0(eng): Video: aic (icod / 0x646F6369), yuv420p(bt709, progressive), 1280x720, 35481 kb/s, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 2500 tbn, 2500 tbc (default)
Metadata:
creation_time : 2011-11-20T18:19:29.000000Z
handler_name : Apple Video Media Handler
encoder : Apple Intermediate Codec
timecode : 00:00:00:00
Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default)
Metadata:
creation_time : 2011-11-20T18:19:29.000000Z
handler_name : Apple Sound Media Handler
Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
Metadata:
creation_time : 2011-11-20T18:19:29.000000Z
handler_name : Time Code Media Handler
timecode : 00:00:00:00
Stream mapping:
Stream #0:0 -> #0:0 (aic (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fef1b817600] using SAR=1/1
[libx264 @ 0x7fef1b817600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fef1b817600] profile High 4:4:4 Predictive, level 3.1, 4:2:0 8-bit
[libx264 @ 0x7fef1b817600] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=0 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=0 chroma_qp_offset=0 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=0
Output #0, mp4, to '/Users/channing/Downloads/out.mp4':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2011-11-20T18:19:29.000000Z
com.apple.proapps.originalFormat: AVCHD 720p25
com.apple.proapps.reel: NO NAME
com.apple.proapps.isGood: 0
com.apple.proapps.clipID: 000000000993d800e7c246220adc51964b39254c2e0e92c76a06b020d854bdb657d015d58964beeb a63c13f541815de16111047b0c330067ee9d8070d2c8fa22eeb097dd58e15461c1c0e7060096774eb9b636c79ce3e48
com.apple.quicktime.creationdate: 2011-11-19T15:10:42+0000
encoder : Lavf58.20.100
Stream #0:0(eng): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 0.04 fps, 12800 tbn, 25 tbc (default)
Metadata:
creation_time : 2011-11-20T18:19:29.000000Z
handler_name : Apple Video Media Handler
timecode : 00:00:00:00
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2011-11-20T18:19:29.000000Z
handler_name : Apple Sound Media Handler
encoder : Lavc58.35.100 aac
frame= 2184 fps= 53 q=-1.0 Lsize= 831156kB time=00:01:27.36 bitrate=77939.9kbits/s speed=2.13x
video:829737kB audio:1368kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.005997%
[libx264 @ 0x7fef1b817600] frame I:9 Avg QP: 0.00 size:426350
[libx264 @ 0x7fef1b817600] frame P:2175 Avg QP: 0.00 size:388880
[libx264 @ 0x7fef1b817600] mb I I16..4: 34.2% 0.0% 65.8%
[libx264 @ 0x7fef1b817600] mb P I16..4: 24.7% 0.0% 27.5% P16..4: 21.2% 13.8% 12.5% 0.0% 0.0% skip: 0.3%
[libx264 @ 0x7fef1b817600] 8x8 transform intra:0.0% inter:75.2%
[libx264 @ 0x7fef1b817600] coded y,uvDC,uvAC intra: 99.4% 99.7% 99.7% inter: 94.3% 95.2% 95.1%
[libx264 @ 0x7fef1b817600] i16 v,h,dc,p: 54% 46% 0% 0%
[libx264 @ 0x7fef1b817600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 43% 46% 3% 1% 2% 2% 2% 1% 1%
[libx264 @ 0x7fef1b817600] i8c dc,h,v,p: 0% 49% 50% 0%
[libx264 @ 0x7fef1b817600] Weighted P-Frames: Y:0.2% UV:0.1%
[libx264 @ 0x7fef1b817600] ref P L0: 75.0% 16.1% 6.5% 2.4% 0.0%
[libx264 @ 0x7fef1b817600] kb/s:77806.84
[aac @ 0x7fef1b808000] Qavg: 419.244