muammar / mkchromecast

Cast macOS and Linux Audio/Video to your Google Cast and Sonos Devices
http://mkchromecast.com
Other
2.21k stars 137 forks source link

[Linux] Some video works, some not #254

Open xanscale opened 5 years ago

xanscale commented 5 years ago

i don't know if is a bug or my mistake but with some video works and with many others not. i need to install some codec ? all video works using Totem video player

uname -a
Linux ThinkPad-X1 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
ffmpeg -version
ffmpeg version 3.4.4-0ubuntu0.18.04.1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil      55. 78.100 / 55. 78.100
libavcodec     57.107.100 / 57.107.100
libavformat    57. 83.100 / 57. 83.100
libavdevice    57. 10.100 / 57. 10.100
libavfilter     6.107.100 /  6.107.100
libavresample   3.  7.  0 /  3.  7.  0
libswscale      4.  8.100 /  4.  8.100
libswresample   2.  9.100 /  2.  9.100
libpostproc    54.  7.100 / 54.  7.100

i updated ffmpeg to 4.1.3 but nothig changed

this works perfectly, audio and video

mkchromecast --source-url http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 --video
Mkchromecast v0.3.8.1
Starting Video Cast Process...
PID of main process: 4436
PID of streaming process: 4440
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

List of Devices Available in Network:
-------------------------------------

Index   Types   Friendly Name 
=====   =====   ============= 
0   Gcast   TV

Casting to first device shown above!
Select devices by using the -s flag.

TV

Information about  TV

DeviceStatus(friendly_name='TV', model_name='Chromecast', manufacturer='Google Inc.', api_version=(1, 0), uuid=UUID('bb65b05c-c80b-5c19-2e74-6f0407aced43'), cast_type='cast')

Status of device  TV

CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.699999988079071, volume_muted=False, app_id='E8C28D3C', display_name='Backdrop', namespaces=['urn:x-cast:com.google.cast.debugoverlay', 'urn:x-cast:com.google.cast.cac', 'urn:x-cast:com.google.cast.sse', 'urn:x-cast:com.google.cast.remotecontrol'], session_id='41df1847-6191-43db-8eee-0f016c37e5a1', transport_id='41df1847-6191-43db-8eee-0f016c37e5a1', status_text='')

The IP of TV is: 192.168.0.14
Your local IP is: 192.168.0.18

Casting from stream URL: http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
Using media type: video/mp4

Cast media controller status

CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.699999988079071, volume_muted=False, app_id='E8C28D3C', display_name='Backdrop', namespaces=['urn:x-cast:com.google.cast.debugoverlay', 'urn:x-cast:com.google.cast.cac', 'urn:x-cast:com.google.cast.sse', 'urn:x-cast:com.google.cast.remotecontrol'], session_id='41df1847-6191-43db-8eee-0f016c37e5a1', transport_id='41df1847-6191-43db-8eee-0f016c37e5a1', status_text='')

Remember to open pavucontrol and select the mkchromecast sink.

Ctrl-C to kill the Application at any Time

in this case i see only the blue chromecast icon on TV

mkchromecast --source-url http://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_2mb.mp4 --video
Mkchromecast v0.3.8.1
Starting Video Cast Process...
PID of main process: 4543
PID of streaming process: 4547
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

List of Devices Available in Network:
-------------------------------------

Index   Types   Friendly Name 
=====   =====   ============= 
0   Gcast   TV

Casting to first device shown above!
Select devices by using the -s flag.

TV

Information about  TV

DeviceStatus(friendly_name='TV', model_name='Chromecast', manufacturer='Google Inc.', api_version=(1, 0), uuid=UUID('bb65b05c-c80b-5c19-2e74-6f0407aced43'), cast_type='cast')

Status of device  TV

CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.699999988079071, volume_muted=False, app_id='E8C28D3C', display_name='Backdrop', namespaces=['urn:x-cast:com.google.cast.debugoverlay', 'urn:x-cast:com.google.cast.cac', 'urn:x-cast:com.google.cast.sse', 'urn:x-cast:com.google.cast.remotecontrol'], session_id='43dabe1c-7673-470d-b9c8-a1b4447d62ad', transport_id='43dabe1c-7673-470d-b9c8-a1b4447d62ad', status_text='')

The IP of TV is: 192.168.0.14
Your local IP is: 192.168.0.18

Casting from stream URL: http://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_2mb.mp4
Using media type: video/mp4

Cast media controller status

CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.699999988079071, volume_muted=False, app_id='E8C28D3C', display_name='Backdrop', namespaces=['urn:x-cast:com.google.cast.debugoverlay', 'urn:x-cast:com.google.cast.cac', 'urn:x-cast:com.google.cast.sse', 'urn:x-cast:com.google.cast.remotecontrol'], session_id='43dabe1c-7673-470d-b9c8-a1b4447d62ad', transport_id='43dabe1c-7673-470d-b9c8-a1b4447d62ad', status_text='')

Remember to open pavucontrol and select the mkchromecast sink.

Ctrl-C to kill the Application at any Time
SamStaps commented 5 years ago

I have the same issue. I also cannot stream downloaded .mp4 file, it is H264, but plays fine with the "videos" app.

stochashtic commented 4 years ago

Also have same issue with mp4/h264. Back to VLC.

frat3rius commented 4 years ago

I've played around with ffmpeg command, and ended up with: mkchromecast --video --command 'ffmpeg -i video.avi -vcodec h264 -acodec aac -f matroska pipe:1' --debug which I think should work, I've got no errors and I'm seeing that chromecast is picking the signal but then just drops and no traffic is being send. At the end all there is on screen is blue cast icon.

In fact I tried with VLC and it gives me info that the file needs convertion. With VLC it works as a charm. I think it's some minor bug that has something to do with ffmpeg convertion process.

JonasVautherin commented 4 years ago

I have exactly the same issue, and I can reproduce this with the videos @xanscale links above. Instead of using mkchromecast, I tried to reproduce with my own setup using pychromecast directly. What I observe is that I get the error code "MEDIA_UNKNOWN", which is documented here:

The media element encountered an error that did not indicate it's one of MediaError.MEDIAERR*. This should be rare.

I have more details about my debugging in this stackoverflow question.

Does anyone get the error code as well?

JonasVautherin commented 4 years ago

So in my case, it seems like the 5.1 channel was the reason for the issue. I ran the command suggested in my stackoverflow question:

ffmpeg -i not_working.mp4 -c copy -c:a aac -ac 2 -movflags +faststart fixed.mp4

And then it worked. Hope this helps somebody.

xanscale commented 4 years ago

so this bug should be reported to : https://github.com/home-assistant-libs/pychromecast

anyway ubuntu 20.04 include 4.1.0 but actually last are 5.3.0 (upgrading will resolve? i dont know)

@JonasVautherin want to open there, you are much informed then me :D

JonasVautherin commented 4 years ago

I don't think this is a pychromecast issue. In my understanding, pychromecast just tells the chromecast device where to go fetch the video. If the video has the wrong format or is not available, then the chromecast device will return an error.

What mkchromecast does is taking a local video file and making it available to the chromecast device through an http server. Maybe mkchromecast may want to check the video format and convert it, or maybe it is okay to delegate that to the user. What do you think?

stochashtic commented 4 years ago

On downmixing 5.1 audio, please check out this thread:

https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg

The -ac 2 flag ignores the centre channel. I've noticed this with VLC, where the voice audio is difficult to hear/understand when downmixed.

The optimal downmix is this according to that thread:

-ac 2 -af "pan=stereo|FL < 1.0*FL + 0.707*FC + 0.707*BL|FR < 1.0*FR + 0.707*FC + 0.707*BR"

xanscale commented 4 years ago

@JonasVautherin if you cast from player of Android device it will works. I don't know how it can

JonasVautherin commented 4 years ago

@stochashtic: What about the comment that says:

The ATSC standards you've linked here were linked to from the FFmpeg wiki on the topic, so it's unsurprising that the formula used here is the same one implemented by FFmpeg with its ac -2 switch. In other words, the only difference between using this filter and doing ac -2 is a lot more typing.

Is it inaccurate?