This example shows how to do VAAPI-accelerated transcoding.Usage: vaapi_transcode input_stream codec output_stream e.g: - vaapi_transcode input.mp4 h264_vaapi output_h264.mp4
#include <stdio.h>
#include <errno.h>
{
return *p;
}
fprintf(stderr, "Unable to decode this file using VA-API.\n");
}
{
int ret;
fprintf(stderr, "Cannot open input file '%s', Error code: %s\n",
return ret;
}
fprintf(stderr, "Cannot find input stream information. Error code: %s\n",
return ret;
}
if (ret < 0) {
fprintf(stderr, "Cannot find a video stream in the input file. "
return ret;
}
fprintf(stderr, "avcodec_parameters_to_context error. Error code: %s\n",
return ret;
}
fprintf(stderr, "A hardware device reference create failed.\n");
}
fprintf(stderr, "Failed to open codec for decoding. Error code: %s\n",
return ret;
}
{
int ret = 0;
fprintf(stderr,
"Error during encoding. Error code: %s\n",
av_err2str(ret));
}
while (1) {
if (ret)
break;
if (ret < 0) {
fprintf(stderr, "Error during writing data to output file. "
return -1;
}
}
return 0;
ret = ((ret ==
AVERROR(EAGAIN)) ? 0:-1);
return ret;
}
{
int ret = 0;
if (ret < 0) {
fprintf(stderr,
"Error during decoding. Error code: %s\n",
av_err2str(ret));
return ret;
}
while (ret >= 0) {
return 0;
} else if (ret < 0) {
fprintf(stderr,
"Error while decoding. Error code: %s\n",
av_err2str(ret));
}
}
fprintf(stderr, "Failed to open encode codec. Error code: %s\n",
}
fprintf(stderr, "Failed to allocate stream for output format.\n");
}
if (ret < 0) {
fprintf(stderr, "Failed to copy the stream parameters. "
}
fprintf(stderr, "Error while writing stream header. "
}
}
fprintf(stderr, "Error during encoding and writing.\n");
if (ret < 0)
return ret;
}
return 0;
}
int main(
int argc,
char **argv)
{
int ret = 0;
if (argc != 4) {
fprintf(stderr, "Usage: %s <input file> <encode codec> <output file>\n"
"The output format is guessed according to the file extension.\n"
"\n", argv[0]);
return -1;
}
if (ret < 0) {
fprintf(stderr,
"Failed to create a VAAPI device. Error code: %s\n",
av_err2str(ret));
return -1;
}
fprintf(stderr, "Could not find encoder '%s'\n", argv[2]);
ret = -1;
}
fprintf(stderr, "Failed to deduce output format from file extension. Error code: "
}
}
if (ret < 0) {
fprintf(stderr, "Cannot open output file. "
}
while (ret >= 0) {
break;
ret =
dec_enc(&dec_pkt, enc_codec);
}
ret =
dec_enc(&dec_pkt, enc_codec);
return ret;
}