[FFmpeg-user] Issues regarding Ffmpeg video HLS conversion command

Aditya Singh singha at marinepals.com
Wed Feb 7 15:19:53 EET 2024


The Ffmpeg command used to convert a video to HLS format can be also executed via php's exec() function.
We can dump the log in a php variable using following syntax with flag '2>&1'

command:
exec('ffmpeg -y -i "D:/HlsEncryptionProject/encTestVideo.mp4" -preset slow -g 48 -sc_threshold 0 -map 0:0 -map 0:1 -map 0:0 -map 0:1 -map 0:0 -map 0:1 -s:v:0 1920*1080 -b:v:0 286k -s:v:1 1280*720 -b:v:1 2500k -s:v:2 630*360 -b:v:2 1000k -c:a copy -var_stream_map "v:0,a:0,name:1080p v:1,a:1,name:720p v:2,a:2,name:360p" -master_pl_name "MLSFS002.m3u8" -f hls -hls_time 30 -hls_key_info_file "D:/HlsEncryptionProject/content/videos/enc.keyinfo" -hls_playlist_type vod -hls_list_size 0 -hls_segment_filename "D:/HlsEncryptionProject/content/videos/vid_%v/MLSFS002%d.ts" D:/HlsEncryptionProject/content/videos/MLSFS002/vid_%v/MLSFS002.m3u8 2>&1', $output, $returnCode);

Output:
"ffmpeg version 2023-01-01-git-62da0b4a74-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers",
  "  built with gcc 12.1.0 (Rev2, Built by MSYS2 project)",
  "  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint",
  "  libavutil      57. 43.100 / 57. 43.100",
  "  libavcodec     59. 55.103 / 59. 55.103",
  "  libavformat    59. 34.102 / 59. 34.102",
  "  libavdevice    59.  8.101 / 59.  8.101",
  "  libavfilter     8. 53.100 /  8. 53.100",
  "  libswscale      6.  8.112 /  6.  8.112",
  "  libswresample   4.  9.100 /  4.  9.100",
  "  libpostproc    56.  7.100 / 56.  7.100",
  "Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:/HlsEncryptionProject/encTestVideo.mp4':",
  "  Metadata:",
  "    major_brand     : isom",
  "    minor_version   : 512",
  "    compatible_brands: isomiso2avc1mp41",
  "    encoder         : Lavf55.33.100",
  "  Duration: 00:01:00.40, start: 0.000000, bitrate: 624 kb/s",
  "  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 630x332, 621 kb/s, 25 fps, 25 tbr, 12800 tbn (default)",
  "    Metadata:",
  "      handler_name    : VideoHandler",
  "      vendor_id       : [0][0][0][0]",
  "Stream map '0:1' matches no streams.",
  "To ignore this, add a trailing '?' to the map."


But when we try to generate error output (for example, via inputting a corrupt video url or by omitting a part of ffmpeg command) via these flags, then Ffmpeg is generating the same type of error mentioned above.

So the issue is every time when we want to log the error in case the tool fails to convert the video into HLS format,
Ffmpeg just generates same error. Are there some ways by which we can improve the logging system of ffmpeg
for error/warning logs? the command above is fixed and we want to find some verdict like what exactly happened
while executing the same command (w/ different values/dynamic values in command)



Also ffmpeg is not taking a localhost url for a video resource as the input in the command below when run via
php Apache xampp configuration in php:

'ffmpeg -y -i "http://localhost/HlsEncryptionProject/encTestVideo.mp4" -preset slow -g 48 -sc_threshold 0 -map 0:0 -map 0:1 -map 0:0 -map 0:1 -map 0:0 -map 0:1 -s:v:0 1920*1080 -b:v:0 286k -s:v:1 1280*720 -b:v:1 2500k -s:v:2 630*360 -b:v:2 1000k -c:a copy -var_stream_map "v:0,a:0,name:1080p v:1,a:1,name:720p v:2,a:2,name:360p" -master_pl_name "MLSFS002.m3u8" -f hls -hls_time 30 -hls_key_info_file "D:/HlsEncryptionProject/content/videos/MLSFS002/enc.keyinfo" -hls_playlist_type vod -hls_list_size 0 -hls_segment_filename "D:/HlsEncryptionProject/content/videos/MLSFS002/vid_%v/MLSFS002%d.ts" D:/HlsEncryptionProject/content/videos/MLSFS002/vid_%v/MLSFS002.m3u8'

Pls help resolve these queries!!


More information about the ffmpeg-user mailing list