FFmpeg错误地连接两个m4a文件(FFmpeg concatenates two m4a files incorrectly)

编程入门 行业动态 更新时间:2024-10-26 23:34:45
FFmpeg错误地连接两个m4a文件(FFmpeg concatenates two m4a files incorrectly)

问题是,当我连接两个m4a文件与concat demuxer时,ffmpeg会产生持续时间不正确的文件。 您可以看到输出文件的持续时间与两个输入文件合并的持续时间非常不同。 请帮我找出它的问题。 我的最终目标是将无声音频附加到音频文件的末尾。 为此,我使用ffmpeg生成无声音频文件,然后尝试将其与其他音频文件连接。

我用来生成音频文件的命令:

ffmpeg -nostdin -loglevel error -y -threads 0 -filter_complex aevalsrc=0 -t 4 /home/ec2-user/videocreation/temp/silence.m4a

我用于concat的命令如下:

ffmpeg -f concat -safe 0 -i temp.txt -c copy output.m4a

我在temp.txt中列出了两个文件路径:

[ec2-user@ip-10-0-1-126 server]$ cat temp.txt file /home/ec2-user/videoData/DnXptC4ld8/FADING_OUT_VOLUP_Blrt_Decrypt_1ed5c4d569d8a1f23428b65217f65eaf_audio.m4a file /home/ec2-user/videocreation/temp/silence.m4a

第一个文件ffprobe:

[ec2-user@ip-10-0-1-126 server]$ ffprobe /home/ec2-user/videoData/DnXptC4ld8/FADING_OUT_VOLUP_Blrt_Decrypt_1ed5c4d569d8a1f23428b65217f65eaf_audio.m4a ffprobe version N-80097-g89e9393 Copyright (c) 2007-2016 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4) configuration: --prefix=/home/ec2-user/ffmpeg_build --extra-cflags=-I/home/ec2-user/ffmpeg_build/include --extra-ldflags=-L/home/ec2-user/ffmpeg_build/lib --bindir=/home/ec2-user/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 55. 24.100 / 55. 24.100 libavcodec 57. 43.100 / 57. 43.100 libavformat 57. 37.100 / 57. 37.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 46.100 / 6. 46.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/ec2-user/videoData/DnXptC4ld8/FADING_OUT_VOLUP_Blrt_Decrypt_1ed5c4d569d8a1f23428b65217f65eaf_audio.m4a': Metadata: major_brand : M4A minor_version : 512 compatible_brands: isomiso2 encoder : Lavf57.44.100 Duration: 00:00:01.77, start: 0.000000, bitrate: 4 kb/s Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 11025 Hz, mono, fltp, 0 kb/s (default) Metadata: handler_name : SoundHandler

第二个文件ffprobe:

[ec2-user@ip-10-0-1-126 server]$ ffprobe /home/ec2-user/videocreation/temp/silence.m4a ffprobe version N-80097-g89e9393 Copyright (c) 2007-2016 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4) configuration: --prefix=/home/ec2-user/ffmpeg_build --extra-cflags=-I/home/ec2-user/ffmpeg_build/include --extra-ldflags=-L/home/ec2-user/ffmpeg_build/lib --bindir=/home/ec2-user/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 55. 24.100 / 55. 24.100 libavcodec 57. 43.100 / 57. 43.100 libavformat 57. 37.100 / 57. 37.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 46.100 / 6. 46.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/ec2-user/videocreation/temp/silence.m4a': Metadata: major_brand : M4A minor_version : 512 compatible_brands: isomiso2 encoder : Lavf57.44.100 Duration: 00:00:04.02, start: 0.000000, bitrate: 4 kb/s Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 1 kb/s (default) Metadata: handler_name : SoundHandler

输出文件ffprobe:

[ec2-user@ip-10-0-1-126 server]$ ffprobe output.m4a ffprobe version N-80097-g89e9393 Copyright (c) 2007-2016 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4) configuration: --prefix=/home/ec2-user/ffmpeg_build --extra-cflags=-I/home/ec2-user/ffmpeg_build/include --extra-ldflags=-L/home/ec2-user/ffmpeg_build/lib --bindir=/home/ec2-user/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 55. 24.100 / 55. 24.100 libavcodec 57. 43.100 / 57. 43.100 libavformat 57. 37.100 / 57. 37.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 46.100 / 6. 46.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.m4a': Metadata: major_brand : M4A minor_version : 512 compatible_brands: isomiso2 encoder : Lavf57.37.100 Duration: 00:00:23.22, start: 0.000000, bitrate: 0 kb/s Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 11025 Hz, mono, fltp, 0 kb/s (default) Metadata: handler_name : SoundHandler

Problem is, when i concatenate two m4a files with concat demuxer, ffmpeg produces files whose duration is incorrect. You can see that the duration of output file is very different from the duration of two input files combined. Please help me spot the issue in it. My ultimate goal is to append silent audio to the end of the audio file. For that, i generate silent audio file with ffmpeg and then try to concat it with other audio file.

Command I used to generate audio file:

ffmpeg -nostdin -loglevel error -y -threads 0 -filter_complex aevalsrc=0 -t 4 /home/ec2-user/videocreation/temp/silence.m4a

Command I used for concat:

ffmpeg -f concat -safe 0 -i temp.txt -c copy output.m4a

I have two file paths listed in temp.txt:

[ec2-user@ip-10-0-1-126 server]$ cat temp.txt file /home/ec2-user/videoData/DnXptC4ld8/FADING_OUT_VOLUP_Blrt_Decrypt_1ed5c4d569d8a1f23428b65217f65eaf_audio.m4a file /home/ec2-user/videocreation/temp/silence.m4a

First file ffprobe:

[ec2-user@ip-10-0-1-126 server]$ ffprobe /home/ec2-user/videoData/DnXptC4ld8/FADING_OUT_VOLUP_Blrt_Decrypt_1ed5c4d569d8a1f23428b65217f65eaf_audio.m4a ffprobe version N-80097-g89e9393 Copyright (c) 2007-2016 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4) configuration: --prefix=/home/ec2-user/ffmpeg_build --extra-cflags=-I/home/ec2-user/ffmpeg_build/include --extra-ldflags=-L/home/ec2-user/ffmpeg_build/lib --bindir=/home/ec2-user/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 55. 24.100 / 55. 24.100 libavcodec 57. 43.100 / 57. 43.100 libavformat 57. 37.100 / 57. 37.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 46.100 / 6. 46.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/ec2-user/videoData/DnXptC4ld8/FADING_OUT_VOLUP_Blrt_Decrypt_1ed5c4d569d8a1f23428b65217f65eaf_audio.m4a': Metadata: major_brand : M4A minor_version : 512 compatible_brands: isomiso2 encoder : Lavf57.44.100 Duration: 00:00:01.77, start: 0.000000, bitrate: 4 kb/s Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 11025 Hz, mono, fltp, 0 kb/s (default) Metadata: handler_name : SoundHandler

Second file ffprobe:

[ec2-user@ip-10-0-1-126 server]$ ffprobe /home/ec2-user/videocreation/temp/silence.m4a ffprobe version N-80097-g89e9393 Copyright (c) 2007-2016 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4) configuration: --prefix=/home/ec2-user/ffmpeg_build --extra-cflags=-I/home/ec2-user/ffmpeg_build/include --extra-ldflags=-L/home/ec2-user/ffmpeg_build/lib --bindir=/home/ec2-user/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 55. 24.100 / 55. 24.100 libavcodec 57. 43.100 / 57. 43.100 libavformat 57. 37.100 / 57. 37.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 46.100 / 6. 46.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/ec2-user/videocreation/temp/silence.m4a': Metadata: major_brand : M4A minor_version : 512 compatible_brands: isomiso2 encoder : Lavf57.44.100 Duration: 00:00:04.02, start: 0.000000, bitrate: 4 kb/s Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 1 kb/s (default) Metadata: handler_name : SoundHandler

Output file ffprobe:

[ec2-user@ip-10-0-1-126 server]$ ffprobe output.m4a ffprobe version N-80097-g89e9393 Copyright (c) 2007-2016 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4) configuration: --prefix=/home/ec2-user/ffmpeg_build --extra-cflags=-I/home/ec2-user/ffmpeg_build/include --extra-ldflags=-L/home/ec2-user/ffmpeg_build/lib --bindir=/home/ec2-user/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 55. 24.100 / 55. 24.100 libavcodec 57. 43.100 / 57. 43.100 libavformat 57. 37.100 / 57. 37.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 46.100 / 6. 46.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.m4a': Metadata: major_brand : M4A minor_version : 512 compatible_brands: isomiso2 encoder : Lavf57.37.100 Duration: 00:00:23.22, start: 0.000000, bitrate: 0 kb/s Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 11025 Hz, mono, fltp, 0 kb/s (default) Metadata: handler_name : SoundHandler

最满意答案

文件需要具有相同的属性。 您的无声文件具有不同的采样率。 使用

ffmpeg -f lavfi -i anullsrc -ar 11025 -ac 1 -t 4 silence.m4a

Files need to have the same properties. Your silence file has a different sampling rate. Use

ffmpeg -f lavfi -i anullsrc -ar 11025 -ac 1 -t 4 silence.m4a

更多推荐

本文发布于:2023-08-01 19:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1363629.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   两个   文件   FFmpeg   m4a

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!