I want to read HEVC compressed video and extract the frames in compressed(encoded) video file to extract some information from frames like motion vectors etc..
can anyone help me how to read the compressed HEVC video file, and how to extract frames using matlab in windows OS.
VideoReader in matlab will read upto H.264 encoded videos but not H.265/HEVC encoded videos.
I have downloaded few HEVC compressed videos from http://www.elecard.com/en/download/videos.html and downloaded the codec tool kit from this website , I can play these videos.
There is no official release for HEVC/H.265 codec in MATLAB because HEVC is not a royalty-free software and it is the reason that the tech Giants make an alternative video coding without any licensing fee. Therefore, HEVC is currently used mostly in scientific literature nowadays.
However, you can encode/decode YUV format video data in HEVC using HM reference software which is available in this link. To encode, you need Visual Studio installed on your Windows machine. Firstly, open your command prompt and type:
msbuild /p:Configuration=Release HM_vc2015.sln
After building the project, you can find some files in /bin folder. Then, you should change your current directory to /bin folder using cd command and type:
TAppEncoderStatic.exe -c your_config_file.cfg -i your_video_data.yuv
Hence, str.bin file will be created in /bin folder which can be renamed using your_config_file.cfg or command-line options which is thoroughly explained in the software manual. Also, you can find good config files in the /cfg folder. To decode the str.bin just type:
TAppDecoderStatic.exe -b str.bin -o dec.yuv
Note that dec.yuv is the decoded output video data in the decoder. Also, you can see the decoded and original video sequence using a YUV viewer. Moreover, you can find a good dataset here.
AFAIK there is no public code or library that enables reading an HEVC datastream directly from MATLAB.
When faced with this same problem, I modified the reference HEVC decoder to write a separate CSV file as it decodes the HEVC video. MATLAB can then read the CSV file.
I borrowed this approach from GitlHEVCAnalyzer. See TSysuAnalyzerOutput.cpp, where the author writes a number of different text files during HEVC decoding. The analyzer then reads the text files.
Related
I followed this link which is on a similar topic. But even after completing the steps mentioned in the link i' am not able to play any mp4 files. I have also tried removing the args.gn file in out/Release folder and recompiling the whole project. That too didn't resolve the issue.
My args.gn file has following contents:
clang_use_chrome_plugins=false
enable_basic_printing=true
enable_linux_installer=false
enable_nacl=false
enable_print_preview=true
enable_rigel=true
enable_service_discovery=false
enable_widevine=true
fatal_linker_warnings=false
ffmpeg_branding="Chrome"
forbid_non_component_debug_builds=false
is_component_build=false
is_debug=false
is_official_build=true
optimize_webui=true
proprietary_codecs=true
target_cpu="x64"
use_bundled_fontconfig=false
use_gtk=false
use_sysroot=false
To enable H264 codec it is enough to set ffmpeg_branding=Chrome proprietary_codecs=true GN defines.
If by MP4 you mean videos with MP4 container then to support these it is required to make additional code changes to Chromium.
Try testing with these sites:
https://tools.woolyss.com/html5-audio-video-tester/
https://lab.html5test.com/codecs/
Hi I am relatively new to Matlab and need to analyze data for a research project. Basically I am importing .csv file into matlab as well as a video and audio file in order to see if I can find a correlation. I've successfully imported the csv file but I am unable to import video and audio. Furthermore once I have uploaded it into matlab I need to align the data from the CSV file and audio and video.
Matlab has several built-in utilities for this.
Try using the VideoReader and audioread to import your video and audio respectively. You can look at the Matlab documentation for each of these functions for more information on their properties.
The last part of your question is too vague. You need to specify what format the data from the CSV is in, what its relationship to the video is, and what kind of alignment you want.
I am doing a project in which I have a video I divide the video into frames and then the image steganography is applied to the frames and the encoded frames are generated. Then the encoded frames are to be converted into video again. All of the methods are applied successfully but the only problem is that I get the encoded video which is very large then the original video. I am using the movie2avi function to generate the video.
Can someone suggest any way to generate the video which is not very large compared to the original video?
First, if you're using movie2avi, you have a limited choice of very poor codecs (compression formats). If you have a new enough version of Matlab (R2009b+ I think) you should be using the VideoWriter class instead. The choice of codecs is still not very good, but they are of much better quality. You didn't indicate which codec (or OS) you're using so I can't recommend an alternative.
Second, even under ideal circumstances you should expect your movie file to get larger with what you're doing unless you apply additional compression. Adding steganographic content is akin to adding noise so you're making the data harder to compress. In both movie2avi and VideoWriter you can adjust the compression level or quality depending on the codec. Also, the default movie2avi codec under Linux and OS X uses no compression so the file will be huge if you haven't changed that.
If VideoWriter doesn't meet your needs (or if your version doesn't have it) you can try my QTWriter class on GitHub that allows one to export QuickTime movies in Matlab. It works very much like VideoWriter, but allows you to create high quality QuickTime movies using a few image-based codecs. No inter-frame compression is used and the PNG and TIFF formats are lossless (this may be important to your steganographic application) while being very efficient at encoding content like that often generated in Matlab. There is also a JPEG format that may be better suited to general images. The QuickTime files can then be converted to other formats if needed. You can read more and see examples here and download the single M-file here.
This is completely dependent on what you are trying to hide in the original video. Remember that the original video is using a compression codec that can take advantage of minimal change frame to frame and various other things, but if you go and try to hide something in that video through steganography, you are making it more difficult for the compression algorithm to do that, which will definitely result in a larger file. So you have to be careful what you are attempting to do, and how you are attempting to encode it.
I want to use mp4 file format for live streaming, which is not possible with an unfragmented mp4 file, as the moov atom is generally written at the end of the file. I need to generate a fragmented mp4 file to transfer it over a network for live streaming. I am using libavformat. The problem is, I can write unfragmented mp4 files easily with libavformat, but I don't know how to write a fragmented mp4 file. So, how to write a fragmented mp4 file using libavformat?
I don't think you are looking for fragmented mp4 (FYI a fragmented mp4 is usually called .ismv) ISMV requires a media server and specialized client to stream.
I think what you are looking for is faststart. This simply moves the moov atom to the start of the file. ffmpeg comes with a qt-faststart utility that will do this for you. Check you distrobution.
You can use Bento4 library to do this easily. Download from here http://www.bento4.com/downloads/ and use the binary mp4fragment.
mp4fragment sourcefile destinatiofile
I would like to create a quicktime movie from a sequence of still frames via perl. It seems like there should be a relatively simple way to do this, but so far I have not found it. Things I've tried:
Reading the Quicktime file spec and creating the movie file from scratch. This low level approach has worked well for me in the past with TIFF and PDF file formats, but Quicktime seems dauntingly complicated.
Looking at the various quicktime-related perl modules. So far I haven't found one that lets me do what I want (images --> movie) with a minimum of fuss.
Using Applescript and Quicktime Player. This would probably work if I paid for Quicktime Pro, but I'd prefer not to do that.
I'm interested in any suggestions (even non-perl-based ones) for a relatively simple way to assemble a sequence of images into a quicktime movie.
Video encoding isn't really an ideal job for perl -- there are a lot of pieces to put together. I would suggest just using mencoder -- you can use an input of e.g. -mf type=png:fps=30 mf://frame*.png, and an output format of e.g. -of lavf -ovc lavc -lavcopts vcodec=libx264 -o whatever.mov. If you want to dub in audio you can use -audiofile whatever.mp3, and then either -acodec copy if you want it to be MP3 in the movie as well, or perhaps -acodec faac (and -faacopts) if the audio format in the movie needs to be AAC. There are lots of different options to tweak and things to learn but it's pretty much the ideal tool for the job. FFmpeg is nicer to use in a lot of ways, but it doesn't have the mf:// input mode, which makes assembling a video from frames a lot more painful.