我有一个主视频剪辑,并且正在使用ffmpeg从中生成一个子剪辑。我用来生成子剪辑的命令是:
ffmpeg -i {input_video} -ss {start_time} -to {end_time} {output_filename}
一旦有了子剪辑,我就会做以下事情:
第1步:我正在使用ffprobe计算平均帧频:
ffprobe -v error -select_streams v:0 -show_entries stream=avg_frame_rate -of default=noprint_wrappers=1:nokey=1 <input file>
步骤2:我正在提取原始视频流并将其存储在临时位置,并使用以下命令删除现有的PTS值:
ffmpeg -i <input video> -c:v copy -an $TMP_STREAM 2>&1
第3步:我将视频重新混合到一个容器中,强制平均FPS导致重写PTS值:
ffmpeg-r <FPS> -i $TMP_STREAM -c:v copy $OUTPUT_FILE 2>&1
当我在主视频剪辑上执行上述三个步骤时,它工作正常。但是,当我在子剪辑(使用ffmpeg生成)上执行这些步骤时,步骤3却给了我错误:
Can't write packet with unknown timestamp
av_interleaved_write_frame(): Invalid argument
关于发生了什么的任何输入?
下面是我的命令和日志:
命令1:
ffprobe -v错误-select_streams v:0 -show_entries stream = avg_frame_rate -of default = noprint_wrappers = 1:nokey = 1 abcd.mp4。
--->输出:287/12
命令2:
ffmpeg -i abcd.mp4 -c:v复制-an /tmp/tmp.h264 2>&1
--->输出:
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.9.4 (GCC)
configuration: --prefix=/local/p4clients/pkgbuild-DlViY/workspace/src/FFmpeg/build/private/install --disable-static --enable-gpl --enable-libx264 --enable-shared --enable-encoder=vorbis --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libebur128
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'subclip_fv_1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.56.101
Duration: 00:00:29.44, start: 0.000000, bitrate: 329 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 300 kb/s, 23.92 fps, 23.92 tbr, 18368 tbn, 47.83 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 26 kb/s (default)
Metadata:
handler_name : SoundHandler
File '/tmp/tmp.h264' already exists. Overwrite ? [y/N] y
Output #0, h264, to '/tmp/tmp.h264':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.56.101
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=2-31, 300 kb/s, 23.92 fps, 23.92 tbr, 23.92 tbn, 23.92 tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 703 fps=0.0 q=-1.0 Lsize= 1077kB time=00:00:29.31 bitrate= 301.1kbits/s speed=4.47e+03x
video:1077kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.010517%
命令3:
ffmpeg-r 287/12 -i /tmp/tmp.h264 -c:v复制abcd.mp4_retimed.mkv 2>&1
----> Ouput:
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.9.4 (GCC)
configuration: --prefix=/local/p4clients/pkgbuild-DlViY/workspace/src/FFmpeg/build/private/install --disable-static --enable-gpl --enable-libx264 --enable-shared --enable-encoder=vorbis --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libebur128
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, h264, from '/tmp/tmp.h264':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], 23.92 fps, 23.92 tbr, 1200k tbn, 47.83 tbc
Output #0, matroska, to 'subclip_fv_1.mp4_retimed.mkv':
Metadata:
encoder : Lavf57.56.101
Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], q=2-31, 23.92 fps, 23.92 tbr, 1k tbn, 23.92 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[matroska @ 0x43d880] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[matroska @ 0x43d880] Can't write packet with unknown timestamp
av_interleaved_write_frame(): Invalid argument
答案 0 :(得分:0)
第三步依赖输出复用器在没有输入时间戳的情况下分配时间戳。在普通的多路复用器中,只有MP4可以做到这一点,所以
sRemoveElem :: forall (xs :: Vect (S n) Nat) (e :: Elem x xs).
SElem e -> SNatVect xs -> SNatVect (RemoveElem xs e)
获得该MP4之后,即可运行
ffmpeg-r 287/12 -i /tmp/tmp.h264 -c:v copy abcd.mp4_retimed.mp4