Discussion:
[Libav-user] Using LibX264 with ffmpeg libraries
Noah Arc
2012-07-11 18:22:16 UTC
Permalink
Hi all;
I've just switched to the newer ffmpeg versions (I always used ffmpeg 0.6), it is a big jump for me and I'm trying to figure out how to implement some of the changes.
In the past, libx264 variables such as crf was a part of AVCodecContext. However, looks like in version 0.11 it has been deprecated and was moved to libx264.c as a private variable. But for my project, I'm used to just assign a value to crf (of a ptr of type AVCodecContext). Could someone please give me a hint on how I could implement the API changes?
Thank you very much!Cheers
Aleksey Shubin
2012-07-12 00:36:25 UTC
Permalink
Hi Noah,

char *crfString = new char[50];
sprintf_s(crfString, 50, "%f", crf);
av_opt_set(codecContext->priv_data, "crf", crfString, 0);

Don't sure if it is the best way (to convert to string first) but I
didn't find a variant of av_opt_set for floating point values, and at
least it works.
Post by Noah Arc
Hi all;
I've just switched to the newer ffmpeg versions (I always used ffmpeg
0.6),
it is a big jump for me and I'm trying to figure out how to implement some
of the changes.
In the past, libx264 variables such as crf was a part of AVCodecContext.
However, looks like in version 0.11 it has been deprecated and was moved
to
libx264.c as a private variable. But for my project, I'm used to just
assign
a value to crf (of a ptr of type AVCodecContext). Could someone please
give
me a hint on how I could implement the API changes?
Thank you very much!
Cheers
_______________________________________________
Libav-user mailing list
http://ffmpeg.org/mailman/listinfo/libav-user
noahzarc
2012-07-20 19:14:28 UTC
Permalink
Hey thanks for your solution! Unfortunately this did not work as for some
reason av_opt_set doesn't behave like a global function, as in even if I
include the opt.h header file I still get an error saying "'av_opt_set':
identifier not found".

My project is built under VS2005, and I've cross compiled ffmpeg with MinGW.
Are there any other ways to set crf in priv_data?

Thanks & cheers
Post by Aleksey Shubin
Hi Noah,
char *crfString = new char[50];
sprintf_s(crfString, 50, "%f", crf);
av_opt_set(codecContext->priv_data, "crf", crfString, 0);
Don't sure if it is the best way (to convert to string first) but I
didn't find a variant of av_opt_set for floating point values, and at
least it works.
Post by Noah Arc
Hi all;
I've just switched to the newer ffmpeg versions (I always used ffmpeg
0.6),
it is a big jump for me and I'm trying to figure out how to implement some
of the changes.
In the past, libx264 variables such as crf was a part of AVCodecContext.
However, looks like in version 0.11 it has been deprecated and was moved
to
libx264.c as a private variable. But for my project, I'm used to just
assign
a value to crf (of a ptr of type AVCodecContext). Could someone please
give
me a hint on how I could implement the API changes?
Thank you very much!
Cheers
_______________________________________________
Libav-user mailing list
http://ffmpeg.org/mailman/listinfo/libav-user
_______________________________________________
Libav-user mailing list
http://ffmpeg.org/mailman/listinfo/libav-user
--
View this message in context: http://libav-users.943685.n4.nabble.com/Libav-user-Using-LibX264-with-ffmpeg-libraries-tp4655395p4655450.html
Sent from the libav-users mailing list archive at Nabble.com.
Nicolas George
2012-07-20 20:58:57 UTC
Permalink
Post by Noah Arc
In the past, libx264 variables such as crf was a part of AVCodecContext.
However, looks like in version 0.11 it has been deprecated and was moved
to libx264.c as a private variable. But for my project, I'm used to just
assign a value to crf (of a ptr of type AVCodecContext). Could someone
please give me a hint on how I could implement the API changes?
You are supposed to pass the options as the third argument to avcodec_open2.
There is an example in the documentation of the function.

Please refrain from top-posting on this mailing list; and if you did not
understand what it means, look it up.

Regards,
--
Nicolas George
noahzarc
2012-07-23 13:34:47 UTC
Permalink
Post by Nicolas George
Post by Noah Arc
In the past, libx264 variables such as crf was a part of AVCodecContext.
However, looks like in version 0.11 it has been deprecated and was moved
to libx264.c as a private variable. But for my project, I'm used to just
assign a value to crf (of a ptr of type AVCodecContext). Could someone
please give me a hint on how I could implement the API changes?
You are supposed to pass the options as the third argument to
avcodec_open2.
There is an example in the documentation of the function.
Please refrain from top-posting on this mailing list; and if you did not
understand what it means, look it up.
Regards,
--
Nicolas George
_______________________________________________
Libav-user mailing list
http://ffmpeg.org/mailman/listinfo/libav-user
Apologies for top posting, it's my very first time using a mailing list.

If you are talking about the "muxing.c" example under doc, yes I have looked
at it and attempted to implement similar format in my code. However as I
stated before, I get the "identifier not found" error at compiling time. I
have included opt.h and avcodec.h avformat.h at the top of my code, so I'm
just wondering if there are anything else I need to include.

P.S. when I right click on the function and "jump to definition", it
actually jumps to the function deceleration in opt.h.

Cheers



--
View this message in context: http://libav-users.943685.n4.nabble.com/Libav-user-Using-LibX264-with-ffmpeg-libraries-tp4655395p4655467.html
Sent from the libav-users mailing list archive at Nabble.com.
noahzarc
2012-07-23 18:36:59 UTC
Permalink
Post by Nicolas George
Post by Noah Arc
In the past, libx264 variables such as crf was a part of AVCodecContext.
However, looks like in version 0.11 it has been deprecated and was moved
to libx264.c as a private variable. But for my project, I'm used to just
assign a value to crf (of a ptr of type AVCodecContext). Could someone
please give me a hint on how I could implement the API changes?
You are supposed to pass the options as the third argument to
avcodec_open2.
There is an example in the documentation of the function.
Please refrain from top-posting on this mailing list; and if you did not
understand what it means, look it up.
Regards,
--
Nicolas George
_______________________________________________
Libav-user mailing list
http://ffmpeg.org/mailman/listinfo/libav-user
Apologies, it's my very first time using a mailing list. Would this be the
correct way of setting priv_data?

AVDictionary *outputDictionary;
av_dict_set(&outputDictionary, "crf", "0", AV_DICT_APPEND);
avcodec_open2(outputCodecCtx, codec, &outputDictionary);

Thanks




--
View this message in context: http://libav-users.943685.n4.nabble.com/Libav-user-Using-LibX264-with-ffmpeg-libraries-tp4655395p4655472.html
Sent from the libav-users mailing list archive at Nabble.com.
Nicolas George
2012-07-23 20:14:22 UTC
Permalink
Post by noahzarc
Apologies for top posting, it's my very first time using a mailing list.
No problem, you fixed it.
Post by noahzarc
Apologies, it's my very first time using a mailing list. Would this be the
correct way of setting priv_data?
AVDictionary *outputDictionary;
av_dict_set(&outputDictionary, "crf", "0", AV_DICT_APPEND);
avcodec_open2(outputCodecCtx, codec, &outputDictionary);
You would probably make sure you init outputDictionary to NULL before doing
anything on it. And AV_DICT_APPEND is not necessary here and may be harmful
under some circumstances, but yes, this is the gist of it.

Regards,
--
Nicolas GEorge
noahzarc
2012-08-09 16:06:11 UTC
Permalink
Post by Nicolas George
Post by noahzarc
Apologies for top posting, it's my very first time using a mailing list.
No problem, you fixed it.
Post by noahzarc
Apologies, it's my very first time using a mailing list. Would this be the
correct way of setting priv_data?
AVDictionary *outputDictionary;
av_dict_set(&outputDictionary, "crf", "0", AV_DICT_APPEND);
avcodec_open2(outputCodecCtx, codec, &outputDictionary);
You would probably make sure you init outputDictionary to NULL before doing
anything on it. And AV_DICT_APPEND is not necessary here and may be harmful
under some circumstances, but yes, this is the gist of it.
Regards,
--
Nicolas GEorge
_______________________________________________
Libav-user mailing list
http://ffmpeg.org/mailman/listinfo/libav-user
Yeah so I tried to implement this into my code, it works but some thing
weird happens when I change the value of crf.. So originally I have crf set
at 0, which produces lossless output. But since the output file size is too
big, I wanted to change crf to a higher value, let's say 18. But if I do
that, the output video file generated would be 6KB without any content in
it. Any ideas why/how this happened?

Thanks!
Cheers



--
View this message in context: http://libav-users.943685.n4.nabble.com/Libav-user-Using-LibX264-with-ffmpeg-libraries-tp4655395p4655558.html
Sent from the libav-users mailing list archive at Nabble.com.

Loading...