xat / castnow

commandline chromecast player
MIT License
3.81k stars 243 forks source link

--tomp4 not working for MKV files. #47

Open ivanfeli opened 9 years ago

ivanfeli commented 9 years ago

C:\Users\User>castnow "C:\Users\User\Videos\True Detective Season 1\True Detectiv e S01E01 - The Long Bright Dark - Ehhhh.mkv" --tomp4 castnow launching... +0ms castnow:localfile started webserver on address 192.168.1.20 using port 4100 +14 ms castnow:transcode started webserver on address 192.168.1.20 using port 4103 +8m s castnow player status: loading plugins +2ms castnow player status: scanning +0ms castnow player status: connecting +132ms castnow player status: launching +152ms castnow player status: loading +1s castnow:transcode incoming request for path http://192.168.1.20:4100/0 +299ms castnow:transcode spawning ffmpeg -i - -vcodec h264 -f mp4 -movflags frag_keyfr ame+faststart -strict experimental pipe:1 +17ms castnow:localfile incoming request serving C:\Users\User\Videos\True Detective Season 1\True Detective S01E01 - The Long Bright Dark - Ehhhh.mkv +15ms castnow:transcode transcoding error: [Error: FFmpeg error: Stream mapping:] +29 8ms castnow player error: [Error: Load failed] +1s Error: Load failed

xat commented 9 years ago

Do you have the latest ffmpeg version installed?

jhvst commented 9 years ago

@FelicianoX You can play .MKV without encoding to MP4. It works for me, at least.

ivanfeli commented 9 years ago

@xat - Yes, downloaded the newest version today and tested it again.

@9uuso - It plays but there is no sound. I think maybe it'd work if I use the "--ffmpeg-* " option but I'm not sure how.

jhvst commented 9 years ago

@FelicianoX How odd, for me both video and audio works fine. I'm on OS X 10.10.1, using node v0.10.26 and my castnow version is 6f21856ff6a94a7bb836b65ec7cec801ed587447.

xat commented 9 years ago

Seems like a similar issue to this one: https://github.com/xat/castnow/issues/21

Try running castnow like this:

castnow yourmovie.mkv --tomp4 --ffmpeg-movflags frag_keyframe
ivanfeli commented 9 years ago

@xat Same error.

C:\Users\User>ffmpeg -version ffmpeg version N-68763-g202947a Copyright (c) 2000-2014 the FFmpeg developers built on Dec 28 2014 22:22:29 with gcc 4.9.2 (GCC)

C:\Users\User>npm version { http_parser: '1.0', node: '0.10.33', v8: '3.14.5.9', ares: '1.9.0-DEV', uv: '0.10.29', zlib: '1.2.3', modules: '11', openssl: '1.0.1j', npm: '1.4.28' }

For castnow I have this version: https://github.com/xat/castnow/commit/6f21856ff6a94a7bb836b65ec7cec801ed587447

Ayms commented 9 years ago

A ffmpeg command (taken from Buck Bunny site) that works for all formats so far is the one described here Peersm links, in addition the webm output is compatible with adaptive streaming and works inside browsers with the Media Source Extensions API.

mp4 would be better but I am not aware of an equivalent ffmpeg command without combining with mp4box if you want it to be compatible with adaptive streaming (which is not necessary here but would still be preferable)

For torrent-live I did not succeed to run the very same command for webm output and had the same issue as #21 for mp4, both webm and mp4 works now, mp4 is the same as described here, for webm you can take a look at https://github.com/Ayms/torrent-live/blob/master/freerider.js#l404-435

ianmurrays commented 9 years ago

I discovered adding --ffmpeg-ac 2 fixes the issue. It seems to be an issue with converting 5.1 audio.

michande commented 9 years ago

Oh, I will try that asap ianmurrays, kind of the old school way using mplayer :-)

omgbox commented 9 years ago

some mkv problem with AC3 audio not converting

voska commented 9 years ago

I'm having this same issue. castnow ./video.mkv gets me video without audio. castnow ./video.mkv --tomp4 throws a transcoding FFmpeg error: Stream mapping. castnow ./video.mkv --tomp4 --ffmpeg-ac 2 gets me audio without video.

ksclarke commented 9 years ago

Same problem but castnow ./video.mkv --tomp4 --ffmpeg-ac 2 does work for me.

fayesafe commented 9 years ago

I kindly want to contribute to this issue and its discussion even though I am not quite sure whether or not it is still relevant. However, I also got the problem that castnow video.mkv left me without audio and castnow video.mkv --tomp4 left me without video.

But, after some time of researching, I was able to solve this problem by editing your source code a little. Considering the file transcode.js, I did change the following part (starting at line 32):

    var trans = new Transcoder(s)
      .videoCodec('h264')
      .format('mp4')
      .custom('strict', 'experimental')
      .on('finish', function() {
        debug('finished transcoding');
      })
      .on('error', function(err) {
        debug('transcoding error: %o', err);
      });

to

    var trans = new Transcoder(s)
      .videoCodec('h264')
      .format('matroska')
      .audioCodec('aac')
      .audioBitrate(128*1000)
      .channels(2)
      .custom('strict', 'experimental')
      .on('finish', function() {
        debug('finished transcoding');
      })
      .on('error', function(err) {
        debug('transcoding error: %o', err);
      });

That way, I was able to play audio and video simultaneously and without any noticeable flaws. Anyways, the stream sometimes laggs when it starts, maybe because the conversion is now slower than it was. I wanted to add these information in case someone has a similar issue like I did. I am glad if I might helped anyone.

camerondpt commented 8 years ago

@fayesafe

Your fix worked for me! No detectable lag for me, and none of the other ffmpeg solutions worked.

Thanks a bunch!

hemanth commented 8 years ago

@fayesafe Would you mind doing a PR?

fayesafe commented 8 years ago

@hemanth not sure about that. Iirc, it does not format the source to mp4, which would be the expected behaviour for the '--tomp4' option.