ffmpeg 相关问题

只讨论有关FFmpeg库,API或工具的编程使用的问题。应在超级用户或视频制作上询问有关交互式使用命令行工具的问题。 FFmpeg是一个免费的开源项目,可以生成用于处理多媒体数据的库和程序。

如何挽救巨大的、可能已损坏的 AIFF 文件?

由于 Sound Track Pro 故障,我的 AIF 文件有问题。 它在 QuickTime Player 中播放良好,长度约为 1 小时 50 分钟。 然而: 它的大小为 3.81GB,而(我相信)AIF 文件是

回答 2 投票 0

使用 FFMPEG 一次应用多个过滤器

我需要对视频应用淡入和叠加滤镜。是否可以同时应用 2 个过滤器? 我得到: ffmpeg -i input.mpg -vf "movie=watermark.png [标志]; [in][标志] 覆盖=W-w-1...

回答 2 投票 0

Ffmpeg 没有设置正确的变量名称,因此抛出 Unable to select format

我正在尝试自动将字幕添加到包含一些视频的文件夹中,因此我编写了以下脚本: forfiles /p "C:\Users itos\Resilio_Sync K_Video_Downloader ideoprocess" /m *....

回答 1 投票 0

将音频与ffmpeg叠加在一起并循环播放3分钟

我正在尝试在 Flutter 中使用 ffmpeg 将两个音频文件叠加在一起并循环播放 3 分钟。现在我有这个命令 -i $路径1 -i $路径2 -filter_complex \" [0]一个...

回答 1 投票 0

cv2.VideoWriter 使用编解码器 h.265

我正在开发一个代码来保存网络摄像头的视频,我需要使用 4 个不同的编解码器保存相同的视频,但我无法保存在 h.265 中,我收到以下错误: [错误:[email protected]] 全局 cap_ffmpeg_im...

回答 1 投票 0

ffmpeg - 从其中一个音频流中删除前几秒

我有一个包含多个音频和字幕流的 .mkv 文件。 其中一个流的音频不同步,我想将其移动 10 秒,我该怎么做?

回答 2 投票 0

使用ffmpeg API连续播放m3u8流失败

我正在开发一个嵌入式Linux系统(5.10.24),我想在其中使用FFMPEG API播放m3u8音频流。 这是我的代码。 #包括 #包括 #包括 我正在开发一个嵌入式Linux系统(5.10.24),我想在其中使用FFMPEG API播放m3u8音频流。 这是我的代码。 #include <stdio.h> #include <stdbool.h> #include <alsa/asoundlib.h> #include <libswresample/swresample.h> #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> #include <libswscale/swscale.h> int init_pcm_play(snd_pcm_t **playback_handle,snd_pcm_uframes_t chunk_size,unsigned int rate,int bits_per_sample,int channels) { snd_pcm_hw_params_t *hw_params; snd_pcm_format_t format; //1. openPCM, if (0 > snd_pcm_open(playback_handle, "default", SND_PCM_STREAM_PLAYBACK, 0)) { printf("snd_pcm_open err\n"); return -1; } //2. snd_pcm_hw_params_t if(0 > snd_pcm_hw_params_malloc (&hw_params)) { printf("snd_pcm_hw_params_malloc err\n"); return -1; } //3. hw_params if(0 > snd_pcm_hw_params_any (*playback_handle, hw_params)) { printf("snd_pcm_hw_params_any err\n"); return -1; } //4. if (0 > snd_pcm_hw_params_set_access (*playback_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) { printf("snd_pcm_hw_params_any err\n"); return -1; } //5. SND_PCM_FORMAT_U8,8 if(8 == bits_per_sample) { format = SND_PCM_FORMAT_U8; } if(16 == bits_per_sample) { format = SND_PCM_FORMAT_S16_LE; } if (0 > snd_pcm_hw_params_set_format (*playback_handle, hw_params, format)) { printf("snd_pcm_hw_params_set_format err\n"); return -1; } //6. if (0 > snd_pcm_hw_params_set_rate_near (*playback_handle, hw_params, &rate, 0)) { printf("snd_pcm_hw_params_set_rate_near err\n"); return -1; } //7. if (0 > snd_pcm_hw_params_set_channels(*playback_handle, hw_params, 2)) { printf("snd_pcm_hw_params_set_channels err\n"); return -1; } //8. set hw_params if (0 > snd_pcm_hw_params (*playback_handle, hw_params)) { printf("snd_pcm_hw_params err\n"); return -1; } snd_pcm_hw_params_get_period_size(hw_params, &chunk_size, 0); snd_pcm_hw_params_free (hw_params); return 0; } int main(int argc, char *argv[]) { AVFormatContext *pFormatCtx = NULL; //for opening multi-media file int audioStream = -1; AVCodecContext *pCodecCtx = NULL; AVCodec *pCodec = NULL; // the codecer AVFrame *pFrame = NULL; AVPacket *packet; uint8_t *out_buffer; struct SwrContext *au_convert_ctx; snd_pcm_t *playback_handle; int bits_per_sample = 0; if (avformat_open_input(&pFormatCtx, argv[1], NULL, NULL) != 0) { printf("Failed to open video file!"); return -1; // Couldn't open file } if(avformat_find_stream_info(pFormatCtx,NULL)<0) { printf("Failed to find stream info.\n"); return -1; } audioStream = av_find_best_stream(pFormatCtx, AVMEDIA_TYPE_AUDIO, -1, -1, NULL, 0); if (audioStream == -1) { printf("Din't find a video stream!"); return -1;// Didn't find a video stream } av_dump_format(pFormatCtx, audioStream, NULL, false); // Find the decoder for the video stream pCodec = avcodec_find_decoder(pFormatCtx->streams[audioStream]->codecpar->codec_id); if (pCodec == NULL) { printf("Unsupported codec!\n"); return -1; // Codec not found } // Copy context pCodecCtx = avcodec_alloc_context3(pCodec); AVCodecParameters *pCodecParam = pFormatCtx->streams[audioStream]->codecpar; if (avcodec_parameters_to_context(pCodecCtx, pCodecParam) < 0) { printf("Failed to set codec params\n"); return -1; } // Open codec if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) { printf("Failed to open decoder!\n"); return -1; // Could not open codec } packet = av_packet_alloc(); pFrame = av_frame_alloc(); uint64_t iInputLayout = av_get_default_channel_layout(pCodecCtx->channels); enum AVSampleFormat eInputSampleFormat = pCodecCtx->sample_fmt; int iInputSampleRate = pCodecCtx->sample_rate; uint64_t iOutputLayout = av_get_default_channel_layout(pCodecCtx->channels); int iOutputChans = pCodecCtx->channels; enum AVSampleFormat eOutputSampleFormat = AV_SAMPLE_FMT_S16; int iOutputSampleRate = pCodecCtx->sample_rate; au_convert_ctx = swr_alloc_set_opts(NULL,iOutputLayout, eOutputSampleFormat, iOutputSampleRate, iInputLayout,eInputSampleFormat, iInputSampleRate, 0, NULL); swr_init(au_convert_ctx); int iConvertLineSize = 0; int iConvertBuffSize = av_samples_get_buffer_size(&iConvertLineSize, iOutputChans, pCodecCtx->frame_size, eOutputSampleFormat, 0); printf("ochans: %d, ifrmsmp: %d, osfmt: %d, cbufsz: %d\n", iOutputChans, pCodecCtx->frame_size, eOutputSampleFormat, iConvertBuffSize); out_buffer = (uint8_t *) av_malloc(iConvertBuffSize); if(eOutputSampleFormat == AV_SAMPLE_FMT_S16 ) { bits_per_sample = 16; } /*** alsa handle ***/ init_pcm_play(&playback_handle,256, iOutputSampleRate,bits_per_sample,2); if (0 > snd_pcm_prepare (playback_handle)) { printf("snd_pcm_prepare err\n"); return -1; } while (av_read_frame(pFormatCtx, packet) >= 0) { if (packet->stream_index == audioStream) { avcodec_send_packet(pCodecCtx, packet); while (avcodec_receive_frame(pCodecCtx, pFrame) == 0) { int outframes = swr_convert(au_convert_ctx, &out_buffer, pCodecCtx->frame_size, (const uint8_t **) pFrame->data, pFrame->nb_samples); // 转换音频 snd_pcm_writei(playback_handle, out_buffer, outframes); av_frame_unref(pFrame); } } av_packet_unref(packet); } swr_free(&au_convert_ctx); snd_pcm_close(playback_handle); av_freep(&out_buffer); return 0; } 当我运行它时,我得到以下输出。 ./ffmpeg_test http://live.ximalaya.com/radio-first-page-app/live/2730/64.m3 u8 [hls @ 0x21a8020] Skip ('#EXT-X-VERSION:3') [hls @ 0x21a8020] Opening 'http://broadcast.tx.xmcdn.com/live/2730_64_241104_000015_2186.aac' for reading [hls @ 0x21a8020] Opening 'http://broadcast.tx.xmcdn.com/live/2730_64_241104_000015_2187.aac' for reading Input #0, hls, from '(null)': Duration: N/A, bitrate: N/A Program 0 Metadata: variant_bitrate : 0 Stream #0:0: Audio: aac (HE-AAC), 44100 Hz, stereo, fltp Metadata: variant_bitrate : 0 [http @ 0x21b7ba0] Opening 'http://broadcast.tx.xmcdn.com/live/2730_64_241104_000015_2188.aac' for reading [hls @ 0x21a8020] Skip ('#EXT-X-VERSION:3') [http @ 0x21d4c20] Opening 'http://broadcast.tx.xmcdn.com/live/2730_64_241104_000015_2189.aac' for reading 一开始可以播放音频,直到第二次Opening http://...发生。 如何使其能够连续播放m3u8音频流? 我找到了代码的修复程序,使其能够连续播放直播流。 需要添加以下代码 rc = snd_pcm_writei(playback_handle, out_buffer2, outframes); + if (rc < 0) { + snd_pcm_prepare(playback_handle); + } 也就是说,流媒体播放过程中出现错误,需要恢复ALSA错误。 现在可以连续播放直播了,但是我遇到了另一个问题:链接更改时会出现轻微的中断,如下, [http @ 0x6eaba0] Opening 'http://broadcast.tx.xmcdn.com/live/2730_64_241107_000014_1e5b.aac' for reading ALSA lib pcm.c:8675:(snd_pcm_recover) underrun occurred [http @ 0x7665d0] Opening 'http://live.ximalaya.com/radio-first-page-app/live/2730/64.m3u8' for reading [hls @ 0x6db020] Skip ('#EXT-X-VERSION:3') [http @ 0x707c40] Opening 'http://broadcast.tx.xmcdn.com/live/2730_64_241107_000014_1e5c.aac' for reading ALSA lib pcm.c:8675:(snd_pcm_recover) underrun occurred [http @ 0x7665d0] Opening 'http://live.ximalaya.com/radio-first-page-app/live/2730/64.m3u8' for reading [hls @ 0x6db020] Skip ('#EXT-X-VERSION:3') [http @ 0x6eaba0] Opening 'http://broadcast.tx.xmcdn.com/live/2730_64_241107_000014_1e5d.aac' for reading ALSA lib pcm.c:8675:(snd_pcm_recover) underrun occurred 我的缓冲区/周期设置似乎有问题,设置正确的值是多少???

回答 1 投票 0

如何将2D视频转换为3D/180°?

我正在尝试从 2D 视频创建 3D 并排视频。显然,Windows 下有一些付费软件可以做到这一点,我想在 Linux 下做同样的事情......

回答 2 投票 0

每次使用 flutter 包 ffmpeg_kit_flutter 时,文件转换为 mp3 都会返回失败

我正在尝试将从 flutter 的文本到语音包“flutter_tts”生成的 .wav 音频文件转换为 mp3 文件,但每次都失败。 我已经为文件编写了以下代码

回答 1 投票 0

ffmpeg 写入 mp4,编码时出现字幕错误

我正在努力编写尝试编写带有嵌入字幕的 mp4 视频文件的代码。 我成功编写了 h264 帧,但是当我尝试向该文件添加字幕时,出现错误

回答 1 投票 0

ffmpeg 接收第一帧之前有很长的延迟(5-8 秒)

发送视频文件并接收它。我发现在收到第一帧之前有很长的延迟,大约 5-8 秒: ::发件人.bat ffmpeg -re -i example.mp4 -vcodec h264 -tune fastdecode -tune Zerolaten...

回答 3 投票 0

使用 python-ffmpeg 为具有多个流的 mov 文件保存帧

我有一个包含多个视频流的 mov 文件,我正在尝试使用 ffmpeg python 绑定来读取每个流并保存其所有帧。 为此,我编写了类似于此的代码: 进口新...

回答 1 投票 0

在ffmpeg中设置cpu线程

我有一个 PC 24 线程,当我使用 ffmpeg 时。它只使用了我的 CPU 的 25%。那么,如何才能全部使用这 24 个线程呢?所以我的CPU使用率达到100%,因为如果是25%,它仍然是一个缓慢的过程 前...

回答 2 投票 0

使用 FFmpeg 编码视频时计算 VMAF 分数

我有一个使用 VMAF 库构建的 ffmpeg 版本。我可以使用它来计算失真视频相对于参考视频的 VMAF 分数,使用如下命令: ffmpeg -i 扭曲.mp4 -i 原始...

回答 2 投票 0

在 Python 中使用 MFDNet 进行视频逐帧去雨

正如 CodeReview 问题提到的,我正在尝试修改代码以处理视频中的逐帧雨条纹去除。此代码中使用了 FFmpeg 包。 导入argparse 导入操作系统 重要...

回答 1 投票 0

尽管玩家渲染正确,FFprobe 仍读取不正确的分辨率值

我正在 FFMPEG 的帮助下从流创建视频,我还使用 FFPROBE 收集信息以在状态页面上使用,例如分辨率、编解码器等。 当 FFProbe 解析我的视频时

回答 1 投票 0

使用 powershell 脚本下载 YouTube 视频的一部分

我正在编写这个Powershell脚本: $URL = "https://www.youtube.com/watch?v=KbuwueqEJL0" $来自 = 00:06:15 $至 = 00:09:17 $cmdOutput = (youtube-dl --get-url $URL) ffmpeg -ss $从-到$...

回答 1 投票 0

gcc:未定义的参考错误

我想使用 ffmpeg/libavfilter/lavfutils.h 中定义的函数“ff_load_image”。 程序.c #include“../ffmpeg/libavfilter/lavfutils.h” int 主函数 () { uint8_t* 数据; int linesize,w...

回答 1 投票 0

将视频快速分割成“x”帧块

我正在尝试将视频分割成每个 1000 帧的块(必须在帧级别完成)。我目前正在使用opencv库,但是它很慢。 1小时分开需要半小时

回答 1 投票 0

如何将 ffmpeg 安装到我的 docker 镜像中

我已在 Windows 10 计算机中设置了 docker 映像。 你能告诉我如何将 ffmpeg 安装到该 docker 映像吗?

回答 5 投票 0

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.