ffmpeg - 转换时出现操作不允许错误

发布于 2025-01-07 08:43:14 字数 2471 浏览 1 评论 0原文

我正在开发一个安卓应用程序。我的要求是在android上实现rtsp流媒体服务器。它必须实时流式传输使用 MediaRecorder 捕获的视频和音频。另一个要求是我必须使用live555作为流媒体服务器。我从 MediaRecorder 获得的内容是 MP4 或 3GP 格式。 live555 无法同时传输两者。但如果我仅以“RAW_AMR”格式录制音频,它可以传输音频。由于live555支持“mpg”格式的流媒体,我决定让一个人可以将“mp4”或“3gp”转换为“mpg”,我选择了ffmpeg。

我已经将live555和ffmpeg移植到android上。 ffmpeg 能够在完成后转换由 MediaRecorder 录制的文件。但问题是ffmpeg无法同时完成。也就是说,ffmpeg 无法在录制时转换文件。它显示不允许操作错误。我在我的 Linux 机器上尝试了同样的操作,使用 VLC 来录制,而不是 Android 上的 MediaRecorder 。结果是一样的。 ffmpeg 能够在录制完成后进行转换,但在录制时无法进行相同的操作。

以下是我在 Linux 机器上发出的 ffmpeg 命令:

ffmpeg -v 9 -loglevel 99 -i test.mp4 test.mpg

其中 test.mp4 是 VLC 以 ​​mp4 格式录制的文件。 test.mpg 是我的目标文件。以下是 ffmpeg 在终端上的输出。

ffmpeg version 0.8.9, Copyright (c) 2000-2011 the FFmpeg developers
  built on Feb  1 2012 18:29:27 with gcc 4.6.2 20111027 (Red Hat 4.6.2-1)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --enable-bzlib --enable-libcelt --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
  libavutil    51.  9. 1 / 51.  9. 1
  libavcodec   53.  8. 0 / 53.  8. 0
  libavformat  53.  5. 0 / 53.  5. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 23. 0 /  2. 23. 0
  libswscale    2.  0. 0 /  2.  0. 0
  libpostproc  51.  2. 0 / 51.  2. 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1672600] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1672600] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1672600] moov atom not found
test.mp4: Operation not permitted

有人可以告诉我是什么导致了这个问题吗?或者上面的场景可以通过 ffmpeg 实现吗?也就是说ffmpeg能在录制的同时进行转换吗?如果 ffmpeg 无法实现,您能否建议其他解决方案?

注意:我放置一个 C 标签,因为如果可以通过在 ffmpeg 上对 C 进行一些调整,我已经准备好这样做(我非常想要这个解决方案)。但请提供一些正确方向的指示。

I am developing an android app. My requirement is that to implement an rtsp streaming server on android. It has to live stream video and audio captured using MediaRecorder. Another requirement is that I have to use live555 as the streaming server. What I get from MediaRecorder is in MP4 or 3GP format. live555 cannot able to stream both. But it can stream audio if I recorded it only in 'RAW_AMR' format. Since live555 support 'mpg' format for streaming, I decided to put someone in middle who can convert 'mp4' or '3gp' to 'mpg', and I chose ffmpeg.

I have ported live555 and ffmpeg to android. ffmpeg is able to convert the file recorded by MediaRecorder once it is finished. But the problem is that ffmpeg cannot be able to do it concurrently. That is, ffmpeg is not able to convert the file while recording. It shows an Operation not permitted error. I tried the same on my linux machine, using VLC to record instead of MediaRecorder on android. The result is same. ffmpeg is able to convert once the recording is finished, and not able to do the same while recording.

Here is the ffmpeg command I issued on my linux box:

ffmpeg -v 9 -loglevel 99 -i test.mp4 test.mpg

Where test.mp4 is the file to which VLC is recording in mp4 format. and test.mpg is my destination file. The following is the output by ffmpeg on terminal.

ffmpeg version 0.8.9, Copyright (c) 2000-2011 the FFmpeg developers
  built on Feb  1 2012 18:29:27 with gcc 4.6.2 20111027 (Red Hat 4.6.2-1)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --enable-bzlib --enable-libcelt --enable-libdc1394 --enable-libdirac --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
  libavutil    51.  9. 1 / 51.  9. 1
  libavcodec   53.  8. 0 / 53.  8. 0
  libavformat  53.  5. 0 / 53.  5. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 23. 0 /  2. 23. 0
  libswscale    2.  0. 0 /  2.  0. 0
  libpostproc  51.  2. 0 / 51.  2. 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1672600] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1672600] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1672600] moov atom not found
test.mp4: Operation not permitted

Would anyone please tell me what is causing the problem? Or is the scenario above is possible by ffmpeg. That is, is ffmpeg is able to do the conversion at the same time as that of recording? If it is not possible by ffmpeg, would you please suggest any alternative solutions?

NOTE: I am putting a C tag because if it possible by some tweaking in C on ffmpeg, I am ready to do that(I want the solution that badly). But please provide some pointers to the right direction.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑脸一如从前 2025-01-14 08:43:14

3gpmp4 格式都包含在文件最终确定时写入的 moov 原子(数据块)。在此之前,该文件还不完整。

您可以使用 FLV 作为“中间”格式。也可以使用支持直播的其他格式。如果需要,选项 -re 可能有助于告诉编码器以流速率运行。

另请参阅是否可以在编码器编码时播放输出视频文件?

Both 3gp and mp4 formats include moov atom (chunk of data) that is written when the file is finalized. Until then the file is incomplete.

You can use FLV as the "middle" format. Other formats that support live streaming can be used too. Option -re may be helpful to tell encoder to run at the stream rate, if needed.

See also Is it possible to play an output video file from an encoder as it's being encoded?.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文