FallingSnow / h265ize

A node utility utilizing ffmpeg to encode videos with the hevc codec.
MIT License
527 stars 82 forks source link

ffmpeg exited with code 1: Error initializing output stream 0:1 -- Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height #151

Open Treverr opened 4 years ago

Treverr commented 4 years ago

I am getting an error when trying to convert a file:

ffmpeg exited with code 1: Error initializing output stream 0:1 -- Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed!

[h265ize]: [debug] Log file location: /Volumes/Media 2/Movies/Annie (1982)/h265ize.log
[h265ize]: [verbose] Handling keypresses...
[h265ize]: [verbose] Setting as-preset options...
[h265ize]: [debug] Video files found: 
    - Annie (1982).mkv
[h265ize]: [verbose] Folder encoding started at Friday, May 15th 2020, 9:21:34 AM
[h265ize]: Processing Annie (1982).mkv...
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[h265ize]: [verbose] Encoding started at Fri, 9:21 AM
[h265ize]: [debug] Path: Annie (1982).mkv
[h265ize]: [verbose] Getting metadata...
[h265ize]: [debug] Container data:
    - duration: 02:07:23
    - size: 8.75 GB
[h265ize]: [verbose] Resolving video streams...
[h265ize]: [debug] Working on stream:
[h265ize]: [debug] Working on stream: 1
[h265ize]: [debug] Working on stream: 2
[h265ize]: [verbose] Upconverting...
[h265ize]: [debug] Upconverting 0 tracks.
[h265ize]: [verbose] Setting video bit depth...
[h265ize]: [verbose] Mapping streams...
[h265ize]: [debug] Video stream 0:0 mapped.
    - size: 1920x808
    - codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
    - profile: High
    - bit depth: 8
[h265ize]: [alert] Audio does not have a title. Title set to "English DTS DTS (5.1 Channel)".
[h265ize]: [debug] Audio stream 0:1 mapped.
    - title: undefined
    - language: English
    - codec: DCA (DTS Coherent Acoustics)
    - channels: 6
    - profile: DTS
[h265ize]: English
[h265ize]: [alert] Subtitle does not have a title. Title set to English.
[h265ize]: [debug] Subtitle stream 0:2 mapped.
    - title: undefined
    - language: English
    - codec: SubRip subtitle
[h265ize]: [verbose] Detecting auto crop...
[h265ize]: Crop Detection: 1/12
[h265ize]: [debug] Running Query: ffmpeg -ss 7055.637230769231 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 2/12
[h265ize]: [debug] Running Query: ffmpeg -ss 6467.667461538461 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 3/12
[h265ize]: [debug] Running Query: ffmpeg -ss 5879.697692307692 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 4/12
[h265ize]: [debug] Running Query: ffmpeg -ss 5291.727923076923 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 5/12
[h265ize]: [debug] Running Query: ffmpeg -ss 4703.758153846154 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 6/12
[h265ize]: [debug] Running Query: ffmpeg -ss 4115.7883846153845 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 7/12
[h265ize]: [debug] Running Query: ffmpeg -ss 3527.8186153846154 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 8/12
[h265ize]: [debug] Running Query: ffmpeg -ss 2939.848846153846 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 9/12
[h265ize]: [debug] Running Query: ffmpeg -ss 2351.879076923077 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 10/12
[h265ize]: [debug] Running Query: ffmpeg -ss 1763.9093076923077 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 11/12
[h265ize]: [debug] Running Query: ffmpeg -ss 1175.9395384615384 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: Crop Detection: 12/12
[h265ize]: [debug] Running Query: ffmpeg -ss 587.9697692307692 -i Annie (1982).mkv -y -vframes 2 -filter:v cropdetect=0.094:16:0 -map 0:0 -f null -
[h265ize]: [alert] Output will be cropped to 1920x800. Originally 1920x808
[h265ize]: [verbose] Mapping HE Audio streams...
[h265ize]: [verbose] Audio stream undefined (index: 1) will be encoded to HE Audio.
[h265ize]: [alert] Audio does not have a title. Title set to "English OPUS (5.1 Channel)".
[h265ize]: [verbose] Setting ffmpeg settings...
[h265ize]: [verbose] Encoding video...
[h265ize]: [debug] Running Query: ffmpeg -n 10 /usr/bin/ffmpeg -i Annie (1982).mkv -y -acodec copy -vcodec libx265 -filter:v crop=1920:800:0:4 -c:s copy -pix_fmt yuv420p -map 0:0 -map 0:1 -metadata:s:a:1 title="English DTS DTS (5.1 Channel)" -map 0:2 -metadata:s:0:2 title=English -metadata:s:0:2 DISPOSITION:default=0 -c:a:0 libopus -b:a:0 240k -frame_duration 60 -metadata:s:a:1 title="English OPUS (5.1 Channel)" -preset fast -x265-params crf=23: /tmp/h265ize/Annie (1982).encoding-in-progress.mkv
[h265ize]: [debug] Error: ffmpeg exited with code 1: Error initializing output stream 0:1 -- Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/h265ize/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
[h265ize]: ffmpeg exited with code 1: Error initializing output stream 0:1 -- Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

[h265ize]: [verbose] Finished encoding at Fri, 9:21 AM (a few seconds)
[h265ize]: [debug] Finished encoding in 2.705 seconds.
[h265ize]: Folder encoding finished at Friday, May 15th 2020, 9:21:37 AM
optio50 commented 4 years ago

Are you using the --he-audio option? I also get this error with files that have AC-3 6 channel audio and trying to use opus HE audio. The only workaround I found is to downmix the audio to Opus 2 channel or keep original audio. --he-audio --downmix-he-audio

optio50 commented 4 years ago

You could also convert just the audio to Opus before you use H265ize to avoid the error. You can use this command. ffmpeg -i 'InPut.mkv' -c:v copy -c:a libopus -b:a 256k -af aformat=channel_layouts="7.1|5.1|stereo" 'OutPut.mkv'

This should be a very quick process as you are only touching the audio in the video. Then there is no need to use the --he-audio option for H265ize