master-of-zen / Av1an

Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding
GNU General Public License v3.0
1.52k stars 156 forks source link

Failed to encode audio #677

Open JGSphaela opened 2 years ago

JGSphaela commented 2 years ago

Hi, I'm running av1an on Windows 11. The video encode just fine but every time I get a warning like this and there's not sound in the encoded video.

WARN [av1an_core::ffmpeg] FFmpeg failed to encode audio!
Output {
    status: ExitStatus(
        ExitStatus(
            1,
        ),
    ),
    stdout: "",
    stderr: "[mov,mp4,m4a,3gp,3g2,mj2 @ 0000015209de6740] Referenced QT chapter track not found\r\n[matroska @ 0000015209e9ea80] Only audio, video, and subtitles are supported for Matroska.\r\nCould not write header for output file #0 (incorrect codec parameters ?): Invalid argument\r\nError initializing output stream 0:1 -- \r\n\r\n",
}
Params: "ffmpeg" "-y" "-hide_banner" "-loglevel" "error" "-i" "test.MOV" "-map_metadata" "0" "-vn" "-map" "0" "-map" "-0:a" "-c" "copy" "-map" "0:a" "-c:a" "copy" ".2f9997b\\audio.mkv"

I tried both using libopus and not using any audio encoder, and the error message is the same. Code I use is av1an -i test.MOV --sc-pix-format=yuv420p -e svt-av1 -v "--keyint 300 --crf 45 --preset 6 --tune 0 --film-grain 8" -o 1.mkv

Thanks in advance!

JGSphaela commented 2 years ago

Error message when using opus is the following:

WARN [av1an_core::ffmpeg] FFmpeg failed to encode audio!
Output {
    status: ExitStatus(
        ExitStatus(
            1,
        ),
    ),
    stdout: "",
    stderr: "[mov,mp4,m4a,3gp,3g2,mj2 @ 0000020bb7a7ea00] Referenced QT chapter track not found\r\n[matroska @ 0000020bb88ef440] Only audio, video, and subtitles are supported for Matroska.\r\nCould not write header for output file #0 (incorrect codec parameters ?): Invalid argument\r\nError initializing output stream 0:1 -- \r\n",
}
Params: "ffmpeg" "-y" "-hide_banner" "-loglevel" "error" "-i" "test.MOV" "-map_metadata" "0" "-vn" "-map" "0" "-map" "-0:a" "-c" "copy" "-map" "0:a" "-c:a" "libopus" "-ac" "2" "-b:a" "192k" ".2f9997b\\audio.mkv"
lastrosade commented 2 years ago

You could try -a ' -dn ' ? or -a ' -map 0:a:0 -c:a copy '

It's couuld be due to some data stream.

Also, could you please post what ffprobe returns on your source file ?

JGSphaela commented 2 years ago

Hi, lastrosade! the-a " dn "worked!! The-a " -map 0:a:0 -c:a copy " however did not work and spit our the error below:

WARN [av1an_core::ffmpeg] FFmpeg failed to encode audio!
Output {
    status: ExitStatus(
        ExitStatus(
            1,
        ),
    ),
    stdout: "",
    stderr: "[mov,mp4,m4a,3gp,3g2,mj2 @ 000001631ed33680] Referenced QT chapter track not found\r\n[matroska @ 000001631ed50680] Only audio, video, and subtitles are supported for Matroska.\r\nCould not write header for output file #0 (incorrect codec parameters ?): Invalid argument\r\nError initializing output stream 0:2 -- \r\n\r\n",
}
Params: "ffmpeg" "-y" "-hide_banner" "-loglevel" "error" "-i" "test.MOV" "-map_metadata" "0" "-vn" "-map" "0" "-map" "-0:a" "-c" "copy" "-map" "0:a" "-map" "0:a:0" "-c:a" "copy" ".2f9997b\\audio.mkv"

ffprobe of the source file is as below:

ffprobe -i test.mov
ffprobe version 5.1.2-full_build-www.gyan.dev Copyright (c) 2007-2022 the FFmpeg developers
  built with gcc 12.1.0 (Rev2, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000013c85ea0240] st: 0 edit list: 1 Missing key frame while searching for timestamp: 3003
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000013c85ea0240] st: 0 edit list 1 Cannot find an index entry before timestamp: 3003.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000013c85ea0240] Referenced QT chapter track not found
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 537986816
    compatible_brands: qt
    creation_time   : 2019-04-20T16:44:36.000000Z
  Duration: 00:00:22.02, start: 0.000000, bitrate: 52087 kb/s
  Stream #0:0[0x1](jpn): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 50310 kb/s, 59.94 fps, 59.94 tbr, 180k tbn (default)
    Metadata:
      creation_time   : 2019-04-20T16:44:36.000000Z
      vendor_id       : [0][0][0][0]
      timecode        : 05:14:55;14
  Stream #0:1[0x2](jpn): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, 2 channels, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2019-04-20T16:44:36.000000Z
      vendor_id       : [0][0][0][0]
      timecode        : 05:14:55;14
  Stream #0:2[0x3](jpn): Data: none (tmcd / 0x64636D74), 1 kb/s (default)
    Metadata:
      creation_time   : 2019-04-20T16:44:36.000000Z
      timecode        : 05:14:55;14
Unsupported codec with id 0 for input stream 2

This file is directly from my camera(Olympus EM-5 mark ii).

lastrosade commented 2 years ago

Oh yeah steam 2 is a datastream, using -dn tells ffmpeg to not bother with it This is probably camera timing info in some proprietary format