I am trying to write an audio file to an existing videofile. Unfortunately I get the Logmessage, that I cannot edit existing files in-place.
I have found some threads about the so called muxing between video and audio, but none of them could help me out really. Maybe some one of you can. Further this isn`t my could either. I am only the one who needs to use it, so I have to fix it.
Thanks for your help
String[] args = { FFMPEG_FILE.getAbsolutePath(), "-y", "-i", videoPath, "-ss", String.valueOf(-offset.toFrames() / 50.0f), "-i", audioPath, "-c", "copy", "-map", "0:v", "-map","1:a", "-bsf:v", "h264_mp4toannexb","-r", String.valueOf(project.getFramerate()), "-shortest",outputPath };
ProcessBuilder pb = new ProcessBuilder(args).inheritIO();
Process p = pb.start();
int exit = p.waitFor();
if (exit != 0) {
throw new IOException("ffmpeg terminated with a failure");
}
EDIT: As someone commented outputPath was same same as videopath. So switched it to another, so this problem would not appear again. But I still have no sound in my outputvideos. I give you the LOG-information, so maybe you can read something out of it.
INFO: start ffmpeg: [C:\Program Files\ffmpeg\bin\ffmpeg.exe, -y, -i, C:\Users\USERNAME\Desktop\Test_Workflow\1.mkv, -ss, 0.0, -i, C:\Users\USERNAME\Desktop\Test\resources/videos/P1000501.MP4\audio.ogg, -c, copy, -map, 0:v, -map, 1:a, -bsf:v, h264_mp4toannexb, -r, 25, -shortest, C:\Users\USERNAME\Desktop\Test\testoutput.mp4]
ffmpeg version N-92087-gdcbd89e000 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20180813
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --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-libxml2 --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
libavutil 56. 19.101 / 56. 19.101
libavcodec 58. 31.102 / 58. 31.102
libavformat 58. 18.104 / 58. 18.104
libavdevice 58. 4.105 / 58. 4.105
libavfilter 7. 33.100 / 7. 33.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Input #0, matroska,webm, from 'C:\Users\USERNAME\Desktop\Test_Workflow\1.mkv':
Metadata:
ENCODER : Lavf56.4.101
Duration: 00:00:04.60, start: 0.080000, bitrate: 1377 kb/s
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Input #1, ogg, from 'C:\Users\USERNAME\Desktop\Test\resources/videos/P1000501.MP4\audio.ogg':
Duration: 00:04:20.65, start: 0.000000, bitrate: 86 kb/s
Stream #1:0(und): Audio: vorbis, 48000 Hz, stereo, fltp, 112 kb/s
Metadata:
CREATION_TIME : 2018-11-09T13:20:07.000000Z
LANGUAGE : und
ENCODER : Lavc58.31.102 libvorbis
MAJOR_BRAND : mp42
MINOR_VERSION : 1
COMPATIBLE_BRANDS: mp42avc1
[mp4 @ 000001e67c0a00c0] track 1: codec frame size is not set
Output #0, mp4, to 'C:\Users\USERNAME\Desktop\Test\testoutput.mp4':
Metadata:
encoder : Lavf58.18.104
Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
Stream #0:1(und): Audio: vorbis (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 112 kb/s
Metadata:
CREATION_TIME : 2018-11-09T13:20:07.000000Z
LANGUAGE : und
ENCODER : Lavc58.31.102 libvorbis
MAJOR_BRAND : mp42
MINOR_VERSION : 1
COMPATIBLE_BRANDS: mp42avc1
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 113 fps=0.0 q=-1.0 Lsize= 824kB time=00:00:04.41 bitrate=1530.8kbits/s speed= 634x
video:772kB audio:43kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 1.092082%
videoPath
andoutputPath
? It seems they're same, butffmpeg
can't overwrite (edit in-place) a file used as input.