mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
lavd/fbdev_enc: add default device
Use device specified by environment variable FRAMEBUFFER or /dev/fb0 as default. Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
This commit is contained in:
parent
90539cea33
commit
fa3bfeb1c1
@ -20,6 +20,7 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include "fbdev_common.h"
|
#include "fbdev_common.h"
|
||||||
#include "libavutil/common.h"
|
#include "libavutil/common.h"
|
||||||
|
|
||||||
@ -55,3 +56,12 @@ enum AVPixelFormat ff_get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *varin
|
|||||||
|
|
||||||
return AV_PIX_FMT_NONE;
|
return AV_PIX_FMT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* ff_fbdev_default_device()
|
||||||
|
{
|
||||||
|
const char *dev = getenv("FRAMEBUFFER");
|
||||||
|
if (!dev)
|
||||||
|
dev = "/dev/fb0";
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -29,4 +29,6 @@
|
|||||||
|
|
||||||
enum AVPixelFormat ff_get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *varinfo);
|
enum AVPixelFormat ff_get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *varinfo);
|
||||||
|
|
||||||
|
const char* ff_fbdev_default_device(void);
|
||||||
|
|
||||||
#endif /* AVDEVICE_FBDEV_COMMON_H */
|
#endif /* AVDEVICE_FBDEV_COMMON_H */
|
||||||
|
@ -45,17 +45,23 @@ static av_cold int fbdev_write_header(AVFormatContext *h)
|
|||||||
FBDevContext *fbdev = h->priv_data;
|
FBDevContext *fbdev = h->priv_data;
|
||||||
enum AVPixelFormat pix_fmt;
|
enum AVPixelFormat pix_fmt;
|
||||||
int ret, flags = O_RDWR;
|
int ret, flags = O_RDWR;
|
||||||
|
const char* device;
|
||||||
|
|
||||||
if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO) {
|
if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO) {
|
||||||
av_log(fbdev, AV_LOG_ERROR, "Only a single video stream is supported.\n");
|
av_log(fbdev, AV_LOG_ERROR, "Only a single video stream is supported.\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fbdev->fd = avpriv_open(h->filename, flags)) == -1) {
|
if (h->filename[0])
|
||||||
|
device = h->filename;
|
||||||
|
else
|
||||||
|
device = ff_fbdev_default_device();
|
||||||
|
|
||||||
|
if ((fbdev->fd = avpriv_open(device, flags)) == -1) {
|
||||||
ret = AVERROR(errno);
|
ret = AVERROR(errno);
|
||||||
av_log(h, AV_LOG_ERROR,
|
av_log(h, AV_LOG_ERROR,
|
||||||
"Could not open framebuffer device '%s': %s\n",
|
"Could not open framebuffer device '%s': %s\n",
|
||||||
h->filename, av_err2str(ret));
|
device, av_err2str(ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user