0

I have a long video file that I want to trim, resize, and compress with H264:

ffmpeg -y -ss 1.2 -to 2:03.800 -i long.MTS -vcodec libx264 -vf scale=320:-1 -vb 500k short.mp4

The file plays in VLC and not in QuickTime with this error:

The document could not be opened. An unknown error occurred (-50).

The same thing happens with the .mov container. The problem is that basic users are unable to see the compressed movie, and the original movie is too heavy to share.

The version of ffmpeg is 4.3.1, the version of macOS is 10.14.6, both up to date. ffprobe on the .mov file returns:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'short.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.45.100
  Duration: 00:02:02.92, start: 0.000000, bitrate: 902 kb/s
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 320x180 [SAR 1:1 DAR 16:9], 501 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.91.100 libx264
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1(side), fltp, 394 kb/s (default)
    Metadata:
      handler_name    : SoundHandler

How can I compress, scale, and trim a video from MTS?

Update: Here is the new command and the log:

$ ffmpeg -y -ac 2 -ss 1.5 -to 2:07.500 -i /Volumes/NO\ NAME/PRIVATE/AVCHD/BDMV/STREAM/00147.MTS -vcodec libx264 -vf scale=540:-1 -vb 500k ~/Downloads/message.mp4
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --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-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mpegts, from '/Volumes/NO NAME/PRIVATE/AVCHD/BDMV/STREAM/00147.MTS':
  Duration: 00:02:10.11, start: 0.374400, bitrate: 5368 kb/s
  Program 1 
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (ac3 (native) -> aac (native))
Press [q] to stop, [?] for help
[aac @ 0x7f81d7000800] Using a PCE to encode channel layout "5.1(side)"
[libx264 @ 0x7f81d7820400] using SAR=1216/1215
[libx264 @ 0x7f81d7820400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f81d7820400] profile High, level 2.1, 4:2:0, 8-bit
[libx264 @ 0x7f81d7820400] 264 - core 160 r3011 cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/Users/mmorin/Downloads/message.mp4':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 540x304 [SAR 1216:1215 DAR 16:9], q=-1--1, 500 kb/s, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.91.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/500000 buffer size: 0 vbv_delay: N/A
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1(side), fltp, 394 kb/s
    Metadata:
      encoder         : Lavc58.91.100 aac

frame=   30 fps=0.0 q=0.0 size=       0kB time=00:00:00.81 bitrate=   0.5kbits/s
frame=   62 fps= 61 q=25.0 size=       0kB time=00:00:02.09 bitrate=   0.2kbits/
frame=   91 fps= 60 q=24.0 size=       0kB time=00:00:03.30 bitrate=   0.1kbits/
frame=  117 fps= 58 q=23.0 size=     256kB time=00:00:04.30 bitrate= 486.7kbits/
frame=  145 fps= 57 q=22.0 size=     256kB time=00:00:05.39 bitrate= 388.6kbits/
frame=  170 fps= 56 q=23.0 size=     512kB time=00:00:06.42 bitrate= 653.2kbits/
frame=  197 fps= 56 q=23.0 size=     512kB time=00:00:07.53 bitrate= 557.0kbits/
frame=  223 fps= 55 q=23.0 size=     512kB time=00:00:08.59 bitrate= 487.9kbits/
frame=  251 fps= 55 q=22.0 size=     768kB time=00:00:09.64 bitrate= 652.5kbits/
frame=  276 fps= 55 q=23.0 size=     768kB time=00:00:10.64 bitrate= 591.0kbits/
frame=  304 fps= 55 q=22.0 size=    1024kB time=00:00:11.79 bitrate= 711.1kbits/
frame=  330 fps= 55 q=23.0 size=    1024kB time=00:00:12.82 bitrate= 654.3kbits/
frame=  352 fps= 54 q=23.0 size=    1280kB time=00:00:13.67 bitrate= 766.8kbits/
frame=  379 fps= 54 q=23.0 size=    1280kB time=00:00:14.82 bitrate= 707.2kbits/
frame=  403 fps= 53 q=23.0 size=    1280kB time=00:00:15.72 bitrate= 666.9kbits/
frame=  430 fps= 53 q=23.0 size=    1536kB time=00:00:16.81 bitrate= 748.5kbits/
frame=  451 fps= 53 q=22.0 size=    1536kB time=00:00:17.64 bitrate= 713.2kbits/
frame=  473 fps= 52 q=22.0 size=    1792kB time=00:00:18.53 bitrate= 791.9kbits/
frame=  499 fps= 52 q=22.0 size=    1792kB time=00:00:19.62 bitrate= 748.0kbits/
frame=  527 fps= 52 q=23.0 size=    2048kB time=00:00:20.69 bitrate= 810.8kbits/
frame=  556 fps= 52 q=22.0 size=    2048kB time=00:00:21.84 bitrate= 768.0kbits/
frame=  583 fps= 52 q=23.0 size=    2304kB time=00:00:22.93 bitrate= 823.0kbits/
frame=  612 fps= 53 q=23.0 size=    2304kB time=00:00:24.08 bitrate= 783.7kbits/
frame=  640 fps= 53 q=22.0 size=    2304kB time=00:00:25.19 bitrate= 749.2kbits/
frame=  667 fps= 53 q=22.0 size=    2560kB time=00:00:26.28 bitrate= 797.9kbits/
frame=  691 fps= 53 q=22.0 size=    2560kB time=00:00:27.30 bitrate= 768.0kbits/
frame=  719 fps= 53 q=22.0 size=    2816kB time=00:00:28.37 bitrate= 813.1kbits/
frame=  739 fps= 52 q=23.0 size=    2816kB time=00:00:29.22 bitrate= 789.3kbits/
frame=  765 fps= 52 q=23.0 size=    3072kB time=00:00:30.25 bitrate= 831.9kbits/
frame=  794 fps= 52 q=23.0 size=    3072kB time=00:00:31.38 bitrate= 801.9kbits/
frame=  823 fps= 53 q=23.0 size=    3328kB time=00:00:32.59 bitrate= 836.4kbits/
frame=  850 fps= 53 q=23.0 size=    3328kB time=00:00:33.64 bitrate= 810.4kbits/
frame=  872 fps= 52 q=22.0 size=    3328kB time=00:00:34.51 bitrate= 789.8kbits/
frame=  887 fps= 52 q=22.0 size=    3584kB time=00:00:35.09 bitrate= 836.6kbits/
frame=  910 fps= 52 q=22.0 size=    3584kB time=00:00:36.01 bitrate= 815.3kbits/
frame=  936 fps= 52 q=22.0 size=    3840kB time=00:00:37.03 bitrate= 849.4kbits/
frame=  965 fps= 52 q=22.0 size=    3840kB time=00:00:38.18 bitrate= 823.8kbits/
frame=  994 fps= 52 q=22.0 size=    4096kB time=00:00:39.38 bitrate= 852.0kbits/
frame= 1024 fps= 52 q=22.0 size=    4096kB time=00:00:40.55 bitrate= 827.4kbits/
frame= 1041 fps= 51 q=22.0 size=    4096kB time=00:00:41.23 bitrate= 813.7kbits/
frame= 1063 fps= 51 q=22.0 size=    4352kB time=00:00:42.15 bitrate= 845.7kbits/
frame= 1092 fps= 51 q=22.0 size=    4352kB time=00:00:43.28 bitrate= 823.7kbits/
frame= 1118 fps= 51 q=22.0 size=    4608kB time=00:00:44.33 bitrate= 851.5kbits/
frame= 1143 fps= 51 q=22.0 size=    4608kB time=00:00:45.33 bitrate= 832.7kbits/
frame= 1165 fps= 51 q=22.0 size=    4608kB time=00:00:46.18 bitrate= 817.3kbits/
frame= 1192 fps= 51 q=23.0 size=    4864kB time=00:00:47.27 bitrate= 842.9kbits/
frame= 1221 fps= 51 q=22.0 size=    4864kB time=00:00:48.46 bitrate= 822.1kbits/
frame= 1248 fps= 51 q=22.0 size=    5120kB time=00:00:49.51 bitrate= 847.1kbits/
frame= 1274 fps= 51 q=22.0 size=    5120kB time=00:00:50.58 bitrate= 829.2kbits/
frame= 1303 fps= 51 q=22.0 size=    5376kB time=00:00:51.73 bitrate= 851.3kbits/
frame= 1330 fps= 52 q=22.0 size=    5376kB time=00:00:52.82 bitrate= 833.8kbits/
frame= 1357 fps= 52 q=22.0 size=    5632kB time=00:00:53.93 bitrate= 855.5kbits/
frame= 1386 fps= 52 q=22.0 size=    5632kB time=00:00:55.06 bitrate= 837.9kbits/
frame= 1416 fps= 52 q=22.0 size=    5888kB time=00:00:56.23 bitrate= 857.7kbits/
frame= 1446 fps= 52 q=22.0 size=    5888kB time=00:00:57.45 bitrate= 839.6kbits/
frame= 1475 fps= 52 q=22.0 size=    6144kB time=00:00:58.60 bitrate= 858.9kbits/
frame= 1504 fps= 52 q=22.0 size=    6144kB time=00:00:59.75 bitrate= 842.3kbits/
frame= 1532 fps= 52 q=22.0 size=    6400kB time=00:01:00.90 bitrate= 860.8kbits/
frame= 1562 fps= 52 q=22.0 size=    6400kB time=00:01:02.10 bitrate= 844.3kbits/
frame= 1591 fps= 52 q=22.0 size=    6656kB time=00:01:03.25 bitrate= 862.0kbits/
frame= 1617 fps= 52 q=19.0 size=    6656kB time=00:01:04.27 bitrate= 848.3kbits/
frame= 1645 fps= 52 q=22.0 size=    6912kB time=00:01:05.42 bitrate= 865.4kbits/
frame= 1672 fps= 52 q=22.0 size=    6912kB time=00:01:06.47 bitrate= 851.8kbits/
frame= 1701 fps= 52 q=22.0 size=    7168kB time=00:01:07.62 bitrate= 868.3kbits/
frame= 1729 fps= 52 q=22.0 size=    7168kB time=00:01:08.77 bitrate= 853.8kbits/
frame= 1758 fps= 52 q=22.0 size=    7424kB time=00:01:09.93 bitrate= 869.7kbits/
frame= 1785 fps= 52 q=22.0 size=    7424kB time=00:01:10.99 bitrate= 856.6kbits/
frame= 1813 fps= 53 q=22.0 size=    7680kB time=00:01:12.14 bitrate= 872.0kbits/
frame= 1841 fps= 53 q=22.0 size=    7680kB time=00:01:13.30 bitrate= 858.3kbits/
frame= 1870 fps= 53 q=22.0 size=    7936kB time=00:01:14.41 bitrate= 873.7kbits/
frame= 1898 fps= 53 q=22.0 size=    7936kB time=00:01:15.54 bitrate= 860.6kbits/
frame= 1925 fps= 53 q=22.0 size=    7936kB time=00:01:16.65 bitrate= 848.2kbits/
frame= 1953 fps= 53 q=22.0 size=    8192kB time=00:01:17.78 bitrate= 862.8kbits/
frame= 1980 fps= 53 q=22.0 size=    8192kB time=00:01:18.80 bitrate= 851.6kbits/
frame= 2008 fps= 53 q=22.0 size=    8448kB time=00:01:19.91 bitrate= 866.0kbits/
frame= 2036 fps= 53 q=22.0 size=    8448kB time=00:01:21.06 bitrate= 853.7kbits/
frame= 2062 fps= 53 q=22.0 size=    8704kB time=00:01:22.09 bitrate= 868.6kbits/
frame= 2089 fps= 53 q=22.0 size=    8704kB time=00:01:23.17 bitrate= 857.2kbits/
frame= 2117 fps= 53 q=22.0 size=    8960kB time=00:01:24.30 bitrate= 870.6kbits/
frame= 2144 fps= 53 q=22.0 size=    8960kB time=00:01:25.39 bitrate= 859.5kbits/
frame= 2172 fps= 53 q=22.0 size=    9216kB time=00:01:26.48 bitrate= 873.0kbits/
frame= 2198 fps= 53 q=22.0 size=    9216kB time=00:01:27.53 bitrate= 862.5kbits/
frame= 2225 fps= 53 q=22.0 size=    9472kB time=00:01:28.61 bitrate= 875.6kbits/
frame= 2252 fps= 53 q=22.0 size=    9472kB time=00:01:29.70 bitrate= 865.0kbits/
frame= 2278 fps= 53 q=22.0 size=    9472kB time=00:01:30.73 bitrate= 855.2kbits/
frame= 2296 fps= 53 q=22.0 size=    9728kB time=00:01:31.49 bitrate= 871.0kbits/
frame= 2324 fps= 53 q=22.0 size=    9728kB time=00:01:32.58 bitrate= 860.7kbits/
frame= 2349 fps= 53 q=22.0 size=    9984kB time=00:01:33.58 bitrate= 873.9kbits/
frame= 2374 fps= 53 q=22.0 size=    9984kB time=00:01:34.57 bitrate= 864.8kbits/
frame= 2400 fps= 53 q=23.0 size=   10240kB time=00:01:35.59 bitrate= 877.5kbits/
frame= 2425 fps= 53 q=23.0 size=   10240kB time=00:01:36.61 bitrate= 868.2kbits/
frame= 2450 fps= 53 q=23.0 size=   10496kB time=00:01:37.62 bitrate= 880.8kbits/
frame= 2475 fps= 53 q=23.0 size=   10496kB time=00:01:38.60 bitrate= 872.0kbits/
frame= 2501 fps= 53 q=23.0 size=   10496kB time=00:01:39.66 bitrate= 862.7kbits/
frame= 2528 fps= 53 q=23.0 size=   10752kB time=00:01:40.75 bitrate= 874.2kbits/
frame= 2553 fps= 52 q=23.0 size=   10752kB time=00:01:41.73 bitrate= 865.8kbits/
frame= 2581 fps= 53 q=23.0 size=   11008kB time=00:01:42.82 bitrate= 877.0kbits/
frame= 2607 fps= 53 q=23.0 size=   11008kB time=00:01:43.89 bitrate= 868.0kbits/
frame= 2630 fps= 52 q=23.0 size=   11264kB time=00:01:44.81 bitrate= 880.4kbits/
frame= 2655 fps= 52 q=23.0 size=   11264kB time=00:01:45.81 bitrate= 872.1kbits/
frame= 2681 fps= 52 q=23.0 size=   11264kB time=00:01:46.83 bitrate= 863.7kbits/
frame= 2707 fps= 52 q=23.0 size=   11520kB time=00:01:47.88 bitrate= 874.8kbits/
frame= 2733 fps= 52 q=23.0 size=   11520kB time=00:01:48.94 bitrate= 866.2kbits/
frame= 2755 fps= 52 q=23.0 size=   11776kB time=00:01:49.80 bitrate= 878.6kbits/
frame= 2781 fps= 52 q=23.0 size=   11776kB time=00:01:50.82 bitrate= 870.5kbits/
frame= 2807 fps= 52 q=23.0 size=   12032kB time=00:01:51.89 bitrate= 880.9kbits/
frame= 2835 fps= 52 q=23.0 size=   12032kB time=00:01:53.00 bitrate= 872.2kbits/
frame= 2862 fps= 52 q=23.0 size=   12288kB time=00:01:54.09 bitrate= 882.3kbits/
frame= 2889 fps= 52 q=23.0 size=   12288kB time=00:01:55.15 bitrate= 874.1kbits/
frame= 2916 fps= 52 q=23.0 size=   12544kB time=00:01:56.30 bitrate= 883.5kbits/
frame= 2943 fps= 52 q=23.0 size=   12544kB time=00:01:57.33 bitrate= 875.8kbits/
frame= 2969 fps= 52 q=23.0 size=   12800kB time=00:01:58.37 bitrate= 885.8kbits/
frame= 2995 fps= 52 q=23.0 size=   12800kB time=00:01:59.40 bitrate= 878.2kbits/
frame= 3023 fps= 52 q=23.0 size=   13056kB time=00:02:00.53 bitrate= 887.3kbits/
frame= 3052 fps= 52 q=23.0 size=   13056kB time=00:02:01.68 bitrate= 878.9kbits/
frame= 3081 fps= 52 q=23.0 size=   13056kB time=00:02:02.83 bitrate= 870.7kbits/
frame= 3109 fps= 52 q=23.0 size=   13312kB time=00:02:03.98 bitrate= 879.5kbits/
frame= 3133 fps= 52 q=23.0 size=   13312kB time=00:02:04.97 bitrate= 872.6kbits/
frame= 3151 fps= 52 q=-1.0 Lsize=   13918kB time=00:02:06.01 bitrate= 904.8kbits/s dup=1 drop=0 speed=2.08x    
video:7750kB audio:6073kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.688174%
[libx264 @ 0x7f81d7820400] frame I:19    Avg QP:14.14  size: 10147
[libx264 @ 0x7f81d7820400] frame P:804   Avg QP:16.08  size:  4710
[libx264 @ 0x7f81d7820400] frame B:2328  Avg QP:18.47  size:  1699
[libx264 @ 0x7f81d7820400] consecutive B-frames:  1.0%  1.0%  1.5% 96.5%
[libx264 @ 0x7f81d7820400] mb I  I16..4: 17.6% 70.4% 12.0%
[libx264 @ 0x7f81d7820400] mb P  I16..4:  1.9%  7.2%  1.0%  P16..4: 46.6% 24.3% 10.4%  0.0%  0.0%    skip: 8.6%
[libx264 @ 0x7f81d7820400] mb B  I16..4:  0.2%  0.7%  0.1%  B16..8: 41.2%  8.8%  1.4%  direct: 4.5%  skip:43.1%  L0:45.0% L1:45.8% BI: 9.2%
[libx264 @ 0x7f81d7820400] final ratefactor: 17.18
[libx264 @ 0x7f81d7820400] 8x8 transform intra:71.3% inter:81.9%
[libx264 @ 0x7f81d7820400] coded y,uvDC,uvAC intra: 72.7% 86.5% 67.7% inter: 22.0% 28.2% 3.0%
[libx264 @ 0x7f81d7820400] i16 v,h,dc,p:  5%  7%  3% 85%
[libx264 @ 0x7f81d7820400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 17% 16%  9%  7%  8%  8%  9% 10%
[libx264 @ 0x7f81d7820400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 21% 13%  7% 10%  8% 10%  6%  5%
[libx264 @ 0x7f81d7820400] i8c dc,h,v,p: 38% 20% 16% 26%
[libx264 @ 0x7f81d7820400] Weighted P-Frames: Y:8.7% UV:2.7%
[libx264 @ 0x7f81d7820400] ref P L0: 48.0%  6.0% 25.7% 19.2%  1.1%
[libx264 @ 0x7f81d7820400] ref B L0: 80.5% 12.4%  7.0%
[libx264 @ 0x7f81d7820400] ref B L1: 93.1%  6.9%
[libx264 @ 0x7f81d7820400] kb/s:503.64
[aac @ 0x7f81d7000800] Qavg: 188.932
4
  • 1
    Nothing obvious here. Maybe it doesn't like 5.1 AAC, although it's a weak guess from a lack of anything else. Try adding -ac 2.
    – llogan
    Nov 22, 2020 at 5:57
  • Adding -ac 2 fixes processing a file with just trimming; when I combine it with resizing the video and h264 codec, I get the same error. Nov 24, 2020 at 18:13
  • 1
    Show your new command with the complete log.
    – llogan
    Nov 26, 2020 at 3:42
  • I updated the question with it. Nov 27, 2020 at 14:30

1 Answer 1

1

Appears that 5.1 audio channels is the problem. Add -ac 2 to convert it to stereo:

ffmpeg -y -ss 1.5 -to 2:07.500 -i /Volumes/NO\ NAME/PRIVATE/AVCHD/BDMV/STREAM/00147.MTS -vcodec libx264 -vf scale=540:-1 -vb 500k -ac 2 ~/Downloads/message.mp4

Location of options is important. In this case -ac 2 needed to be applied as an output option: ffmpeg [input options] -i input [output options] output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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