Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
I am trying to append the video segments to an existing video segment file, so that multiple videos can be streamed at once. How to achieve it ?
14 février, par Prafulla NayakHere is what I do:
- Fetch the existing m3u8 file
- Generate the segments to the new video file.
- fetch old segments from the m3u8 file and combine the new segments details. and then add it in between under "mergedSegments" as mentioned below.
#EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:${newMediaSequence} #EXT-X-PLAYLIST-TYPE:VOD ${mergedSegments} #EXT-X-ENDLIST
While doing so, everything works fine. But when I play it, The 1st video gets played without skipping any segments. But afterwords, few segments are getting skipped.
Why it that? Is there any other effective way to do this?
ffmpeg(tempFilePath) .outputOptions([ '-codec:v libx264', '-codec:a aac', '-map 0', '-f segment', '-segment_time 10', '-reset_timestamps 1' ]) .output(m3u8FilePath) .outputOptions([ `-start_number ${startNumber}`, // Sets the starting number for the HLS segments. '-hls_time 10', // Duration of each HLS segment in seconds. '-hls_list_size 0', // Ensures all segments are included in the playlist. '-hls_playlist_type vod', // Designates the playlist as VOD and includes the EXT-X-ENDLIST tag. '-f hls', // Specifies the output format as HLS (HTTP Live Streaming). ]) .on('end', async () => { fs.unlinkSync(tempFilePath); // Remove the temporary file const segmentFiles = fs.readdirSync(outputDir); const uploadPromises = segmentFiles.map((file) => { // if the file is a m3u8 file, update the content with the new segments if (file.endsWith(".m3u8") && doc.exists && existingSegmentUrls.length > 0) { const m3u8ContentPath = path.join(outputDir, file); const newContent = fs.readFileSync(m3u8ContentPath, "utf8"); const oldSegments = m3u8Content.match(/#EXTINF:[\d.]+,\n[^\n]+/g); const newSegments = newContent.match(/#EXTINF:[\d.]+,\n[^\n]+/g); const newMediaSequence = oldSegments.length; //log both old and new segments //log newcontent console.log("------newContent------",newContent); console.log("old",oldSegments); console.log("new",newSegments); const mergedSegments = [...oldSegments, ...newSegments].join( "\n" ); console.log("merged",mergedSegments); const mergedM3u8Content = `#EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:${newMediaSequence} #EXT-X-PLAYLIST-TYPE:VOD ${mergedSegments} #EXT-X-ENDLIST
-
How to extract the 1st frame and restore as an image with ffmpeg ? [closed]
14 février, par lexAnyone knows the trick?
And how to install ffmpeg ?
yum install mpeg
only returns this:======================================================================================== Matched: mpeg ======================================================================================== libiec61883.i386 : Streaming library for IEEE1394 libiec61883.x86_64 : Streaming library for IEEE1394 qffmpeg-devel.i386 : Development package for qffmpeg qffmpeg-devel.x86_64 : Development package for qffmpeg qffmpeg-libs.i386 : Libraries for qffmpeg qffmpeg-libs.x86_64 : Libraries for qffmpeg
-
Using swr_convert to resample audio frames resulted in audio with significant noise [closed]
14 février, par Bruce HuI attempted to use swr_convert to resample audio frames from 44100 Hz to 16000 Hz, processing the frames one by one for testing purposes. However, the resulting audio appears to be mixed with noise.
The following code shows how I resample a single audio frame:
AVFrame* output_frame = av_frame_alloc(); if (!output_frame) { throw std::runtime_error("Failed to allocate output AVFrame"); } AVRational output_time_base = {1, output_sample_rate}; SwrContext* swr_ctx = swr_alloc(); if (!swr_ctx) { av_frame_free(&output_frame); throw std::runtime_error("Failed to allocate SwrContext"); } av_opt_set_int(swr_ctx, "in_sample_fmt", aframe->format, 0); av_opt_set_int(swr_ctx, "out_sample_fmt", output_format, 0); av_opt_set_int(swr_ctx, "in_channel_layout", aframe->channel_layout, 0); av_opt_set_int(swr_ctx, "out_channel_layout", output_channel_layout, 0); av_opt_set_int(swr_ctx, "in_sample_rate", aframe->sample_rate, 0); av_opt_set_int(swr_ctx, "out_sample_rate", output_sample_rate, 0); if (swr_init(swr_ctx) < 0) { swr_free(&swr_ctx); av_frame_free(&output_frame); throw std::runtime_error("Failed to initialize SwrContext"); } output_frame->format = output_format; output_frame->channel_layout = output_channel_layout; output_frame->sample_rate = output_sample_rate; int64_t delay = swr_get_delay(swr_ctx, aframe->sample_rate); output_frame->nb_samples = av_rescale_rnd( delay + aframe->nb_samples, output_sample_rate, aframe->sample_rate, AV_ROUND_UP); output_frame->nb_samples = av_rescale_rnd( aframe->nb_samples, output_sample_rate, aframe->sample_rate, AV_ROUND_UP); if (av_frame_get_buffer(output_frame, 0) < 0) { swr_free(&swr_ctx); av_frame_free(&output_frame); throw std::runtime_error("Failed to allocate buffer for output AVFrame"); } int ret = swr_convert(swr_ctx, output_frame->data, output_frame->nb_samples, (const uint8_t**)aframe->data, aframe->nb_samples); if (ret < 0) { swr_free(&swr_ctx); av_frame_free(&output_frame); throw std::runtime_error("Failed to resample audio data"); } if (aframe->pts != AV_NOPTS_VALUE) { output_frame->pts = av_rescale_q(aframe->pts, {1, aframe->sample_rate}, output_time_base); } else { output_frame->pts = AV_NOPTS_VALUE; }
-
What tool can I use to analyze audio and clip webm files ? [closed]
14 février, par Phillip FeldmanI have a bunch of 2-3 hour long podcast webms from Youtube. I want to extract the audio from them, and programmatically analyze things like volume, or who's speaking. I then want to use my analysis to clip the original webms. What tools can I use to do this, and is size of the audio files something that I need to consider? I know python and have used ffmpeg.
-
Eleven Labs API not working, is ffmpeg not installed properly ?
13 février, par Daniel Masso PardoTraceback (most recent call last): File "C:\Users\danim\OneDrive\Desktop\programming\APItests.py", line 9, in
play(audio) File "C:\Users\danim\PycharmProjects\EXAM\venv\lib\site-packages\elevenlabs\utils.py", line 25, in play raise ValueError(message) ValueError: ffplay from ffmpeg not found, necessary to play audio. On mac you can install it with 'brew install ffmpeg'. On linux and windows you can install it from https://ffmpeg.org/ I keep getting this error, and yes, I've gone to the web site and installed, made a path "C:\Users(my name)\ffmpeg\bin" and exported it there, but it doesn't work.
I'm expecting to get the result as audio from the free Eleven Labs API, but I keep getting these issues.