冻结帧和解复用错误

2024-04-24 16:55:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用ffmpeg通过python脚本使用子进程连接一些视频片段。在

下面是代码的一部分:

def join_videos(videos):
    # videos is a list of tuples with (file_name, start_point, duration)
    path = os.path.dirname(__file__)

    # create a new video file containg only the desired bit, it will be named output_N.mov
    for out_n, (file_name, start, duration) in enumerate(videos, 1):
        video_path = path + "/VIDEOS/" + file_name
        ## essentialy ffmpeg -i %PATH_TO_VIDEO -ss %STARTING_POINT -c copy -t %DURATION output_%NUMBER.mov
        command = ["ffmpeg", "-i",video_path,"-ss", str(start),"-c","copy","-t",str(duration),"output_%i.mov"%out_n]
        subprocess.Popen(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE)

    # get the list of files with this pattern
    files = glob.glob("output_*.mov")
    # add them to a text file
    with open("to_merge_tmp.txt", 'w') as f:
        for file_name in files:
            f.write("file '{path}/{file_name}'\n".format(**locals()))
    # use 'ffmpeg' to concatenate
    command = "ffmpeg -f concat -i to_merge_tmp.txt -c copy final.mov"
    subprocess.Popen(command.split(" "), stderr=subprocess.PIPE, stdout=subprocess.PIPE)

我发布了一个新的视频,使用文件名和期望的开始点和持续时间列表。在

例如:

^{pr2}$

这将生成一个最终.mov将零件连接在一起(一个接一个)

程序运行良好。没有错误什么的。在

但当我试着播放时,有些画面停留太久(冻结),音频播放正常。在

我用python bindings for VLC编写了第二个脚本以编程方式播放它

给你:

import vlc

instance = vlc.Instance()
media = instance.media_new("final.mov")
player = instance.media_player_new()
player.set_media(media)
player.play()

while player.is_playing():
     pass

instance.vlm_release()
player.release()
instance.release()

有了这个我得到了一堆警告,当播放文件。在

例如,发生这种情况时,视频无法播放(demux错误)

[0x7f4e64009528] mp4 demux error: MP4 plugin discarded (no moov,foov,moof box)  
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f4e64025be0] moov atom not found
[0x7f4e64009528] avformat demux error: Could not open /medi /.../final.mov: Unknown error 1052488119

而这种情况发生了,视频播放时却出现了冻结的画面。在

Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
Non-reference picture received and no reference available
[h264 @ 0x7fe76c0e5280] decode_slice_header error
[h264 @ 0x7fe76c0e5280] concealing 1080 DC, 1080 AC, 1080 MV errors
Non-reference picture received and no reference available
[h264 @ 0x7fe76c0e5820] decode_slice_header error
[h264 @ 0x7fe76c0e5820] concealing 1080 DC, 1080 AC, 1080 MV errors
[0x7fe740001248] main vout display error: Failed to resize display

或者这个,中途停止播放并使程序崩溃。在

Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
Fontconfig warning: FcPattern object size does not accept value "0"
Non-reference picture received and no reference available
[h264 @ 0x7f5c3c0c0000] decode_slice_header error
[h264 @ 0x7f5c3c0c0000] concealing 1080 DC, 1080 AC, 1080 MV errors
Non-reference picture received and no reference available
[h264 @ 0x7f5c3c0c0440] decode_slice_header error
[h264 @ 0x7f5c3c0c0440] concealing 1080 DC, 1080 AC, 1080 MV errors
[h264 @ 0x7f5c3c0c0440] Reinit context to 1280x720, pix_fmt: 12
Non-reference picture received and no reference available
[h264 @ 0x7f5c3c0c09e0] decode_slice_header error
Non-reference picture received and no reference available
[h264 @ 0x7f5c3c0befa0] decode_slice_header error

我不知道怎么回事,我很确定ffmpeg是如何连接文件的。在

编辑

正如我发现的here,当创建文件时录像机崩溃时,moov atom not found错误就会发生。但是我发现很难理解为什么会发生这种情况,并且在创建这些文件时没有显示任何错误。在


Tags: nosizeobjectvaluenoterrorfilereference