'In-line way to create a thumbnail for a processed video

Usually, when FFmpeg converts a video the result does not have a thumbnail on my computer, only showing the default blank 'mp4' thumb. I am trying to make a command line that will convert videos and also give the output a thumbnail. I've found a lot of examples of how to pull an image from a video, but not how to in-line make sure it has a thumbnail.

The main function I want is for any type of video to be converted to hevc_nvenc/aac/mov_text.

Currently, my command looks like this:

ffmpeg -i "pth_in.mp4" -i "pth_in.mp4" -movflags faststart -map 0:v:0 -map 1:v -c:v hevc_nvenc -preset slow -map 1:a? -c:a aac -b:a 128k -map 1:s? -c:s ssa -filter:v:0 thumbnail,scale=360:-1,trim=end_frame=1 -c:v:0 mjpeg -disposition:0 attached_pic "pth_out.mp4"

where the double input and -filter:v:0 thumbnail,scale=360:-1,trim=end_frame=1 -c:v:0 mjpeg -disposition:0 attached_pic is supposed to create the thumbnail. It DOES, however, as it stands this command will also cause the video's seek bar to malfunction, only working for about 3 seconds using MPC-HC and VLC, although the video will still play in its entirety.

Is there any way to do this in 'one' pass like I'm trying? Or do I have to split it up and do something else? Is there any other faux pas I'm making? Thanks for any help!



Solution 1:[1]

Try this:

ffmpeg -i pth_in.mp4 \
       -movflags faststart \
       -filter_complex [0:v]thumbnail,trim=end_frame=1,scale=360:-1[thumb] \
       -map 0:v -c:v:0 hevc_nvenc -preset slow \
       -map [thumb] -frames:v:1 1 -c:v:1 mjpeg -disposition:v:1 attached_pic \
       -map 0:a? -c:a aac -b:a 128k \
       -map 0:s? -c:s ssa 
       pth_out.mp4
    ]
)

Using a complex filtergraph, you need to specify the input video only once, and careful stream specification of video output options should let you get everything done in one shot.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kesh