音量を調整したビデオを連結する際の問題

音量を調整したビデオを連結する際の問題

いくつかのビデオ クリップを 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 の音量を調整するにはどうすればいいですか)?

答え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

(最初のクリップと 2 番目のクリップの間でクロスフェードを行う方法を知っている人はいないのではないでしょうか?)

ありがとう

関連情報