連接調整音量的影片時出現問題

連接調整音量的影片時出現問題

我拍攝了許多視頻剪輯並使用 ffmpeg 調整了它們的音量,然後嘗試連接它們(使用 ffmpeg),但是雖然我可以觀看單獨調整的音量剪輯文件並聽到調整後的音量,但最終的連接版本包含視頻但沒有音訊。

我用來調整音量的命令是:

> ffmpeg -y -i "E:/_Videos/Test/snippet.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts "E:/_Videos/Test/snippet.ts"


> ffmpeg -y -i "E:/_Videos/Test/snippet.ts" -vol 409 -vcodec copy  "E:/_Videos/Test/snippet_v1.6.ts"

我使用 concat 的命令是:

> ffmpeg -y -progress progressinfo.dat -f concat -safe 0 -i "E:/_Videos/Test/concat.txt" -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1:color=black" "E:/_Videos/Test/_MERGED.mp4"

其輸出如下,但列出了多個與此類似的錯誤...

[aac @ 00000284490f6580] More than one AAC RDB per ADTS frame is not implemented. 
Update your FFmpeg version to the newest one from Git. If the problem still occurs, 
it means that your file has a feature which has not been implemented.

[aac @ 00000284490f6580] channel element 3.11 is not allocated
Error while decoding stream #0:1: Invalid data found when processing input

完整輸出....

ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200523
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --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-libx

ml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  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
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, concat, from 'E:/_Videos/Test/concat.txt':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1(und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 136 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 00000284495c5c40] using SAR=1/1
[libx264 @ 00000284495c5c40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000284495c5c40] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 00000284495c5c40] 264 - core 160 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - 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=9 lookahead_threads=1 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
Output #0, mp4, to 'E:/_Videos/Test/_MERGED.mp4':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.54.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.54.100 aac
[aac @ 00000284490f6580] More than one AAC RDB per ADTS frame is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[aac @ 00000284490f6580] channel element 3.11 is not allocated
Error while decoding stream #0:1: Invalid data found when processing input
[aac @ 00000284490f6580] channel element 3.11 is not allocated
Error while decoding stream #0:1: Invalid data found when processing input
[aac @ 00000284490f6580] channel element 3.11 is not allocated
.
.
.

我嘗試了幾種不同的方法來調整音量,並且在版本 4.2.3 和最新的 4.4.1 上嘗試過,但都失敗並出現相同的錯誤。 (我使用的是 Windows 10)

(在不調整音量的情況下連接原始 .ts 檔案可以正常運作)。

我做錯了什麼(在將 mp4 連接回其他 mp4 之前如何調整 mp4 的音量)?

答案1

因此,解決方案(如 Rotem [在上面的評論中非常感謝 Rotem] 給出的)似乎如 Rotem 所說,但添加了一些使用“-async 1”來阻止聲音與視頻。

我使用的全套命令如下:

// process the first clip (from a 640x480 30frames/s video)....

// Pull out a snippet from clip1.mp4 (39.51 seconds to 43.701 seconds...
ffmpeg -y -i "E:/_Videos/Test/clip1.mp4" -ss 39.51 -to 43.701 -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1:color=black" "E:/_Videos/Test/tmp/f1.mp4" 2>&1

// Create synthetic video with stereo audio...
ffmpeg -y -f lavfi -i testsrc=size=192x108:rate=25 -f lavfi -i sine=frequency=400 -f lavfi -i sine=frequency=1000 -filter_complex "[1:a][2:a]amix=inputs=2" -vcodec libx264 -crf 17 -pix_fmt yuv420p -acodec aac -ar 44100 -t 10  "E:/_Videos/Test/tmp/f1.ts" 2>&1

// Execute conversion to TS
ffmpeg -y -i "E:/_Videos/Test/tmp/f1.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts  "E:/_Videos/Test/tmp/f1.ts" 2>&1

// Set the volume...
ffmpeg -y -i "E:/_Videos/Test/tmp/f1.ts" -vol 25 -vcodec copy -acodec aac -async 1  "E:/_Videos/Test/tmp/f1_v0.1.ts" 2>&1

 
// now do the same for the next clip (with no volume adjust)...
// (a 1280x720 25frames/s video)...
ffmpeg -y -i "E:/_Videos/Test/clip2.mp4" -ss 0 -to 5.05 -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1:color=black" "E:/_Videos/Test/tmp/f2.mp4" 2>&1
ffmpeg -y -f lavfi -i testsrc=size=192x108:rate=25 -f lavfi -i sine=frequency=400 -f lavfi -i sine=frequency=1000 -filter_complex "[1:a][2:a]amix=inputs=2" -vcodec libx264 -crf 17 -pix_fmt yuv420p -acodec aac -ar 44100 -t 10  "E:/_Videos/Test/tmp/f2.ts" 2>&1
ffmpeg -y -i "E:/_Videos/Test/tmp/f2.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts  "E:/_Videos/Test/tmp/f2.ts" 2>&1

 

// and the same for the next clip (with volume adjusted down)...
// (a 1280x720 25frames/s video)...
ffmpeg -y -i "E:/_Videos/Test/clip2.mp4" -ss 0 -to 5.05 -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1:color=black" "E:/_Videos/Test/tmp/f3.mp4" 2>&1
ffmpeg -y -f lavfi -i testsrc=size=192x108:rate=25 -f lavfi -i sine=frequency=400 -f lavfi -i sine=frequency=1000 -filter_complex "[1:a][2:a]amix=inputs=2" -vcodec libx264 -crf 17 -pix_fmt yuv420p -acodec aac -ar 44100 -t 10  "E:/_Videos/Test/tmp/f3.ts" 2>&1
ffmpeg -y -i "E:/_Videos/Test/tmp/f3.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts  "E:/_Videos/Test/tmp/f3.ts" 2>&1
ffmpeg -y -i "E:/_Videos/Test/tmp/f3.ts" -vol 76 -vcodec copy -acodec aac -async 1  "E:/_Videos/Test/tmp/f3_v0.3.ts" 2>&1

 

// and the same for the next clip (with volume adjusted up)...
// (a 1280x720 25frames/s video)...
ffmpeg -y -i "E:/_Videos/Test/clip2.mp4" -ss 0 -to 5.05 -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1:color=black" "E:/_Videos/Test/tmp/f4.mp4" 2>&1
ffmpeg -y -f lavfi -i testsrc=size=192x108:rate=25 -f lavfi -i sine=frequency=400 -f lavfi -i sine=frequency=1000 -filter_complex "[1:a][2:a]amix=inputs=2" -vcodec libx264 -crf 17 -pix_fmt yuv420p -acodec aac -ar 44100 -t 10  "E:/_Videos/Test/tmp/f4.ts" 2>&1
ffmpeg -y -i "E:/_Videos/Test/tmp/f4.mp4" -c copy -bsf:v h264_mp4toannexb -f mpegts  "E:/_Videos/Test/tmp/f4.ts" 2>&1
ffmpeg -y -i "E:/_Videos/Test/tmp/f4.ts" -vol 409 -vcodec copy -acodec aac -async 1  "E:/_Videos/Test/tmp/f4_v1.6.ts" 2>&1


// then create a concat.txt file with the following contents
file 'f1_v0.1.ts'
file 'f2.ts'
file 'f3_v0.3.ts'
file 'f4_v1.6.ts'


// concatenate the listed files into the final _MERGED.mp4 file.
ffmpeg -y -progress progressinfo.dat -f concat -safe 0 -i "E:/_Videos/Test/tmp/concat.txt" -vf  "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:-1:-1:color=black"  "E:/_Videos/Test/_MERGED.mp4" 2>&1

(我想現在沒有人知道如何在第一個和第二個剪輯之間進行交叉淡入淡出?)

謝謝

相關內容