hls-test.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. source test-common.sh
  3. if [ "x$Q" == "x1" ] && [ -z "$V" ]; then
  4. FFMPEG_Q="-v quiet"
  5. fi
  6. set -e
  7. HLS_DIR=hls-test-dir.$$
  8. mkdir -p $HLS_DIR
  9. # generate input sample
  10. audiowmark test-gen-noise $HLS_DIR/test-input.wav 200 44100
  11. # convert to hls
  12. ffmpeg $FFMPEG_Q -i $HLS_DIR/test-input.wav \
  13. -f hls \
  14. -c:a:0 aac -ab 192k \
  15. -master_pl_name replay.m3u8 \
  16. -hls_list_size 0 -hls_time 10 $HLS_DIR/as%v/out.m3u8
  17. # prepare hls segments for watermarking
  18. audiowmark hls-prepare $HLS_DIR/as0 $HLS_DIR/as0prep out.m3u8 $HLS_DIR/test-input.wav
  19. # watermark hls segments individually
  20. mkdir -p $HLS_DIR/as0m
  21. for i in $(cd $HLS_DIR/as0; ls out*.ts)
  22. do
  23. audiowmark hls-add $HLS_DIR/as0prep/$i $HLS_DIR/as0m/$i $TEST_MSG
  24. done
  25. cp $HLS_DIR/as0/out.m3u8 $HLS_DIR/as0m/out.m3u8
  26. # convert watermarked hls back to wav
  27. ffmpeg $FFMPEG_Q -y -i $HLS_DIR/as0m/out.m3u8 $HLS_DIR/test-output.wav
  28. # detect watermark from wav
  29. audiowmark_cmp --expect-matches 5 $HLS_DIR/test-output.wav $TEST_MSG
  30. rm $HLS_DIR/as0*/*.ts
  31. rm $HLS_DIR/as0*/out.m3u8
  32. rmdir $HLS_DIR/as0*
  33. rm $HLS_DIR/test-*.wav
  34. rm $HLS_DIR/replay.m3u8
  35. rmdir $HLS_DIR
  36. exit 0