lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
540 stars 24 forks source link

Error initializing output stream: Error while opening encoder for output stream #0:0 #199

Open ravedoglv opened 6 months ago

ravedoglv commented 6 months ago

Just upgraded to Sonoma. Made sure i Updated Homebrew, all packages, and OVT was the latest. (Running on a Mac Book Pro M1 Max).

However, when I run my usual command:

other-transcode --vt-allow-sw --mp4 --hevc --crop 0:0:68:68 '/Users/ravedog/Desktop/rips/The Holdovers (2023)/src/ds-Road Back to Barton.mkv'

I am now met with an error:

Error initializing output stream: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height /usr/local/bin/other-transcode: transcoding failed: ds-Road Back to Barton.mp4

If I remove --hevc it will work. These are the same MKV source files that worked prior to updating my MacOS.

Here is the generated log file:

'ffmpeg started on 2024-01-03 at 19:11:54 Report written to "_ffmpeg_60553_6220.mp4.log" Log level: 40 Command line: ffmpeg -loglevel error -stats -i "/Users/ravedog/Desktop/rips/The Holdovers (2023)/src/ds-Road Back to Barton.mkv" -map 0:0 -filter:v "crop=1784:1080:68:0" -c:v hevc_videotoolbox -b:v 4000k -allow_sw:v 1 -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v "title=" -disposition:v default -tag:v hvc1 -map 0:1 -c:a:0 copy -metadata:s:a:0 "title=" -disposition:a:0 default -sn -metadata:g "title=" -movflags disable_chpl "ds-Road Back to Barton.mp4" ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers built with Apple clang version 15.0.0 (clang-1500.0.40.1) configuration: --prefix=/usr/local/Cellar/ffmpeg/6.0_2 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-audiotoolbox libavutil 58. 2.100 / 58. 2.100 libavcodec 60. 3.100 / 60. 3.100 libavformat 60. 3.100 / 60. 3.100 libavdevice 60. 1.100 / 60. 1.100 libavfilter 9. 3.100 / 9. 3.100 libswscale 7. 1.100 / 7. 1.100 libswresample 4. 10.100 / 4. 10.100 libpostproc 57. 1.100 / 57. 1.100 [h264 @ 0x7fba1d004640] Reinit context to 1920x1088, pix_fmt: yuv420p [matroska,webm @ 0x7fba1c705ec0] max_analyze_duration 5000000 reached at 5005000 microseconds st:0 [matroska,webm @ 0x7fba1c705ec0] Could not find codec parameters for stream 2 (Subtitle: hdmv_pgs_subtitle (pgssub)): unspecified size Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options Input #0, matroska,webm, from '/Users/ravedog/Desktop/rips/The Holdovers (2023)/src/ds-Road Back to Barton.mkv': Metadata: title : The Holdovers encoder : libmakemkv v1.17.5 (1.3.10/1.5.2) darwin(arm64-release) creation_time : 2024-01-03T23:15:55.000000Z Duration: 00:01:49.44, start: 0.000000, bitrate: 16916 kb/s Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn Metadata: BPS-eng : 16717998 DURATION-eng : 00:01:49.400958333 NUMBER_OF_FRAMES-eng: 2623 NUMBER_OF_BYTES-eng: 228618629 SOURCE_ID-eng : 001011 _STATISTICS_WRITING_APP-eng: MakeMKV v1.17.5 darwin(arm64-release) _STATISTICS_WRITING_DATE_UTC-eng: 2024-01-03 23:15:55 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default) Metadata: title : Stereo BPS-eng : 192000 DURATION-eng : 00:01:49.440000000 NUMBER_OF_FRAMES-eng: 3420 NUMBER_OF_BYTES-eng: 2626560 SOURCE_ID-eng : 001100 _STATISTICS_WRITING_APP-eng: MakeMKV v1.17.5 darwin(arm64-release) _STATISTICS_WRITING_DATE_UTC-eng: 2024-01-03 23:15:55 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID Stream #0:2(eng): Subtitle: hdmv_pgs_subtitle Metadata: BPS-eng : 13228 DURATION-eng : 00:01:23.395812500 NUMBER_OF_FRAMES-eng: 18 NUMBER_OF_BYTES-eng: 137899 SOURCE_ID-eng : 001200 _STATISTICS_WRITING_APP-eng: MakeMKV v1.17.5 darwin(arm64-release) _STATISTICS_WRITING_DATE_UTC-eng: 2024-01-03 23:15:55 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_videotoolbox)) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [h264 @ 0x7fba1d014600] Reinit context to 1920x1088, pix_fmt: yuv420p [graph 0 input from stream 0:0 @ 0x7fba1c70a0c0] w:1920 h:1080 pixfmt:yuv420p tb:1/1000 fr:24000/1001 sar:1/1 [Parsed_crop_0 @ 0x7fba1c70b800] w:1920 h:1080 sar:1/1 -> w:1784 h:1080 sar:1/1 [hevc_videotoolbox @ 0x7fba1d011e00] Error encoding frame: -12905 [hevc_videotoolbox @ 0x7fba1d011e00] popping: -542398533 [vost#0:0/hevc_videotoolbox @ 0x7fba1d011b00] Error initializing output stream: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height [AVIOContext @ 0x7fba1d013b40] Statistics: 0 bytes written, 0 seeks, 0 writeouts Terminating demuxer thread 0 [AVIOContext @ 0x7fba1c7064c0] Statistics: 1812542 bytes read, 2 seeks Conversion failed!'

Any ideas?

ttyS0 commented 6 months ago

I don't know what the specific problem is, but there are two things I'd try first.

Also, it's possible that this is a source file problem. To that end, it might be useful to try the same command on a different (ideally, a "known good") source file.

ravedoglv commented 6 months ago

i undated ffmpeg but still the same issue. However, removing --vt-allow-sw seems to fix it. However it is not using hardware acceleration now.

ttyS0 commented 6 months ago

That's certainly odd, especially since I would expect removing the flag to allow software encoding to ensure that the Video Toolbox encoder would be used.

When you remove the -vt-allow-sw flag does other-transcode use x265 as opposed to hevc_videotoolbox?

And of course, it could still be a source file issue. The only reason I bring that back up is because sometimes weirdness in a source file can cause all kinds of issues that others haven't seem and/or is hard to reproduce.

ravedoglv commented 5 months ago

I was wondering of there were any follow up ideas how to enable hardware acceleration. Also, The source files - i tried some older ones that used to work and they have an issue now. So i think i can rule out the media.

wintervaler commented 5 months ago

Hi there! No idea how much help I can be but let's try a few things, and others may chime in as well.

Let us know how that goes!

ravedoglv commented 5 months ago

ffmpeg -loglevel error -stats -i /Users/ravedog/Desktop/rips/Lone\ Star\ \(1996\)/src/Interview\ with\ Dryburgh\ DP.mkv -map 0:0 -filter:v crop\=1696:1050:180:30 -c:v libx265 -pix_fmt:v yuv420p10le -b:v 4000k -maxrate:v 12000k -bufsize:v 12000k -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v title\= -disposition:v default -tag:v hvc1 -map 0:1 -c:a:0 copy -metadata:s:a:0 title\= -disposition:a:0 default -sn -metadata:g title\= -movflags disable_chpl Interview\ with\ Dryburgh\ DP.mp4

is the ffmpeg command issued without the --vt-allow-sw option

if i remove the --hvec option it transcodes with acceleration, yes: ffmpeg -loglevel error -stats -i /Users/ravedog/Desktop/rips/Lone\ Star\ \(1996\)/src/Interview\ with\ Dryburgh\ DP.mkv -map 0:0 -filter:v crop\=1696:1050:180:30 -c:v h264_videotoolbox -b:v 6000k -allow_sw:v 1 -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v title\= -disposition:v default -map 0:1 -c:a:0 copy -metadata:s:a:0 title\= -disposition:a:0 default -sn -metadata:g title\= -movflags disable_chpl Interview\ with\ Dryburgh\ DP.mp4

if issue the command other-transcode --vt-allow-sw --hevc /Users/ravedog/Desktop/rips/Lone Star (1996)/src/Conversations with Sayles & Sava.mkv without the --mp4 option it errors:

i get an error Error while filtering: Generic error in an external library [out#0/matroska @ 0x7f955bf046c0] Nothing was written into output file, because at least one of its streams received no packets.

So it will work with acceleration if I dont use --hvec and it transcodes with H.264

ttyS0 commented 5 months ago

That is very odd. Does other-transcode not "find" the hevc_videotoolbox encoder? The --hevc option should try (and use) that, but it looks like it's defaulting to software encoding for you for some unexplained reason.

For example:

❯ other-transcode --hevc src/foo.mkv --dry-run
Verifying "ffprobe" availability...
Verifying "ffmpeg" availability...
Verifying "mkvpropedit" availability...
Finding encoders...
Trying "hevc_videotoolbox" video encoder...
Scanning media...
duration = 02:34:26.981
Stream mapping:
 0 = hevc_videotoolbox / 4000 Kbps
 1 = ac3
Command line:
ffmpeg -loglevel error -stats -i src/foo.mkv -map 0:0 -c:v hevc_videotoolbox -b:v 4000k -color_primaries:v bt709 -color_trc:v bt709 -colorspace:v bt709 -metadata:s:v title\= -disposition:v default -map 0:1 -c:a:0 ac3 -metadata:s:a:0 title\= -disposition:a:0 default -sn -metadata:g title\= -default_mode passthrough foo.mkv

In my case, these are the versions I'm using on a Mac Studio: