如何在 iOS 应用程序中将(重新包装)传输流转换为 MPEG-4 容器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17907762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to convert (re-wrap) Transport Stream to MPEG-4 container in iOS app?
提问by Aleksandr Suvorov
I have a live stream in .ts format, containing AAC audio and H.264 video. I want to play it on iOS devices. I tried to use a movie player based on FFmpegto decode and play video, but the audio was lagging.
我有一个 .ts 格式的直播流,包含 AAC 音频和 H.264 视频。我想在 iOS 设备上播放它。我尝试使用基于FFmpeg的电影播放器来解码和播放视频,但音频滞后。
Can I rewrap this Transport Stream to an MPEG-4 container to play on iOS devices – without converting it server-side?
我可以将此传输流重新包装到 MPEG-4 容器中以在 iOS 设备上播放 - 而无需在服务器端进行转换吗?
The server returns me a URL of the .ts live stream and my goal is to play this stream on iOS devices without an .m3u8 playlist because I can't get it from the server.
服务器向我返回 .ts 直播流的 URL,我的目标是在没有 .m3u8 播放列表的 iOS 设备上播放此流,因为我无法从服务器获取它。
回答by d33pika
To just re-mux without transcoding you can use: ffmpeg -i input.ts -acodec copy -vcodec copy out.mp4
要在不转码的情况下重新复用,您可以使用: ffmpeg -i input.ts -acodec copy -vcodec copy out.mp4
回答by Zimba
I used ffmpeg -i input.ts -acodec copy -vcodec copy out.mp4
and conversion failed.
我用过ffmpeg -i input.ts -acodec copy -vcodec copy out.mp4
,转换失败。
I then used -bsf:a aac_adtstoasc
flag & conversion passed, with 'Non-monotonous DTS' errors, resulting in incorrect timestamps in output file.
The out.mp4 file plays well, but when I extract audio from it, the length of audio is different to that of the video.
然后我使用-bsf:a aac_adtstoasc
标志和转换通过,带有“非单调 DTS”错误,导致输出文件中的时间戳不正确。
out.mp4 文件播放良好,但是当我从中提取音频时,音频的长度与视频的长度不同。
If I use the extracted audio to replace that one in original file, the audio in resulting video file is out of sync (audio lagging).
如果我使用提取的音频替换原始文件中的音频,则生成的视频文件中的音频不同步(音频滞后)。
I then imported the out.mp4 clip into DaVinci Resolve video editor. The length of both the audio & video files showed the same, so I exported the audio only and got file size same as original video.
然后我将 out.mp4 剪辑导入 DaVinci Resolve 视频编辑器。音频和视频文件的长度显示相同,因此我仅导出音频并获得与原始视频相同的文件大小。
However, when I played the file & viewed audio graph in Audacity, I noticed many blanked out areas (no sound). Audio files created with Audacity, ffmpeg, VLC, VSDC Video Editor all gave audio files of different size than the original video file, although they all had sound.
但是,当我在 Audacity 中播放文件和查看音频图时,我注意到许多空白区域(没有声音)。使用 Audacity、ffmpeg、VLC、VSDC Video Editor 创建的音频文件都提供了与原始视频文件不同大小的音频文件,尽管它们都有声音。
I've heard of projectX to demux a/v, as a possible solution. Demux completed successfully, but created a 1KB mp1 file, with lots of errors: "PTS without a frame".
我听说 projectX 可以将 a/v 解复用为一个可能的解决方案。Demux 成功完成,但创建了一个 1KB mp1 文件,有很多错误:“PTS without a frame”。
eac3to was successful in extracting AAC audio from TS video file. Both files were same size. Using ffmpeg to replace audio in video file results in perfect syn, no lagging or blank sounds.
No errors about 'Non-monotonous DTS' or incorrect timestamps.
eac3to 成功从 TS 视频文件中提取 AAC 音频。两个文件大小相同。使用 ffmpeg 替换视频文件中的音频会产生完美的同步,没有滞后或空白的声音。
没有关于“非单调 DTS”或不正确时间戳的错误。
Done.
完毕。