ffmpeg 创建的 mp4 无法播放 IPython.display.Video
mp4 created by ffmpeg will not play with IPython.display.Video
我正在使用以下命令使用 ffmpeg 从 jpegs 创建 mp4 视频:
ffmpeg -y -threads 0 -f image2 -i jpegs/%05d.jpg -framerate 10 video.mp4
生成的视频可以在 VLC 中正常播放,但无法通过以下方式在 Jupyter 笔记本中播放:
from IPython.display import Video
Video('video.mp4')
这个笔记本视频功能过去对我有用,所以我假设视频功能无法解决 codec/mime 类型的问题?
请求更新
我试过的新命令:
ffmpeg -y -framerate 10 -i jpegs/%05d.jpg -vf format=yuv420p -movflags +faststart video.mp4
视频在 VLC 中仍然可以正常播放,但在 Jupyter 中仍然无法播放。我查看了标记为的重复项,但实际上似乎不是同一个问题..
这是输出(我删除了帧率和线程标志以简化):
algo-1-poqk5_1 | 2020-11-18 21:19:36 [INFO]: ffmpeg output:
algo-1-poqk5_1 | 2020-11-18 21:19:36 [INFO]: ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
algo-1-poqk5_1 | built with gcc 7.2.0 (crosstool-NG fa8859cb)
algo-1-poqk5_1 | configuration: --prefix=/opt/conda --cc=/opt/conda/conda-bld/ffmpeg_1531088893642/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --enable-shared --enable-static --enable-zlib --enable-pic --enable-gpl --enable-version3 --disable-nonfree --enable-hardcoded-tables --enable-avresample --enable-libfreetype --disable-openssl --disable-gnutls --enable-libvpx --enable-pthreads --enable-libopus --enable-postproc --disable-libx264
algo-1-poqk5_1 | libavutil 56. 14.100 / 56. 14.100
algo-1-poqk5_1 | libavcodec 58. 18.100 / 58. 18.100
algo-1-poqk5_1 | libavformat 58. 12.100 / 58. 12.100
algo-1-poqk5_1 | libavdevice 58. 3.100 / 58. 3.100
algo-1-poqk5_1 | libavfilter 7. 16.100 / 7. 16.100
algo-1-poqk5_1 | libavresample 4. 0. 0 / 4. 0. 0
algo-1-poqk5_1 | libswscale 5. 1.100 / 5. 1.100
algo-1-poqk5_1 | libswresample 3. 1.100 / 3. 1.100
algo-1-poqk5_1 | libpostproc 55. 1.100 / 55. 1.100
algo-1-poqk5_1 | Input #0, image2, from '/opt/ml/model/outputs/01-IR.mp4_1/%05d.jpg':
algo-1-poqk5_1 | Duration: 00:00:12.00, start: 0.000000, bitrate: N/A
algo-1-poqk5_1 | Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
algo-1-poqk5_1 | Stream mapping:
algo-1-poqk5_1 | Stream #0:0 -> #0:0 (mjpeg (native) -> mpeg4 (native))
algo-1-poqk5_1 | Press [q] to stop, [?] for help
algo-1-poqk5_1 | [swscaler @ 0x55b8cc6fcc40] deprecated pixel format used, make sure you did set range correctly
algo-1-poqk5_1 | Output #0, mp4, to '/opt/ml/model/outputs/01-IR.mp4_1/video.mp4':
algo-1-poqk5_1 | Metadata:
algo-1-poqk5_1 | encoder : Lavf58.12.100
algo-1-poqk5_1 | Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc
algo-1-poqk5_1 | Metadata:
algo-1-poqk5_1 | encoder : Lavc58.18.100 mpeg4
algo-1-poqk5_1 | Side data:
algo-1-poqk5_1 | cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
algo-1-poqk5_1 | frame= 31 fps=0.0 q=31.0 size= 768kB time=00:00:01.20 bitrate=5242.8kbits/s speed=2.33x
algo-1-poqk5_1 | frame= 64 fps= 63 q=31.0 size= 1280kB time=00:00:02.52 bitrate=4161.0kbits/s speed=2.48x
algo-1-poqk5_1 | frame= 98 fps= 64 q=31.0 size= 1792kB time=00:00:03.88 bitrate=3783.5kbits/s speed=2.53x
algo-1-poqk5_1 | frame= 131 fps= 64 q=31.0 size= 2304kB time=00:00:05.20 bitrate=3629.7kbits/s speed=2.55x
algo-1-poqk5_1 | frame= 164 fps= 64 q=31.0 size= 2560kB time=00:00:06.52 bitrate=3216.5kbits/s speed=2.56x
algo-1-poqk5_1 | frame= 198 fps= 65 q=31.0 size= 3072kB time=00:00:07.88 bitrate=3193.6kbits/s speed=2.58x
algo-1-poqk5_1 | frame= 232 fps= 65 q=31.0 size= 3328kB time=00:00:09.24 bitrate=2950.6kbits/s speed= 2.6x
algo-1-poqk5_1 | frame= 266 fps= 66 q=31.0 size= 3840kB time=00:00:10.60 bitrate=2967.7kbits/s speed=2.62x
algo-1-poqk5_1 | frame= 299 fps= 66 q=31.0 size= 4096kB time=00:00:11.92 bitrate=2815.0kbits/s speed=2.62x
algo-1-poqk5_1 | [mp4 @ 0x55b8cc658900] Starting second pass: moving the moov atom to the beginning of the file
algo-1-poqk5_1 | frame= 300 fps= 65 q=31.0 Lsize= 4202kB time=00:00:11.96 bitrate=2877.9kbits/s speed=2.61x
algo-1-poqk5_1 | video:4199kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.052020%
algo-1-poqk5_1 | Stream mapping:
algo-1-poqk5_1 | Stream #0:0 -> #0:0 (mjpeg (native) -> mpeg4 (native))
正在编码为mpeg4。你需要一个更兼容的编解码器,比如 h.264
我正在使用以下命令使用 ffmpeg 从 jpegs 创建 mp4 视频:
ffmpeg -y -threads 0 -f image2 -i jpegs/%05d.jpg -framerate 10 video.mp4
生成的视频可以在 VLC 中正常播放,但无法通过以下方式在 Jupyter 笔记本中播放:
from IPython.display import Video
Video('video.mp4')
这个笔记本视频功能过去对我有用,所以我假设视频功能无法解决 codec/mime 类型的问题?
请求更新
我试过的新命令:
ffmpeg -y -framerate 10 -i jpegs/%05d.jpg -vf format=yuv420p -movflags +faststart video.mp4
视频在 VLC 中仍然可以正常播放,但在 Jupyter 中仍然无法播放。我查看了标记为的重复项,但实际上似乎不是同一个问题..
这是输出(我删除了帧率和线程标志以简化):
algo-1-poqk5_1 | 2020-11-18 21:19:36 [INFO]: ffmpeg output:
algo-1-poqk5_1 | 2020-11-18 21:19:36 [INFO]: ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
algo-1-poqk5_1 | built with gcc 7.2.0 (crosstool-NG fa8859cb)
algo-1-poqk5_1 | configuration: --prefix=/opt/conda --cc=/opt/conda/conda-bld/ffmpeg_1531088893642/_build_env/bin/x86_64-conda_cos6-linux-gnu-cc --disable-doc --enable-shared --enable-static --enable-zlib --enable-pic --enable-gpl --enable-version3 --disable-nonfree --enable-hardcoded-tables --enable-avresample --enable-libfreetype --disable-openssl --disable-gnutls --enable-libvpx --enable-pthreads --enable-libopus --enable-postproc --disable-libx264
algo-1-poqk5_1 | libavutil 56. 14.100 / 56. 14.100
algo-1-poqk5_1 | libavcodec 58. 18.100 / 58. 18.100
algo-1-poqk5_1 | libavformat 58. 12.100 / 58. 12.100
algo-1-poqk5_1 | libavdevice 58. 3.100 / 58. 3.100
algo-1-poqk5_1 | libavfilter 7. 16.100 / 7. 16.100
algo-1-poqk5_1 | libavresample 4. 0. 0 / 4. 0. 0
algo-1-poqk5_1 | libswscale 5. 1.100 / 5. 1.100
algo-1-poqk5_1 | libswresample 3. 1.100 / 3. 1.100
algo-1-poqk5_1 | libpostproc 55. 1.100 / 55. 1.100
algo-1-poqk5_1 | Input #0, image2, from '/opt/ml/model/outputs/01-IR.mp4_1/%05d.jpg':
algo-1-poqk5_1 | Duration: 00:00:12.00, start: 0.000000, bitrate: N/A
algo-1-poqk5_1 | Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
algo-1-poqk5_1 | Stream mapping:
algo-1-poqk5_1 | Stream #0:0 -> #0:0 (mjpeg (native) -> mpeg4 (native))
algo-1-poqk5_1 | Press [q] to stop, [?] for help
algo-1-poqk5_1 | [swscaler @ 0x55b8cc6fcc40] deprecated pixel format used, make sure you did set range correctly
algo-1-poqk5_1 | Output #0, mp4, to '/opt/ml/model/outputs/01-IR.mp4_1/video.mp4':
algo-1-poqk5_1 | Metadata:
algo-1-poqk5_1 | encoder : Lavf58.12.100
algo-1-poqk5_1 | Stream #0:0: Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc
algo-1-poqk5_1 | Metadata:
algo-1-poqk5_1 | encoder : Lavc58.18.100 mpeg4
algo-1-poqk5_1 | Side data:
algo-1-poqk5_1 | cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
algo-1-poqk5_1 | frame= 31 fps=0.0 q=31.0 size= 768kB time=00:00:01.20 bitrate=5242.8kbits/s speed=2.33x
algo-1-poqk5_1 | frame= 64 fps= 63 q=31.0 size= 1280kB time=00:00:02.52 bitrate=4161.0kbits/s speed=2.48x
algo-1-poqk5_1 | frame= 98 fps= 64 q=31.0 size= 1792kB time=00:00:03.88 bitrate=3783.5kbits/s speed=2.53x
algo-1-poqk5_1 | frame= 131 fps= 64 q=31.0 size= 2304kB time=00:00:05.20 bitrate=3629.7kbits/s speed=2.55x
algo-1-poqk5_1 | frame= 164 fps= 64 q=31.0 size= 2560kB time=00:00:06.52 bitrate=3216.5kbits/s speed=2.56x
algo-1-poqk5_1 | frame= 198 fps= 65 q=31.0 size= 3072kB time=00:00:07.88 bitrate=3193.6kbits/s speed=2.58x
algo-1-poqk5_1 | frame= 232 fps= 65 q=31.0 size= 3328kB time=00:00:09.24 bitrate=2950.6kbits/s speed= 2.6x
algo-1-poqk5_1 | frame= 266 fps= 66 q=31.0 size= 3840kB time=00:00:10.60 bitrate=2967.7kbits/s speed=2.62x
algo-1-poqk5_1 | frame= 299 fps= 66 q=31.0 size= 4096kB time=00:00:11.92 bitrate=2815.0kbits/s speed=2.62x
algo-1-poqk5_1 | [mp4 @ 0x55b8cc658900] Starting second pass: moving the moov atom to the beginning of the file
algo-1-poqk5_1 | frame= 300 fps= 65 q=31.0 Lsize= 4202kB time=00:00:11.96 bitrate=2877.9kbits/s speed=2.61x
algo-1-poqk5_1 | video:4199kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.052020%
algo-1-poqk5_1 | Stream mapping:
algo-1-poqk5_1 | Stream #0:0 -> #0:0 (mjpeg (native) -> mpeg4 (native))
正在编码为mpeg4。你需要一个更兼容的编解码器,比如 h.264