Class VideoSteg
- java.lang.Object
-
- steganography.video.VideoSteg
-
- All Implemented Interfaces:
Steganography
public class VideoSteg extends java.lang.Object implements Steganography
- Since:
- : 23-11-2020
- Author:
- : Enrico Gamil Toros de Chadarevian Project name : ProjektStudiumSteganography
-
-
Constructor Summary
Constructors Constructor Description VideoSteg()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
decode(byte[] steganographicData)
Extract the hidden Payload from a Steganographic Videobyte[]
decode(byte[] steganographicData, long seed)
Extract the hidden Payload from a Steganographic Video using a custom seedbyte[]
encode(byte[] carrier, byte[] payload)
UsesetMaxEncodingThreads(int)
andsetMaxDecodingThreads(int)
to enable multithreading (by default single threaded).byte[]
encode(byte[] carrier, byte[] payload, long seed)
UsesetMaxEncodingThreads(int)
andsetMaxDecodingThreads(int)
to enable multithreading (by default single threaded).java.io.File
getFfmpegBin()
Get path of ffmpeg binlong
getVideoCapacity(byte[] carrier)
Returns the maximum number of bytes that can be encoded in the given video.long
getVideoCapacity(java.util.List<byte[]> pictureList)
Returns the maximum number of bytes that can be encoded in the given video.boolean
isSteganographicData(byte[] data)
Tests whether the given data has a hidden message encoded in it.boolean
isSteganographicData(byte[] data, long seed)
Tests whether the given data has a hidden message encoded in it.void
setDebug(boolean debug)
void
setFfmpegBin(java.io.File ffmpegBin)
If another version or a different distribution of ffmpeg or ffprobe should be used you can set the File path here.void
setMaxDecodingThreads(int maxDecodingThreads)
Set the number of threads used to decode the pictures WARNING very memory expensive might overflow max JVM heap VM option: -Xmx might help By default using 1 Threads To use multithreading set maxDecodingThreads higher than 1void
setMaxEncodingThreads(int maxEncodingThreads)
Set the number of threads used to encode the pictures WARNING very memory expensive might overflow max JVM heap VM option: -Xmx might help By default using 1 Threads To use multithreading set maxEncodingThreads higher than 1
-
-
-
Method Detail
-
encode
public byte[] encode(byte[] carrier, byte[] payload) throws java.io.IOException, UnsupportedImageTypeException, NoImageException, ImageWritingException, ImageCapacityException, VideoCapacityException, VideoNotFoundException, UnsupportedVideoTypeException
UsesetMaxEncodingThreads(int)
andsetMaxDecodingThreads(int)
to enable multithreading (by default single threaded).We also highly recommend to set call
ImageIO.setUseCache(boolean)
. This will make the decoding way faster since the images will be stored in-memory and not cached on disk (will be Memory demanding)- Specified by:
encode
in interfaceSteganography
- Parameters:
carrier
- media used to hide the payloadpayload
- data to hide- Returns:
- steganographic data - exact media representation. Can be stored as it is to a file to open externally
- Throws:
java.io.IOException
- if a problem occurs during reading of carrier or payloadUnsupportedImageTypeException
NoImageException
ImageWritingException
ImageCapacityException
VideoCapacityException
VideoNotFoundException
UnsupportedVideoTypeException
-
encode
public byte[] encode(byte[] carrier, byte[] payload, long seed) throws java.io.IOException, VideoCapacityException, UnsupportedImageTypeException, NoImageException, ImageWritingException, ImageCapacityException, VideoNotFoundException, UnsupportedVideoTypeException
UsesetMaxEncodingThreads(int)
andsetMaxDecodingThreads(int)
to enable multithreading (by default single threaded).We highly recommend to set call
ImageIO.setUseCache(boolean)
. This will make the decoding way faster since the images will be stored in-memory and not cached on disk (will be Memory demanding)- Specified by:
encode
in interfaceSteganography
- Parameters:
carrier
- media used to hide the payloadpayload
- data to hideseed
- affects the resulting steganographic data (similar to a password)- Returns:
- steganographic data - exact media representation. Can be stored as it is to a file to open externally
- Throws:
java.io.IOException
- if a problem occurs during reading of carrier or payloadVideoCapacityException
UnsupportedImageTypeException
NoImageException
ImageWritingException
ImageCapacityException
VideoNotFoundException
UnsupportedVideoTypeException
-
decode
public byte[] decode(byte[] steganographicData) throws java.io.IOException, VideoNotFoundException, UnsupportedVideoTypeException
Extract the hidden Payload from a Steganographic Video- Specified by:
decode
in interfaceSteganography
- Parameters:
steganographicData
- Media containing the hidden message to decode- Returns:
- the hidden message as a byte array
- Throws:
java.io.IOException
- if a problem occurs during reading of steganographicDataVideoNotFoundException
UnsupportedVideoTypeException
-
decode
public byte[] decode(byte[] steganographicData, long seed) throws java.io.IOException, VideoNotFoundException, UnsupportedVideoTypeException
Extract the hidden Payload from a Steganographic Video using a custom seed- Specified by:
decode
in interfaceSteganography
- Parameters:
steganographicData
- Media containing the hidden message to decodeseed
- seed that was used to encode the given stenographicData- Returns:
- the hidden message as a byte array
- Throws:
java.io.IOException
- if a problem occurs during reading of steganographicDataVideoNotFoundException
UnsupportedVideoTypeException
-
isSteganographicData
public boolean isSteganographicData(byte[] data) throws java.io.IOException, UnsupportedMediaTypeException, MediaNotFoundException
Description copied from interface:Steganography
Tests whether the given data has a hidden message encoded in it. This method only works if the message was encoded using the given Seed or the respective default Seed. Otherwise it will always return false.
The use of this method is discouraged. It saves very little resources compared to decode(...). So unless you need to test a lot of possible steganographicData, just use decode(...) and catch the UnknownStegFormatException
- Specified by:
isSteganographicData
in interfaceSteganography
- Parameters:
data
- data to test- Returns:
- true if the given data has a hidden message encoded in it
- Throws:
java.io.IOException
- if a problem occurs during reading of dataUnsupportedMediaTypeException
- if the Media Type (e.g. JPG) is not supportedMediaNotFoundException
- if the intended media (e.g. Image, Video, ...) could not be read from data
-
isSteganographicData
public boolean isSteganographicData(byte[] data, long seed) throws java.io.IOException, MediaNotFoundException, UnsupportedMediaTypeException
Description copied from interface:Steganography
Tests whether the given data has a hidden message encoded in it. This method only works if the message was encoded using the given Seed. Otherwise it will always return false.
The use of this method is discouraged. It saves very little resources compared to decode(...). So unless you need to test a lot of possible steganographicData, just use decode(...) and catch the UnknownStegFormatException
- Specified by:
isSteganographicData
in interfaceSteganography
- Parameters:
data
- data to testseed
- seed the hidden message was encoded with- Returns:
- true if the given data has a hidden message encoded in it
- Throws:
java.io.IOException
- if a problem occurs during reading of dataMediaNotFoundException
- if the intended media (e.g. Image, Video, ...) could not be read from dataUnsupportedMediaTypeException
- if the Media Type (e.g. JPG) is not supported
-
setMaxEncodingThreads
public void setMaxEncodingThreads(int maxEncodingThreads)
Set the number of threads used to encode the pictures WARNING very memory expensive might overflow max JVM heap VM option: -Xmx might help By default using 1 Threads To use multithreading set maxEncodingThreads higher than 1- Parameters:
maxEncodingThreads
- max number of Threads used to encode
-
setMaxDecodingThreads
public void setMaxDecodingThreads(int maxDecodingThreads)
Set the number of threads used to decode the pictures WARNING very memory expensive might overflow max JVM heap VM option: -Xmx might help By default using 1 Threads To use multithreading set maxDecodingThreads higher than 1- Parameters:
maxDecodingThreads
- max number of Threads used to decode
-
setDebug
public void setDebug(boolean debug)
-
getVideoCapacity
public long getVideoCapacity(byte[] carrier) throws java.io.IOException, NoImageException, UnsupportedImageTypeException, VideoNotFoundException, UnsupportedVideoTypeException
Returns the maximum number of bytes that can be encoded in the given video.- Parameters:
carrier
- carrier to be used (Video)- Returns:
- max amount of total number of bytes that can be encoded in the carrier
- Throws:
java.io.IOException
- if IO Exception occursNoImageException
- Thrown if the attempt to read an image failed.UnsupportedImageTypeException
- Thrown if an operation was attempted on an image type it doesn't support. This can happen if the frames can't be read as PNGVideoNotFoundException
- Thrown if a Video stream was not found in the given video carrierUnsupportedVideoTypeException
- Thrown if the used encoding is not supportedNoImageException
- Thrown if Video has Video stream but is empty
-
getVideoCapacity
public long getVideoCapacity(java.util.List<byte[]> pictureList) throws java.io.IOException, NoImageException, UnsupportedImageTypeException
Returns the maximum number of bytes that can be encoded in the given video.- Parameters:
pictureList
- list of pictures that will be encoded- Returns:
- max amount of total number of bytes that can be encoded in the carrier
- Throws:
java.io.IOException
- if IO Exception occursNoImageException
- Thrown if the attempt to read an image failed.UnsupportedImageTypeException
- Thrown if an operation was attempted on an image type it doesn't support.
-
setFfmpegBin
public void setFfmpegBin(java.io.File ffmpegBin)
If another version or a different distribution of ffmpeg or ffprobe should be used you can set the File path here.- Parameters:
ffmpegBin
- File pointing the Path of ffmpeg and ffprobe
-
getFfmpegBin
public java.io.File getFfmpegBin()
Get path of ffmpeg bin- Returns:
- File where ffmpeg is searched
-
-