Transcodes a media file from H.264/AVC to H.265/HEVC using AVBlocks Transcoder with hardcoded input and output file paths.
This sample demonstrates the basic AVBlocks transcoding workflow:
- Initialize the AVBlocks library
- Create a
MediaInfoobject to probe the input file - Create an input
MediaSocketfrom the probed media info - Create an output
MediaSocketusing a preset (MP4 / H.264 (AVC) + AAC) and change the video stream type toH.265 (HEVC) - Configure a
Transcoderwith the input and output sockets - Run the transcode operation
No command line parsing is used — the input and output file paths are hardcoded in the source code.
From the repository root:
mkdir -p build/debug_x64
cd build/debug_x64
cmake -G 'Ninja' -DCMAKE_BUILD_TYPE=debug -DPLATFORM=x64 ../../samples
ninjaThe built executable will be placed in bin/x64/simple_converter.
-
Download the sample video:
curl -L -o Wildlife_h264_aac.mp4 https://archive.org/download/WildlifeSampleVideo/Wildlife.mp4
-
Run the sample from the sample directory (the input/output file paths are relative to the working directory):
cd samples/linux/simple_converter ../../../bin/x64/simple_converter -
The transcoded output file
Wildlife_h265_aac.mp4will be created in thesamples/linux/simple_converterdirectory.
- The input file
Wildlife_h264_aac.mp4and output fileWildlife_h265_aac.mp4paths are hardcoded insimple_converter.cpp. They are relative to the working directory from which the executable is run. - If
transcoder->open()fails, it may be becauseWildlife_h265_aac.mp4already exists in the directory. Delete the output file and try again. - The output uses the
Preset::Video::Generic::MP4::Base_H264_AACpreset with the video stream type changed toStreamType::H265, producing an MP4 container with H.265 video and AAC audio streams.