arciisine / vscode-chronicler

VS Code Screen Recording
MIT License
62 stars 13 forks source link

MP4 cannot be played on Quicktime #13

Closed madzim closed 5 years ago

madzim commented 5 years ago

OS: macOS Mojave, Version 10.14.4 Chronicler: 0.1.3 VSCode: 1.38.1 Quicktime: 10.5 (935.3) ffmpeg: 4.1.2 ffmpeg location: /usr/local/bin/ffmpeg (used $which ffmpeg to locate) settings.json: "chronicler.ffmpeg-binary": "/usr/local/bin/ffmpeg",

Error message when opening in Quicktime:

The document 'c.mp4' could not be opened.
The file isn't compatible with QuickTime Player.

IMPACT

This is more of an inconvenience to have to select a different default player or open the file in the browser.

SUSPECTED CAUSE

It appears the problem may be with pix format (-pix_fmt).

Here is the info about the file:

ffmpeg -i c.mp4
ffmpeg version 4.1.2 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.2 --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 'c.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:00:06.50, start: 0.000000, bitrate: 4698 kb/s
    Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuvj444p(pc), 2256x1237, 4696 kb/s, 10 fps, 10 tbr, 10240 tbn, 20 tbc (default)
    Metadata:
      handler_name    : VideoHandler

The pixel format is reported as yuvj444p(pc).

Some googling suggest that QuickTime only supports yuv420p.

WORKAROUNDS [attempted]

Workaround #1: Manually convert using FFMPEG (did not succeed)

I'm not particularly skilled, but I attempted to just change the -pix_fmt yuv420p

But the file couldn't be converted because h264 requires even-numbered dimensions but the videos has an odd-numbered height of 1237.

Given that Chronicle was able to create the image

ffmpeg -i c.mp4 -f h264 -pix_fmt yuv420p c_fixed.mp4 -hide_banner

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'c.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:00:06.50, start: 0.000000, bitrate: 4698 kb/s
    Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuvj444p(pc), 2256x1237, 4696 kb/s, 10 fps, 10 tbr, 10240 tbn, 20 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler @ 0x11a760000] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x7f9964009000] height not divisible by 2 (2256x1237)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

I tried using -vf "pad=2256:1238" per some recommendations I found on SO, but I got the same error.

Workaround #2 : Add chronicler.flags to settings.json

"chronicler.flags": "-pix_fmt yuv420p",

I wasn't confident that this was going to work because the line is greyed out in VSCode.

A looked over the source code and I couldn't find a reference to the flags configuration setting.

Maybe it is just missing in types.ts?

arciisine commented 5 years ago

Yeah. This is a known issue as a balance between quality and QuickTime support. I thought I had that outlined but I'll double check.

On Wed, Oct 9, 2019, 10:34 AM Zim notifications@github.com wrote:

OS: macOS Mojave, Version 10.14.4 Chronicler: 0.1.3 VSCode: 1.38.1 Quicktime: 10.5 (935.3) ffmpeg: 4.1.2 ffmpeg location: /usr/local/bin/ffmpeg (used $which ffmpeg to locate) settings.json: "chronicler.ffmpeg-binary": "/usr/local/bin/ffmpeg",

Error message when opening in Quicktime:

The document 'c.mp4' could not be opened. The file isn't compatible with QuickTime Player.

IMPACT

This is more of an inconvenience to have to select a different default player or open the file in the browser. SUSPECTED CAUSE

It appears the problem may be with pix format (-pix_fmt).

Here is the info about the file:

ffmpeg -i c.mp4 ffmpeg version 4.1.2 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.2 --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 'c.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.20.100 Duration: 00:00:06.50, start: 0.000000, bitrate: 4698 kb/s Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuvj444p(pc), 2256x1237, 4696 kb/s, 10 fps, 10 tbr, 10240 tbn, 20 tbc (default) Metadata: handler_name : VideoHandler

The pixel format is reported as yuvj444p(pc).

Some googling suggest that QuickTime only supports yuv420p. WORKAROUNDS [attempted] Workaround #1 https://github.com/arciisine/vscode-chronicler/pull/1: Manually convert using FFMPEG (did not succeed)

I'm not particularly skilled, but I attempted to just change the -pix_fmt yuv420p

But the file couldn't be converted because h264 requires even-numbered dimensions but the videos has an odd-numbered height of 1237.

Given that Chronicle was able to create the image

ffmpeg -i c.mp4 -f h264 -pix_fmt yuv420p c_fixed.mp4 -hide_banner

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'c.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf58.20.100 Duration: 00:00:06.50, start: 0.000000, bitrate: 4698 kb/s Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuvj444p(pc), 2256x1237, 4696 kb/s, 10 fps, 10 tbr, 10240 tbn, 20 tbc (default) Metadata: handler_name : VideoHandler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Press [q] to stop, [?] for help [swscaler @ 0x11a760000] deprecated pixel format used, make sure you did set range correctly [libx264 @ 0x7f9964009000] height not divisible by 2 (2256x1237) Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

I tried using -vf "pad=2256:1238" per some recommendations I found on SO, but I got the same error. Workaround #2 https://github.com/arciisine/vscode-chronicler/issues/2 : Add chronicler.flags to settings.json

"chronicler.flags": "-pix_fmt yuv420p",

I wasn't confident that this was going to work because the line is greyed out in VSCode.

A looked over the source code and I couldn't find a reference to the flags configuration setting.

Maybe it is just missing in types.ts?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/arciisine/vscode-chronicler/issues/13?email_source=notifications&email_token=AAJUULZW3LYEBKW6K2XN3DLQNXTXJA5CNFSM4I7AKJH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HQVAKTQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJUUL2TUUCJ77ZCBNGROU3QNXTXJANCNFSM4I7AKJHQ .

arciisine commented 5 years ago

Passing the flags should allow you to override the underlying flags passed to ffmpeg. I'll verify, and if so, I'll add the specific steps in the readme for Quicktime support.

arciisine commented 5 years ago

Updated the docs, and pushed out a fix to ensure the flags work properly. The final format would be:

"chronicler.flags": { 
   "pix_fmt": "yuv420p"
}