重新编码vlc创建的mpeg2 .ts文件会导致20秒的文件;又名:具有隐藏流的多流文件 [英] Re-encoding vlc-created mpeg2 .ts file results in 20 second file; AKA: multi-stream file with hidden streams

查看:328
本文介绍了重新编码vlc创建的mpeg2 .ts文件会导致20秒的文件;又名:具有隐藏流的多流文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用v4l2禁用vlc录制某些东西(以防万一),我只是选择了第一种有效的格式,即使用TS容器的mpeg2.文件的扩展名为.ts,由vlc自动选择.然后,当我尝试将视频文件放入我的视频编辑器中时,它说视频长19884小时,大约应该是6分钟(大小约为80mb).当我尝试在xine中播放时,它会正确显示持续时间(vlc不会),以及当我使用ffprobe时:

I was recording something with vlc off v4l2 (in case that makes a difference), and I just selected the first format that worked, being mpeg2 using TS container. File resulted in .ts extension, as automatically selected by vlc. When I then tried to put the video file in my video editor, it said the video was 19,884 hours long, when it should be about 6 minutes (it is ~80mb in size). When I try to play it in xine, it correctly shows the duration (vlc doesn't), and when I use ffprobe:

[mpegts @ 0x9b2c0a0] max_analyze_duration 5000000 reached at 5000000
Input #0, mpegts, from 'loopbacktestcap.ts':   Duration: N/A, start:
17978.139456, bitrate: N/A   Program 1 
     Stream #0:0[0x44](): Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 104857 kb/s, 30 fps, 30
tbr, 90k tbn, 60 tbc
     Stream #0:1[0x46](): Video: mpeg2video ([2][0][0][0] / 0x0002), 90k tbn

请特别注意这一行:

   Duration: N/A, start: 17978.139456, bitrate: N/A   Program 1 

我抬起头来,似乎容器的持续时间不足.但是我已经尝试了一些重新编码的方法(我尝试了-vcodec copy,mpeg2,libx264 ...),而我所能得到的只是20秒的1.1mb-1.8mb文件.

I looked it up and it seems the lack of duration has to do with the container. But I have tried a few things to reencode (I tried -vcodec copy, mpeg2, libx264...) and all I can get is 20 second files of 1.1mb - 1.8mb.

那么我该如何重新编码此文件,以便显示持续时间,而我得到了完整的6分钟,而不是仅仅20秒?

So how can I reencode this file so the duration appears, and I get the full 6 minutes, instead of just the first 20 seconds?

推荐答案

当我找到此链接时,已达到第一个里程碑:地图-ffmpeg-示例#8 使我尝试:

First milestone was reached when I found this link: Map - ffmpeg -- Example #8 which led me to try:

ffmpeg -probesize 90M -analyzeduration 90M -i my_mpeg2_file.ts

满足以下条件:

[mpegts @ 0x9980f40] max_analyze_duration 90000000 reached at 90000000
Input #0, mpegts, from 'loopbacktestcap.ts':
  Duration: 00:16:00.96, start: 17978.139456, bitrate: 695 kb/s
  Program 1 
    Stream #0:0[0x44](): Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 104857 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc
    Stream #0:1[0x45](): Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 104857 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc
    Stream #0:2[0x46](): Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 104857 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc

请注意,它现在为我提供了正确的持续时间以及第二个流(从技术上来说是第三个)的额外信息流和更多信息.所以我跑了:

Notice that it now gives me the correct duration as well as an extra stream and more info on the second one (which is technically the third one). So then I ran:

ffmpeg -probesize 90M -analyzeduration 90M -i my_mpeg2_file.ts  -map 0 -c copy map0.mp4

,现在生成了一个79451050字节文件 map0.mp4 ,其中 my_mpeg2_file.ts 为83499636.我尝试在vlc中播放此文件,它显示的持续时间为9:12,但是如果我慢跑播放位置,则会再打开两个vlc窗口,并且vlc开始变得奇怪;尽管播放位置指示继续进行,但视频显示区域已挂起.这可能只是一辆越野车,但我现在还停留在那儿.让我知道是否有人在这里看到我想念的东西.

and that now produced a 79451050 byte file map0.mp4, where my_mpeg2_file.ts is 83499636. I try to play this in vlc, and it shows the duration as 9:12, but if I jog the play position, two more vlc windows are opened and vlc begins to act strange; the video display area is hung, though the playback position indicator continues to progress. This might be just a buggy vlc, but I am stuck at this point. Let me know if anyone sees anything I am missing here.

xine但是无法播放新文件(播放原始文件并显示该文件的长度为6分钟-实际上,持续时间计数器在我播放文件并不断更改时有点不固定,所以我不不知道).

xine however cannot play back the new file (where it plays the original and shows that it is 6 minutes long -- actually, the duration counter goes a little nutty as I play the file and changes constantly, so I don't know).

所以,我尝试的下一个命令是:

So, next command I tried was:

ffmpeg -probesize 90M -analyzeduration 90M -i my_mpeg2_file.ts  -map 0 -c libx264 map0x264.mp4

尝试播放生成的文件(43652975字节,出于好奇)导致在vlc中出现相同的奇怪行为,现在我可以看到它正在为每个流打开一个新窗口,并在播放流时对其进行播放在其相应的窗口中旋转",冻结其他窗口的其他显示区域.尝试关闭它们将停止所有播放并关闭两个额外的窗口.我想将所有3个流都保留在同一个文件中是胡说八道.

Trying to play the resulting file (43652975 bytes, for the curious) led to the same strange behavior in vlc, where now I can see that it is opening a new window for each stream, and playing the stream when it is its "turn" in its respective window, freezing the other display areas of the other windows. Trying to close them stops playback for all and closes the two extra windows. I am guessing keeping all 3 streams in the same file is nonsense.

成功!

下一次尝试是:

ffmpeg -probesize 90M -analyzeduration 90M -i my_mpeg2_file.ts  -map 0:0 -c copy map0_0.ts
ffmpeg -probesize 90M -analyzeduration 90M -i my_mpeg2_file.ts  -map 0:1 -c copy map0_1.ts
ffmpeg -probesize 90M -analyzeduration 90M -i my_mpeg2_file.ts  -map 0:2 -c copy map0_2.ts

产生的文件大小为:

 4912 map0_0.ts
 5372 map0_1.ts
74728 map0_2.ts

map0_0.ts 长20秒, map0_1.ts 长1:12静止图像, map0_2.ts 长9 :12.正是我想要的!我的视频编辑器也接受他们没问题.解决了!

map0_0.ts is 20 seconds long, map0_1.ts is a still image 1:12 long, and map0_2.ts is 9:12. Exactly what I wanted! And my video editor accepts them no problem. SOLVED!

这篇关于重新编码vlc创建的mpeg2 .ts文件会导致20秒的文件;又名:具有隐藏流的多流文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆