petrkotek/chromecastize

help casting/converting a file

TheBallOfAeolus opened this issue · 3 comments

First of all I would like to thank you for your time and help to the community.

I think your script is really helpful, but I need help for a specific file I cannot stream via Chromecast from a Synology station.

First of all chromecastize says it should be playable:

./chromecastize.sh videofile.mkv
===========
Processing: videofile.mkv
- general: Matroska -> ok
- video: AVC -> copy
- audio: AAC -> copy
- file should be playable by Chromecast!

If I try to force it to mp4 I get this output

./chromecastize.sh --mp4 videofile.mkv
===========
Processing: videofile.mkv
- file was generated by `chromecastize`, skipping

If I try to force it to mkv I get this output

./chromecastize.sh --mkv videofile.mkv
===========
Processing: videofile.mkv
- file was generated by `chromecastize`, skipping

mediainfo:

mediainfo videofile.mkv
General
Unique ID                                : xxxxxxxxxxxxxxxxxxxxxxxxxx
Complete name                            : videofile.mkv
Format                                   : Matroska
Format version                           : Version 2
File size                                : 382 MiB
Duration                                 : 47 min 46 s
Overall bit rate                         : 1 118 kb/s
Encoded date                             : UTC 2015-10-07 10:29:45
Writing application                      : mkvmerge v8.4.0 ('A better way to fly') 32bit
Writing library                          : libebml v1.3.1 + libmatroska v1.4.2
FileExtension_Invalid                    : mkv mk3d mka mks

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4.1
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 8 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 47 min 46 s
Bit rate                                 : 948 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.043
Stream size                              : 324 MiB (85%)
Writing library                          : x264 core 148 r2597 e86f3a1
Encoding settings                        : cabac=1 / ref=8 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=9 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3 / threads=12 / 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=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=240 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=2pass / mbtree=1 / bitrate=948 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=62500 / vbv_bufsize=78125 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Default                                  : Yes
Forced                                   : No

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : HE-AAC / LC
Codec ID                                 : A_AAC
Duration                                 : 47 min 46 s
Bit rate                                 : 168 kb/s
Channel(s)                               : 6 channels
Channel positions                        : Front: L C R, Side: L R, LFE
Sampling rate                            : 48.0 kHz / 24.0 kHz
Frame rate                               : 23.438 FPS (1024 SPF)
Compression mode                         : Lossy
Delay relative to video                  : 31 ms
Stream size                              : 57.4 MiB (15%)
Language                                 : English
Default                                  : Yes
Forced                                   : No

Menu
00:00:00.000                             : en:00:00:00.000
00:00:46.797                             : en:00:00:46.797
00:19:04.393                             : en:00:19:04.393
00:27:08.794                             : en:00:27:08.794
00:34:34.906                             : en:00:34:34.906
00:41:11.219                             : en:00:41:11.219
00:46:48.472                             : en:00:46:48.472

Any suggestion?

As additional information, I have manually transcoded the same video file with HandBrake and I was able to cast it.
the mediainfo of the transcoded video is:

mediainfo transformed.with.HandBrake.m4v 
General
Complete name                            : transformed.with.HandBrake.m4v
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (isom/iso2/avc1/mp41)
File size                                : 489 MiB
Duration                                 : 47 min 46 s
Overall bit rate                         : 1 430 kb/s
Movie name                               : transformed.with.HandBrake
Encoded date                             : UTC 2018-03-11 00:37:50
Tagged date                              : UTC 2018-03-11 00:37:50
Writing application                      : HandBrake 1.0.7 2017082500

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L4
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 47 min 46 s
Bit rate                                 : 1 262 kb/s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 23.976 (24000/1001) FPS
Minimum frame rate                       : 23.974 FPS
Maximum frame rate                       : 23.981 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.057
Stream size                              : 431 MiB (88%)
Writing library                          : x264 core 148 r2795 aaa9aa8
Encoding settings                        : cabac=1 / ref=2 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=6 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / 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=1 / keyint=240 / keyint_min=24 / scenecut=40 / intra_refresh=0 / rc_lookahead=30 / rc=crf / mbtree=1 / crf=22.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=20000 / vbv_bufsize=25000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Encoded date                             : UTC 2018-03-11 00:37:50
Tagged date                              : UTC 2018-03-11 00:37:50
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Menus                                    : 3

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 47 min 46 s
Bit rate mode                            : Constant
Bit rate                                 : 162 kb/s
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 55.3 MiB (11%)
Title                                    : Stereo / Stereo
Language                                 : English
Default                                  : Yes
Alternate group                          : 1
Encoded date                             : UTC 2018-03-11 00:37:50
Tagged date                              : UTC 2018-03-11 00:37:50
Menus                                    : 3

Menu
ID                                       : 3
Codec ID                                 : text
Duration                                 : 47 min 46 s
Language                                 : English
Encoded date                             : UTC 2018-03-11 00:37:50
Tagged date                              : UTC 2018-03-11 00:37:50
Bit rate mode                            : CBR
Menu For                                 : 1,2
00:00:00.000                             : 00:00:00.000
00:00:46.797                             : 00:00:46.797
00:19:04.518                             : 00:19:04.393
00:27:08.794                             : 00:27:08.794
00:34:35.031                             : 00:34:34.906
00:41:11.219                             : 00:41:11.219
00:46:48.597                             : 00:46:48.472

By the way, I've understood why if I force a file to mp4 I get this output

./chromecastize.sh --mp4 videofile.mkv
===========
Processing: videofile.mkv
- file was generated by `chromecastize`, skipping

As soon as ./chromecastize.sh videofile.mkv is run, an entrance is created in ~/.chromecastize/processed_files.

Having the file described in ~/.chromecastize/processed_files is making the option --mp4 and --mkv skipping the file.

I am still learning bash, but I think I can add a --force option, so even if a file is included in ~/.chromecastize/processed_files, chromecastize will run anyway.

Before that, I am trying to figure out how the video codec work, so chromecastize can transform to the format I am looking for.

Thanks again (I am learning a lot with your script!) ;)

Thanks for the report. I had a look at the differences between your original non-working file and the working file converted by Handbrake, and I found this report which seems to explain why it is not working: https://issuetracker.google.com/issues/69112577

Apparently the support for multichannel AAC audio has been removed in firmware 1.28.

Thanks for reporting the issue. We discarded support for 5.1 AAC & Multi-channel AAC streams for Gen 2 and Ultra devices from 1.28 onwards.

11-09 15:48:28.554 1145 1145 I cast_shell: [2604:2604:INFO:MediaSource.cpp(199)] addSourceBuffer this=0x28ead940 type="video/mp2t; codecs="avc1.4D401E,mp4a.40.2"" -> 0x396b70b0

This is working as intended. We would recommend you to use either regular stereo (2-channel) AAC or AC3/EAC3 audio or 5.1 Opus audio stream or etc.

This matches with your report, your original media file has 6 channel AAC audio and doesn't work. The Handbrake conversion has 2 channel AAC audio which works.

I think a good solution would be to check if multichannel AAC audio is used, and if this is the case, convert it to multichannel Vorbis, which is still supported.