l3tnun / EPGStation

Mirakurun を使用した録画管理ソフト
https://twitter.com/l3tnun
MIT License
552 stars 149 forks source link

FFmpeg変換が機能しない(Windows) #341

Closed ShintakuNobuhiro closed 4 years ago

ShintakuNobuhiro commented 4 years ago

環境

Issue

ライブストリーム、録画ストリームいずれも、無変換以外にすると、読み込み状態のまま再生できません。 FFmpegのプロセスは立ち上がっており、debugにしたときにFFmpegの起動ログは残っていますが、実際にエンコード処理が行われないようです。 画質プリセットはデフォルトのままで、FFmpegのバージョンを上記変えてみたりはしましたが、いずれもNGでした。

FFmpegに対してコマンドレットで手動でエンコードを流すと、普通に変換ができていますが、EPGStationからのリクエストにうまく応じられていないようです。プロセス起動そのものはできているため、パスの誤りもないと思いますが、何が原因なのでしょうか?

stream.log (debug)

[2020-09-21T18:23:44.000] [INFO] stream - start stream: 1 [2020-09-21T18:23:44.010] [DEBUG] stream - ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 7.2.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx libavutil 55. 34.100 / 55. 34.100 libavcodec 57. 64.100 / 57. 64.100 [2020-09-21T18:23:44.010] [DEBUG] stream - libavformat 57. 56.100 / 57. 56.100 libavdevice 57. 1.100 / 57. 1.100 libavfilter 6. 65.100 / 6. 65.100 libswscale 4. 2.100 / 4. 2.100 libswresample 2. 3.100 / 2. 3.100 libpostproc 54. 1.100 / 54. 1.100 [2020-09-21T18:23:44.314] [INFO] stream - stop stream: 0 [2020-09-21T18:23:47.950] [INFO] stream - stop stream: 1

system.log

[2020-09-21T18:23:43.998] [INFO] system - create new encode child: 1600680223997

l3tnun commented 4 years ago

config.json をデフォルトから変えていませんか? 少なくとも ffmpeg 4.1.4 であれば問題なく動くと思いますが。

ShintakuNobuhiro commented 4 years ago

config.json をデフォルトから変えたのは下記の部分ですが、変えてはいけないところもありましたでしょうか?

"ffmpeg": "C:\ffmpeg\ffmpeg.exe", "ffprobe": "C:\ffmpeg\ffprobe.exe",

"encode": [ { "name": "H264", "cmd": "%NODE% %ROOT%\config\enc.js", "suffix": ".mp4", "default": true }

l3tnun commented 4 years ago

特に問題なさそうですね。

エンコードも動作しないのでしょうか?

エンコードの場合 config/serviceLogConfig.jsonsystem を debug に切り替えてエンコードをさせてみてください。 ffmpeg のログが記録されます。

ShintakuNobuhiro commented 4 years ago

system も debug にしていますが、create new encode child のログが記録されるのみで、それに対する反応がありません。

l3tnun commented 4 years ago

なるほど、ではenc.jsが手動で正常に動くか確かめたほうが良いかもしれませんね。

enc.js の以下の部分を変更して enc,js が単体で動作するか確認してください。

2行目

const ffmpeg = process.env.FFMPEG;
const ffmpeg = 'C:\\ffmpeg\\ffmpeg.exe'; // ffmpeg のフルパス

4行目

const input = process.env.INPUT;
const input = 'C:\\hoge\\fuga.ts'; // 適当な ts ファイルフルパス

5行目

const output = process.env.OUTPUT;
const output = 'C:\\hoge\\fuga.mp4'; // 適当な保存先フルパス

以上の3箇所を修正したあと以下のようにして enc.js を手動で動かしてください

node enc.js

ffmpeg へ渡した引数と、ffmpeg の標準エラー出力が表示されるはずです。

もしこれで ffmpeg が動作しない場合、ffmpeg側になにか問題があるのかもしれません。 (受け付けられないオプションが渡されている等)

ShintakuNobuhiro commented 4 years ago

BonRecTestで録画したものを読み込ませたところ、特に問題なくエンコードでき、動画の再生も確認することができました。 しかしながら、EPGStationで予約したものについては、エンコードエラーが発生しました。

-y -analyzeduration 10M -probesize 32M -i C:\ffmpeg\1.ts -movflags faststart -vf yadif -preset veryfast -aspect 16:9 -c:v libx264 -crf 23 -f mp4 -c:a aac -ar 48000 -ab 128k -ac 2 C:\ffmpeg\1-b.ts ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 7.2.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx

libavutil 55. 34.100 / 55. 34.100 libavcodec 57. 64.100 / 57. 64.100 libavformat 57. 56.100 / 57. 56.100 libavdevice 57. 1.100 / 57. 1.100 libavfilter 6. 65.100 / 6. 65.100 libswscale 4. 2.100 / 4. 2.100 libswresample 2. 3.100 / 2. 3.100 libpostproc 54. 1.100 / 54. 1.100

[mpegts @ 0000018f09376fe0] nothing to probe for stream 2

[mpegts @ 0000018f09376fe0] start time for stream 0 is not set in estimate_timings_from_pts [mpegts @ 0000018f09376fe0] start time for stream 1 is not set in estimate_timings_from_pts [mpegts @ 0000018f09376fe0] start time for stream 2 is not set in estimate_timings_from_pts [mpegts @ 0000018f09376fe0] start time for stream 3 is not set in estimate_timings_from_pts

[mpegts @ 0000018f09376fe0] Could not find codec parameters for stream 0 (Video: mpeg2video ([2][0][0][0] / 0x0002), none(tv)): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options [mpegts @ 0000018f09376fe0] Could not find codec parameters for stream 1 (Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp): unspecified sample rate Consider increasing the value for the 'analyzeduration' and 'probesize' options [mpegts @ 0000018f09376fe0] Could not find codec parameters for stream 4 (Unknown: none ([13][0][0][0] / 0x000D)): unknown codec Consider increasing the value for the 'analyzeduration' and 'probesize' options [mpegts @ 0000018f09376fe0] Could not find codec parameters for stream 5 (Unknown: none ([13][0][0][0] / 0x000D)): unknown codec Consider increasing the value for the 'analyzeduration' and 'probesize' options [mpegts @ 0000018f09376fe0] Could not find codec parameters for stream 6 (Unknown: none ([13][0][0][0] / 0x000D)): unknown codec Consider increasing the value for the 'analyzeduration' and 'probesize' options

[mpegts @ 0000018f09376fe0] Could not find codec parameters for stream 7 (Unknown: none ([13][0][0][0] / 0x000D)): unknown codec Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, mpegts, from 'C:\ffmpeg\1.ts': Duration: N/A, bitrate: N/A Program 22544 Metadata: service_name : ?RAB?@D?9J|Aw?1 service_provider: Stream #0:0[0x100]: Video: mpeg2video ([2][0][0][0] / 0x0002), none(tv), 90k tbr, 90k tbn, 90k tbc Stream #0:1[0x110]: Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp Stream #0:2[0x130]: Data: bin_data ([6][0][0][0] / 0x0006) Stream #0:3[0x138]: Data: bin_data ([6][0][0][0] / 0x0006) Stream #0:4[0x511]: Unknown: none ([13][0][0][0] / 0x000D) Stream #0:5[0x512]: Unknown: none ([13][0][0][0] / 0x000D) Stream #0:6[0x611]: Unknown: none ([13][0][0][0] / 0x000D) Stream #0:7[0x612]: Unknown: none ([13][0][0][0] / 0x000D) Program 22545 Metadata: service_name : ?RAB?@D?9J|Aw?2 service_provider: Program 22546 Metadata: service_name : ?RAB?@D?9J|Aw?3 service_provider: Program 22928 Metadata: service_name : ?RAB?@D?9J|Aw7HBS service_provider: Program 22547 Metadata: service_name : ?RAB?@D?9J|AwNW;~ service_provider: Output #0, mp4, to 'C:\ffmpeg\1-b.ts': Output file #0 does not contain any stream

l3tnun commented 4 years ago

[mpegts @ 0000018f09376fe0] Could not find codec parameters for stream 0 (Video: mpeg2video ([2][0][0][0] / 0x0002), none(tv)): unspecified size Consider increasing the value for the 'analyzeduration' and 'probesize' options

ffmpeg がうまく ts を解釈できていないようですね。 エラーにあるように analyzeduration と probesize を増やしてみてください。

enc.js の 6,7 行目がそれになります。

ShintakuNobuhiro commented 4 years ago

どちらも512Mに増やしてみましたが、エラー内容に変化がありませんでした。

l3tnun commented 4 years ago

mirakurun の /api/programs/{id}/stream を適当にファイル保存したものはどうでしょうか? もしこれでだめなら BonRecTest -> Mirakurun を経由した時点でなにかおかしいです。

ShintakuNobuhiro commented 4 years ago

上記apiをたたいても、同じエラーでした…。tsファイルの再生はできるのですが、まったく同じエラーです。 ということは、Mirakurun側の問題かもしれませんね。

l3tnun commented 4 years ago

Mirakurun 側で大きな ts パケットの変更は行われないはずなので、不可解ですね。 現状、ffmpeg のオプションを適当に変更してエンコードできるパラメータを見つけるくらいしか手立てがなさそうです。

ShintakuNobuhiro commented 4 years ago

大変申し訳ございません!非常に単純なミスをやらかしていました! tuners.yml内のBonRecTest.exeのコマンド指定で、decoderの指定忘れが原因でした…。 質問内容があいまいな中、迅速なご対応いただき、大変感謝しております。

Before :

command: C:\PT3\BonRecTest\BonRecTest.exe --driver BonDriver_PT3-T1.dll --output - --channel

After :

command: C:\PT3\BonRecTest\BonRecTest.exe --decoder B25Decoder.dll --driver BonDriver_PT3-T1.dll --output - --channel