encryptionffmpegelectronwatermarkffplay

play encrypted video and add watermark using ffplay in electron (or nodejs)


I'm using electron(you can consider it as nodejs) for making a player for playing encrypted videos. using code below I'm able to encypt videos

exec( ffmpeg -i "${file}" -encryption_scheme cenc-aes-ctr -encryption_key ${encryptionKey} -encryption_kid ${encryptionKey} "${pathWithoutExtension}".CONVERTED.${extension} )

and using this command I'm able to decypt and at the same time play the video

exec(
    `ffplay "${fileFullPath}"  -decryption_key ${encryptionKey} `,
    (error) => {
      console.log(error)
    }
  )

my question is :how can I add text watermark to this video during play time and kind of combine decryption job to add text watermark. I tried this command but it doesn't work.it add watermark but decryption doesn't work

exec( ffplay "${fileFullPath}" -vf "drawtext=text='Place text here':x=10:y=H-th-10: fontfile=/path/to/font.ttf:fontsize=12:fontcolor=white: shadowcolor=black:shadowx=5:shadowy=5", -decryption_key ${encryptionKey} , (error) => { console.log(error) } )


Solution

  • finaly find the solution: this command added text watermark to encrypted file and show it during playtime

     exec( `ffplay "${fileFullPath}" -decryption_key ${encryptionKey} -vf 
     drawtext=fontfile='c\:/Windows/Fonts/Arial.ttf':text='Place text here'
    :fontsize=48:x=100:y=100"`,
            (error) => {
              console.log(error) 
            }
          )