在流 #1 中找不到编解码器 pcm_s16le 的标签,容器中当前不支持编解码器

在流 #1 中找不到编解码器 pcm_s16le 的标签,容器中当前不支持编解码器

我有一个非常旧的 .AVI 文件,正在尝试使用 FFMPEG 将其转换为 MP4 格式

这是我当前尝试转换的命令:

ffmpeg -i aVideo.avi -s 1980x1080 -c:a copy aNewVideo.mp4

我正在使用版本ffmpeg version 4.2.4-1ubuntu0.1

编辑

这是我创建的 sh 脚本,它让我可以轻松转换视频,以便与我的好友分享。这不是我最好的作品……我是一名 JS 开发人员 :O

hutber@hutber:/mnt/users/Downloads/Old$ sd
Select Resolution:
1) 1280x720
2) 1980x1080
#? 1
/mnt/users/Downloads/Old/1011 Random Goal 1.avi
/mnt/users/Downloads/Old/02.12.2021/1011 Random Goal 1.avi_02.12.2021_00.31_SD.mp4
ffmpeg -i /mnt/users/Downloads/Old/1011 Random Goal 1.avi -s 1280x720 -c:a copy /mnt/users/Downloads/Old/02.12.2021/1011 Random Goal 1.avi_02.12.2021_00.31_SD.mp4
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-liblensfun --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, avi, from '/mnt/users/Downloads/Old/1011 Random Goal 1.avi':
  Duration: 00:01:09.72, start: 0.000000, bitrate: 30356 kb/s
    Stream #0:0: Video: dvvideo (dvsd / 0x64737664), yuv420p, 720x576 [SAR 16:15 DAR 4:3], 28816 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (dvvideo (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[libx264 @ 0x562e372efc40] using SAR=3/4
[libx264 @ 0x562e372efc40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x562e372efc40] profile High, level 3.1
[libx264 @ 0x562e372efc40] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x562e372ee600] Could not find tag for codec pcm_s16le in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 -- 
Conversion failed!

脚本如下:

hutber@hutber:/mnt/users/Downloads/Old$ cat /mnt/googledrive/Documents/sh/sd.sh
#!/bin/bash

simpleCopy(){    
    printf "Select Resolution:\n"
    select answer in "1280x720" "1980x1080"
    do
        break;
    done
}
simpleCopy

file=$(zenity --file-selection)
currentDateTime=$(date +'%m.%d.%Y_%H.%M')
currentDate=$(date +'%m.%d.%Y')
safeVideoName="${file/ /_}"
safeVideoName="${file/.mp4/}"
safeVideoName="${file/.mp4/}"
filename=${safeVideoName##*/}

fullpath="${safeVideoName%/*}/$currentDate"
videoName="${fullpath}/${filename}_${currentDateTime}_SD.mp4"
echo $file
echo $videoName
mkdir -p $fullpath
echo "ffmpeg -i "$file" -s "$answer" -c:a copy "$videoName""
ffmpeg -i "$file" -s "$answer" -c:a copy "$videoName"

答案1

看来 FFmpeg 不愿意将以下输入音频流放入 mp4 容器中,正如您所请求的-c:a copy

 Stream #0:1: Audio: pcm_s16le

一个简单的解决方法是简单地将 pcm_s16le 流转换为 FFmpeg很高兴将其放置在这样的容器中。一个不错的选择是使用 FFmpeg 原生 AAC 编码器,具体操作如下:

ffmpeg -i aVideo.avi -s 1980x1080 -c:a aac -b:a 128k aNewVideo.mp4

对于 AAC 来说,更好的选择实际上是使用带有 FFmpeg 的 Fraunhofer FDK AAC(libfdk_aac)编码器,但需要进行一些实际操作(编译)才能实现这一点,您会对原生 AAC 编码器的质量感到非常满意。

也许您也可以为视频编码提供一些特定选项?默认值非常合理,但您可能更喜欢以下选项:

ffmpeg -i aVideo.avi -vf scale=1980:-2 \
       -c:v libx264 -preset slow -crf 22 \
       -c:a aac -b:a 128k \
       aNewVideo.mp4

然后尝试所有这些选项来找到输出视频的最佳质量与尺寸......

相关内容