php 我收到错误“使用了已弃用的像素格式,请确保您使用 ffmpeg 正确设置了范围”..有人可以检查我下面的代码吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43038294/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Im getting error "deprecated pixel format used, make sure you did set range correctly using ffmpeg".. can someone check my code below?
提问by Mavs Mavs
This is my code using ffmpeg i want to have video thumbnail but im not familiar in ffmpeg can someone know the error i got.
这是我使用 ffmpeg 的代码,我想要视频缩略图,但我对 ffmpeg 不熟悉,有人知道我遇到的错误吗?
[swscaler @ 0x7ff8da028c00] deprecated pixel format used, make sure you did set range correctly
Output #0, mjpeg, to 'image.jpg':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf56.36.100
Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 320x240 [SAR 4:3 DAR 16:9], q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc (default)
Metadata:
creation_time : 2016-11-06 09:40:22
handler_name : ISO Media file produced by Google Inc.
encoder : Lavc56.41.100 mjpeg
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame= 1 fps=0.0 q=4.8 Lsize= 16kB time=00:00:01.00 bitrate= 129.5kbits/s
video:16kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Also This is my code:
另外这是我的代码:
$video_url ='https://URL/upload/4b8acab123563649f19e07450d810df6.mp4';
$ffmpeg = '/opt/local/bin/ffmpeg';
$image = 'image.jpg';
$interval = 5;
$size = '320x240';
shell_exec($tmp = "$ffmpeg -i $video_url -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1");
回答by Louis Loudog Trottier
According to ffmpeg forum this can be ignored when called from the command line and i always ignored it. One thing you can try (test with a dummy file PLEASE) is to add -pix_fmt yuvj422p
to your last line so it look like this:
根据 ffmpeg 论坛,从命令行调用时可以忽略它,我总是忽略它。您可以尝试的一件事(请使用虚拟文件进行测试)是添加-pix_fmt yuvj422p
到您的最后一行,使其看起来像这样:
shell_exec($tmp = "$ffmpeg -i $video_url -pix_fmt yuvj422p -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1");
As i said, test it please as i cannot guaratee the results but as far as i'm concerned i'Ve used ffmpeg thousand of times and everything looks just fine even with the warning.
正如我所说,请测试它,因为我无法保证结果,但就我而言,我已经使用了 ffmpeg 数千次,即使有警告,一切看起来也很好。
https://lists.ffmpeg.org/pipermail/ffmpeg-user/2014-February/020151.html
https://lists.ffmpeg.org/pipermail/ffmpeg-user/2014-February/020151.html
Afaict, the warning is primarily meant for library users, ffmpeg users should not be affected.
OK, will just ignore it then.
Afaict,警告主要针对图书馆用户,ffmpeg 用户不应该受到影响。
好吧,那就忽略它吧。
回答by Mavs Mavs
I just change the path of the destination of the image:
我只是更改图像目的地的路径:
# path of image on the server
$image = '/users/xx/xxxx/sample/upload/image.jpg';
Then used the following:
然后使用了以下内容:
# $ffmpeg - path of ffmpeg on the server
# $video_url - path of the video file on the server
shell_exec($tmp = "$ffmpeg -i $video_url -pix_fmt yuvj422p -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1");