dtvfxzq3802 2015-03-10 18:59
浏览 185
已采纳

PHP注意:未定义的偏移量错误[重复]

This is my codes in compresser.php:

<?php

$filename = "isnotconverted_*";
$files = glob($filename);
$filefound = $files[0];

$new_filefound = str_replace( "isnotconverted_", '', $filefound );

$command = 'ffmpeg -i '.$filefound.' -b 64k -vf "movie=watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:0 [out]" '.$new_filefound;
exec( $command );

unlink( $filefound );

When I open compresser.php directly there is no error and everything is OK, but when I use putty and type /usr/local/bin/php /home/dltvbourse/public_html/compresser.php, I get this error:

PHP Notice:  Undefined offset: 0 in /home/dltvbourse/domains/dl.tvbourse.ir/public_html/compresser.php on line 5
ffmpeg version 0.7.11, Copyright (c) 2000-2011 the FFmpeg developers
  built on Mar  1 2015 14:55:21 with gcc 4.1.2 20080704 (Red Hat 4.1.2-55)
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-libmp3lame --enable-libx264 --enable-libfaac --enable-libvorbis --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvpx
  libavutil    50. 43. 0 / 50. 43. 0
  libavcodec   52.123. 0 / 52.123. 0
  libavformat  52.111. 0 / 52.111. 0
  libavdevice  52.  5. 0 / 52.  5. 0
  libavfilter   1. 80. 0 /  1. 80. 0
  libswscale    0. 14. 1 /  0. 14. 1
  libpostproc  51.  2. 0 / 51.  2. 0
-b: No such file or directory
PHP Warning:  unlink(): No such file or directory in /home/dltvbourse/domains/dl.tvbourse.ir/public_html/compresser.php on line 12

What should I do?

</div>
  • 写回答

2条回答 默认 最新

  • du8794 2015-03-10 20:23
    关注

    You should run the php file in the correct folder. So do a:

    cd /home/dltvbourse/public_html/
    /usr/local/bin/php compresser.php
    

    (in putty or whatever ssh client you are using).

    The reason this fails is because glob() uses the current directory as offset directory. Since no files of the pattern are probably placed in the initial directory it won't work.

    Furthermore it is perhaps safe to rewrite your program a bit. After all it is always possible that something goes wrong and no such file is placed in the directory. In that case you probably better check the size of the array and throw an error message.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵