![Das Aufteilen des Audios mit ffmpeg und das erneute Kombinieren mit dem Video fügt am Anfang schwarze Frames ein](https://rvso.com/image/1452850/Das%20Aufteilen%20des%20Audios%20mit%20ffmpeg%20und%20das%20erneute%20Kombinieren%20mit%20dem%20Video%20f%C3%BCgt%20am%20Anfang%20schwarze%20Frames%20ein.png)
Ich verwende ffmpeg, um den Ton aus einer Videodatei herauszutrennen, ihn in eine WAV-Datei umzuwandeln und ihn dann wieder mit dem Video zu kombinieren. Wenn ich das mache, hat das neue Video ganz am Anfang schwarze Frames.
Hier sind die Befehle, die ich ausführe:
ffmpeg -i orig.mp4 orig-sound.wav
ffmpeg -i orig.mp4 -i orig-sound.wav -map 0:0 -map 1:0 -vcodec copy new.mp4
Mir ist aufgefallen, dass die schwarzen Rahmen nicht vorhanden sind, wenn ich beim Neukombinieren ein -itsoffset -0,5 hinzufüge, aber ich verstehe nicht, warum das funktioniert oder warum es notwendig ist.
ffmpeg -itsoffset -0.5 -i orig.mp4 -i orig-sound.wav -map 0:0 -map 1:0 -vcodec copy new.mp4
Weitere Informationen: Dies passiert nur bei einigen Videos.
Ausgabe des Befehls „Teilen“
Running command: ffmpeg -i shortvideo.mp4 -y /var/folders/rr/x5blbrq14yj6zwlj5_y2y5gh0000gp/T/11555-44766-13uwbwy.wav
ffmpeg version 2.6.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'shortvideo.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.25.101
Duration: 00:01:15.72, start: 0.072562, bitrate: 171 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 800x600, 40 kb/s, 24.01 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
Output #0, wav, to '/var/folders/rr/x5blbrq14yj6zwlj5_y2y5gh0000gp/T/11555-44766-13uwbwy.wav':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
ISFT : Lavf56.25.101
Stream #0:0(und): Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, stereo, s16, 705 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc56.26.100 pcm_s16le
Stream mapping:
Stream #0:1 -> #0:0 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
size= 6524kB time=00:01:15.74 bitrate= 705.6kbits/s
video:0kB audio:6524kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.001168%
Ausgabe zusammenführen
Running command: ffmpeg -i shortvideo.mp4 -i /var/folders/rr/x5blbrq14yj6zwlj5_y2y5gh0000gp/T/11555-44766-ou67bd.wav -map 0:0 -map 1:0 -vcodec copy -ab 127166 /var/folders/rr/x5blbrq14yj6zwlj5_y2y5gh0000gp/T/11555-44766-1lafn4z.mp4
ffmpeg version 2.6.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
Running command: ffmpeg -i shortvideo.mp4 -y /var/folders/rr/x5blbrq14yj6zwlj5_y2y5gh0000gp/T/11555-44766-13uwbwy.wav
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'shortvideo.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.25.101
Duration: 00:01:15.72, start: 0.072562, bitrate: 171 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 800x600, 40 kb/s, 24.01 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from '/var/folders/rr/x5blbrq14yj6zwlj5_y2y5gh0000gp/T/11555-44766-ou67bd.wav':
Duration: 00:01:15.74, bitrate: 705 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, 2 channels, s16, 705 kb/s
Output #0, mp4, to '/var/folders/rr/x5blbrq14yj6zwlj5_y2y5gh0000gp/T/11555-44766-1lafn4z.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.25.101
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 800x600, q=2-31, 40 kb/s, 24.01 fps, 24 tbr, 12288 tbn, 12288 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1: Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 22050 Hz, stereo, s16, 127 kb/s
Metadata:
encoder : Lavc56.26.100 libvo_aacenc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (libvo_aacenc))
Press [q] to stop, [?] for help
[mp4 @ 0x7fbf0c826e00] Packet with invalid duration -2654 in stream 0164.3kbits/s
frame= 1807 fps=0.0 q=-1.0 Lsize= 1585kB time=00:01:15.76 bitrate= 171.4kbits/s
video:376kB audio:1177kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.046465%
1/1 videos completed...
Success: shortvideo.mp4
Processed 1623247 bytes in 3.064000129699707 seconds, at 0.5297803300547149 MB/sec