36

This is my code using ffmpeg I want to have video thumbnail but I'm not familiar in ffmpeg can someone know the error I got.

[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");  
Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Mavs Mavs
  • 409
  • 1
  • 4
  • 10

2 Answers2

34

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:

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 guarantee 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.

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.

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Louis Loudog Trottier
  • 1,367
  • 13
  • 26
  • but i cant get any image file when i execute it. – Mavs Mavs Mar 27 '17 at 05:27
  • where can i add this -pix_fmt yuvj422p – Mavs Mavs Mar 27 '17 at 05:28
  • i change the path of my destination and i get it .. i dont use url path just the path of the server.. thanks by the way :) – Mavs Mavs Mar 27 '17 at 05:32
  • if that ain'T working i cannot help you further more. Like i said, you can ignore this warning... Or turn log level down with -loglevel 8 or -loglevel 16. See the docs: https://ffmpeg.org/ffmpeg.html – Louis Loudog Trottier Mar 27 '17 at 05:33
  • I get error when typing 422 instead of 420: `deprecated pixel format used, make sure you did set range correctly No pixel format specified, yuv422p for H.264 encoding chosen. Use -pix_fmt yuv420p for compatibility with outdated media players.` – Zimba Mar 06 '21 at 09:21
  • Hey, I can't ignore it because I try to stream something and I get this warning 5 times a second flooding my terminal. What should I do than? – Konrad Nov 23 '21 at 19:17
  • 1
    @KonradLinkowski: at least a couple of options: (1) turn off warning output from `ffmpeg`, e.g. with `-loglevel error`; (2) update your input data to not have colors with component values outside the range 16–235 (see https://superuser.com/a/1273941/57367 ) [how to do that depends on how the input is generated/sourced, of course, so I can't answer that here, but in my case, just using very light and dark greys instead of white and black in my image generator worked great]. One or the other of those should quiet things down. – lindes Apr 12 '22 at 20:55
0

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");  
Jonny Henly
  • 4,023
  • 4
  • 26
  • 43
Mavs Mavs
  • 409
  • 1
  • 4
  • 10