I wrote a program using C# that downloads an audio file in WebM format from YouTube. Now I don't want to have the entire audio track, just a small section of it. I already found a thread explaining how to transfer the stream in FFmpeg. After this process I want to forward the cropped file to a client. How can I direct the output to a stream after FFmpeg is done?
From the answer of the thread mentioned above, I adapted the following code for myself:
var inputArgs = "-ss 60 -t 10 -i -";
var outputArgs = "-f webm_chunk pipe:.webm";
var process = new Process()
{
StartInfo =
{
FileName = "ffmpeg.exe",
Arguments = $"{inputArgs} {outputArgs}",
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true
}
};
process.Start();
var ffmpegIn = process.StandardInput.BaseStream;
var ffmpegOut = process.StandardOutput.BaseStream;
var ffmpegErr = process.StandardError.BaseStream;
stream.Seek(0,SeekOrigin.Begin);
stream.CopyTo(ffmpegIn);
ffmpegIn.Flush();
ffmpegIn.Close();
process.WaitForExit();
But when I try this way, I get an error:
built with gcc 11.2.0 (crosstool-NG 1.24.0.533_681aaef)
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --disable-avisynth --enable-libdav1d --disable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --disable-frei0r --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librist --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --disable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --disable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --disable-libx264 --disable-libx265 --disable-libxavs2 --disable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20220626
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
Input #0, matroska,webm, from 'pipe:':
Metadata:
encoder : google/video-file
Duration: 00:03:14.16, start: -0.007000, bitrate: N/A
Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Output #0, webm_chunk, to 'pipe:.webm':
Output file #0 does not contain any stream
I found a thread while searching that brought me to the RedirectStandardOutput
option. But I don't understand this error.