update
This commit is contained in:
parent
29331006a6
commit
c5159c3eab
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"os/exec"
|
||||
|
@ -27,9 +28,11 @@ type Movie struct {
|
|||
// var movies []Movie
|
||||
var categories []Category
|
||||
|
||||
var IsRemakePNG = false
|
||||
|
||||
func initMovie() {
|
||||
// 需要改进 如果存在这个文件的略缩图, 就不存进movieDict里
|
||||
var movieDict map[string]string = make(map[string]string)
|
||||
var movieDict map[string]*Movie = make(map[string]*Movie)
|
||||
|
||||
matches, err := filepath.Glob("movie/*")
|
||||
if err != nil {
|
||||
|
@ -43,30 +46,11 @@ func initMovie() {
|
|||
base = base[:strings.IndexByte(base, '.')]
|
||||
|
||||
if _, ok := movieDict[base]; ok {
|
||||
delete(movieDict, base)
|
||||
if !IsRemakePNG {
|
||||
delete(movieDict, base)
|
||||
}
|
||||
} else {
|
||||
movieDict[base] = filename
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for key, filename := range movieDict {
|
||||
// width := 160
|
||||
// height := 120
|
||||
log.Println(filename)
|
||||
|
||||
cmd := exec.Command("ffmpeg",
|
||||
"-i", filename,
|
||||
"-vf", "select='isnan(prev_selected_t)+gte(t-prev_selected_t\\,35)',scale=320:180,tile=3x3",
|
||||
"-frames:v", "1",
|
||||
"movie/"+key+".png",
|
||||
)
|
||||
|
||||
var buffer bytes.Buffer
|
||||
cmd.Stdout = &buffer
|
||||
if cmd.Run() != nil {
|
||||
log.Println(buffer.String())
|
||||
panic("could not generate frame")
|
||||
movieDict[base] = &Movie{Name: filename}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -101,6 +85,11 @@ func initMovie() {
|
|||
Image: base[:strings.IndexByte(base, '.')] + ".png",
|
||||
Duration: int(duration / 60.0),
|
||||
}
|
||||
|
||||
if m, ok := movieDict[base[:strings.IndexByte(base, '.')]]; ok {
|
||||
m.Duration = movie.Duration
|
||||
}
|
||||
|
||||
if movie.Duration <= 15 {
|
||||
categories[0].Movies = append(categories[0].Movies, movie)
|
||||
} else if movie.Duration <= 30 {
|
||||
|
@ -122,5 +111,44 @@ func initMovie() {
|
|||
})
|
||||
}
|
||||
|
||||
for key, movie := range movieDict {
|
||||
// width := 160
|
||||
// height := 120
|
||||
// if movie.Duration <= 40 {
|
||||
// continue
|
||||
// }
|
||||
|
||||
log.Println(movie.Name, "时长:", movie.Duration)
|
||||
var filter string
|
||||
|
||||
if movie.Duration <= 2 {
|
||||
filter = "select='isnan(prev_selected_t)+gte(t-prev_selected_t\\,5)',scale=320:180,tile=3x3"
|
||||
} else if movie.Duration <= 5 {
|
||||
filter = "select='isnan(prev_selected_t)+gte(t-prev_selected_t\\,10)',scale=320:180,tile=3x3"
|
||||
} else if movie.Duration <= 30 {
|
||||
filter = "select='isnan(prev_selected_t)+gte(t-prev_selected_t\\,20)',scale=320:180,tile=3x3"
|
||||
} else if movie.Duration <= 60 {
|
||||
filter = "select='isnan(prev_selected_t)+gte(t-prev_selected_t\\,35)',scale=320:180,tile=3x3"
|
||||
} else {
|
||||
filter = "select='isnan(prev_selected_t)+gte(t-prev_selected_t\\,60)',scale=320:180,tile=3x3"
|
||||
}
|
||||
|
||||
cmd := exec.Command("ffmpeg",
|
||||
"-i", movie.Name,
|
||||
"-vf", filter,
|
||||
"-frames:v", "1",
|
||||
"-y",
|
||||
"movie/"+key+".png",
|
||||
)
|
||||
|
||||
var buffer bytes.Buffer
|
||||
cmd.Stdout = &buffer
|
||||
if cmd.Run() != nil {
|
||||
log.Println(buffer.String())
|
||||
panic(fmt.Errorf("could not generate frame %s %d", movie.Name, movie.Duration))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// log.Printf("%##v", categories)
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ import ConfigContext from './Config';
|
|||
import MovieCard from './components/MovieCard';
|
||||
import CategoryNav from './components/CategoryNav';
|
||||
|
||||
import Select from '@mui/material/Select';
|
||||
import MenuItem from '@mui/material/MenuItem';
|
||||
import FormControl from '@mui/material/FormControl';
|
||||
import InputLabel from '@mui/material/InputLabel';
|
||||
|
||||
const Main = () => {
|
||||
const config = useContext(ConfigContext);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import React from 'react';
|
||||
import Card from '@mui/material/Card';
|
||||
import CardMedia from '@mui/material/CardMedia';
|
||||
import CardContent from '@mui/material/CardContent';
|
||||
import Typography from '@mui/material/Typography';
|
||||
|
||||
import { Card, CardContent, CardMedia, Typography } from '@mui/material';
|
||||
import { styled, useTheme } from '@mui/system';
|
||||
|
||||
const MovieCard = ({ movie, config }) => {
|
||||
const truncateFilename = (filename, maxLength) => {
|
||||
|
@ -11,7 +10,20 @@ const MovieCard = ({ movie, config }) => {
|
|||
: filename;
|
||||
};
|
||||
|
||||
const theme = useTheme();
|
||||
console.log(theme.shadows)
|
||||
|
||||
|
||||
const StyledCard = styled(Card)({
|
||||
'&:hover': {
|
||||
transform: 'scale(1.05)',
|
||||
boxShadow: '0px 6px 16px rgba(0, 0, 0, 0.1)',
|
||||
zIndex: 1,
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<StyledCard>
|
||||
<Card
|
||||
style={{
|
||||
width: '100%',
|
||||
|
@ -35,6 +47,7 @@ const MovieCard = ({ movie, config }) => {
|
|||
</Typography>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</StyledCard>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user