Aws-sdk-php putobject with ffmpeg .m3u8& .ts格式

时间:2018-04-12 14:31:24

标签: amazon-s3 ffmpeg aws-sdk ffmpeg-php aws-php-sdk

我无法发送hls视频。 aws-sdk-php mp4视频效果不错但hls个视频仅发送.m3u8个文件.ts文件local storage

这是我的实际代码。提交-ffmpeg.php:

  $ffmpeg_b = $pt->config->ffmpeg_binary_file;
  $filepath = explode('.', $_POST['video-location'])[0];
  $time     = time();
  $full_dir = str_replace('ajax', '/', __DIR__);

 $structure = $filepath;

 if (!mkdir($structure, 0777, true)) {
   die('Failed to create folders...');
 }
 $hls_link = $structure . "/_360p_converted.m3u8";

 $video_file_full_path = $full_dir . $_POST['videolocation'];
 $shell                = shell_exec("$ffmpeg_b -y -i $video_file_full_path -vcodec copy -acodec copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls $hls_link 2>&1");
 $upload_s3            = PT_UploadToS3($filepath . "/_360p_converted.m3u8");
 $db->where('id', $insert);
 $db->update(T_VIDEOS, array( 
   'converted' => 1,
   '360p' => 1,
   'video_location' => $filepath . "/_360p_converted.m3u8"
 ));

function.php aws-sdk-php中发送的文件

 $s3->putObject([
    'Bucket' => $pt->config->s3_bucket_name,
    'Key'    => $filename,
    'Body'   => fopen($filename, 'r+'),
    'ACL'    => 'public-read',
 ]);

0 个答案:

没有答案