如何使用 ffmpeg 获取 mp4 容器的视频流的偏移量?
How to get the offset of a video stream of a mp4 container with ffmpeg?
我可以通过 运行 此命令对 mp4 容器内的视频流进行 1 秒偏移编码:
ffmpeg -i input.mp3 -itsoffset 1 -t 3 -i input.mp4 -c:v copy output.mp4
如何使用 ffmpeg 取回流的偏移量?
使用此命令,我可以获得有关特定流的信息(例如本例中的视频流):
ffmpeg -i input.mp4 -c copy -map 0:v -f null -
我获得了有用的信息,例如流的持续时间,但从未包括偏移量。
请注意,我无法使用 ffprobe
。
编辑
此命令的完整日志:ffmpeg -i input.mp4 -map 0:v -frames 1 -f null -
我知道这个版本很旧,但我无法控制版本。
ffmpeg version n3.1.2 Copyright (c) 2000-2016 the FFmpeg developers
built with emcc (Emscripten gcc/clang-like replacement) 1.36.7 ()
configuration: --cc=emcc --enable-cross-compile --target-os=none --arch=x86 --disable-runtime-cpudetect --disable-asm --disable-fast-unaligned --disable-pthreads --disable-w32threads --disable-os2threads --disable-debug --disable-stripping --disable-all --enable-ffmpeg --enable-avcodec --enable-avformat --enable-avutil --enable-swresample --enable-swscale --enable-avfilter --disable-network --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vda --disable-vdpau --enable-decoder=vp8 --enable-decoder=vp9 --enable-decoder=theora --enable-decoder=mpeg2video --enable-decoder=mpeg4 --enable-decoder=h264 --enable-decoder=hevc --enable-decoder=png --enable-decoder=mjpeg --enable-decoder=vorbis --enable-decoder=opus --enable-decoder=mp3 --enable-decoder=ac3 --enable-decoder=aac --enable-decoder=ass --enable-decoder=ssa --enable-decoder=srt --enable-decoder=webvtt --enable-demuxer=matroska --enable-demuxer=ogg --enable-demuxer=avi --enable-demuxer=mov --enable-demuxer=flv --enable-demuxer=mpegps --enable-demuxer=image2 --enable-demuxer=mp3 --enable-demuxer=concat --enable-protocol=file --enable-filter=aresample --enable-filter=scale --enable-filter=crop --enable-filter=overlay --disable-bzlib --disable-iconv --disable-libxcb --disable-lzma --disable-sdl --disable-securetransport --disable-xlib --disable-zlib --enable-encoder=libx264 --enable-encoder=libmp3lame --enable-encoder=aac --enable-muxer=mp4 --enable-muxer=mp3 --enable-muxer=null --enable-gpl --enable-libmp3lame --enable-libx264 --extra-cflags=-I../lame/dist/include --extra-ldflags=-L../lame/dist/lib
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavfilter 6. 47.100 / 6. 47.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
[h264 @ 0x809db0] Warning: not compiled with thread support, using thread emulation
[aac @ 0x80edf0] Warning: not compiled with thread support, using thread emulation
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.41.100
Duration: 00:00:07.08, start: 0.000000, bitrate: 137 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 100x100 [SAR 1:1 DAR 1:1], 4 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : SoundHandler
Output #0, null, to 'pipe:':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.41.100
Stream #0:0(und): Unknown: none (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> ? (?))
Encoder (codec wrapped_avframe) not found for output stream #0:0
在不生成详细日志的情况下,您可以接近 运行
ffmpeg -copyts -i input.mp4 -r 1000 -map 0:v -frames 1 -f null -
输出中的time
值应该是第一帧的PTS。
我可以通过 运行 此命令对 mp4 容器内的视频流进行 1 秒偏移编码:
ffmpeg -i input.mp3 -itsoffset 1 -t 3 -i input.mp4 -c:v copy output.mp4
如何使用 ffmpeg 取回流的偏移量?
使用此命令,我可以获得有关特定流的信息(例如本例中的视频流):
ffmpeg -i input.mp4 -c copy -map 0:v -f null -
我获得了有用的信息,例如流的持续时间,但从未包括偏移量。
请注意,我无法使用 ffprobe
。
编辑
此命令的完整日志:ffmpeg -i input.mp4 -map 0:v -frames 1 -f null -
我知道这个版本很旧,但我无法控制版本。
ffmpeg version n3.1.2 Copyright (c) 2000-2016 the FFmpeg developers
built with emcc (Emscripten gcc/clang-like replacement) 1.36.7 ()
configuration: --cc=emcc --enable-cross-compile --target-os=none --arch=x86 --disable-runtime-cpudetect --disable-asm --disable-fast-unaligned --disable-pthreads --disable-w32threads --disable-os2threads --disable-debug --disable-stripping --disable-all --enable-ffmpeg --enable-avcodec --enable-avformat --enable-avutil --enable-swresample --enable-swscale --enable-avfilter --disable-network --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vda --disable-vdpau --enable-decoder=vp8 --enable-decoder=vp9 --enable-decoder=theora --enable-decoder=mpeg2video --enable-decoder=mpeg4 --enable-decoder=h264 --enable-decoder=hevc --enable-decoder=png --enable-decoder=mjpeg --enable-decoder=vorbis --enable-decoder=opus --enable-decoder=mp3 --enable-decoder=ac3 --enable-decoder=aac --enable-decoder=ass --enable-decoder=ssa --enable-decoder=srt --enable-decoder=webvtt --enable-demuxer=matroska --enable-demuxer=ogg --enable-demuxer=avi --enable-demuxer=mov --enable-demuxer=flv --enable-demuxer=mpegps --enable-demuxer=image2 --enable-demuxer=mp3 --enable-demuxer=concat --enable-protocol=file --enable-filter=aresample --enable-filter=scale --enable-filter=crop --enable-filter=overlay --disable-bzlib --disable-iconv --disable-libxcb --disable-lzma --disable-sdl --disable-securetransport --disable-xlib --disable-zlib --enable-encoder=libx264 --enable-encoder=libmp3lame --enable-encoder=aac --enable-muxer=mp4 --enable-muxer=mp3 --enable-muxer=null --enable-gpl --enable-libmp3lame --enable-libx264 --extra-cflags=-I../lame/dist/include --extra-ldflags=-L../lame/dist/lib
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavfilter 6. 47.100 / 6. 47.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
[h264 @ 0x809db0] Warning: not compiled with thread support, using thread emulation
[aac @ 0x80edf0] Warning: not compiled with thread support, using thread emulation
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.41.100
Duration: 00:00:07.08, start: 0.000000, bitrate: 137 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 100x100 [SAR 1:1 DAR 1:1], 4 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : SoundHandler
Output #0, null, to 'pipe:':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.41.100
Stream #0:0(und): Unknown: none (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> ? (?))
Encoder (codec wrapped_avframe) not found for output stream #0:0
在不生成详细日志的情况下,您可以接近 运行
ffmpeg -copyts -i input.mp4 -r 1000 -map 0:v -frames 1 -f null -
输出中的time
值应该是第一帧的PTS。