Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Add a possibility to use ffmpeg (instead of AtomicParsey) to embed thumbnail in downloaded video #24882

Open
sebma opened this issue Apr 19, 2020 · 9 comments
Labels

Comments

@sebma
Copy link

@sebma sebma commented Apr 19, 2020

Checklist

  • I'm reporting a feature request
  • I've verified that I'm running youtube-dl version 2020.03.24
  • I've searched the bugtracker for similar feature requests including closed ones

Description

Hi,

Since version 4, ffmpeg is able to embed thumbnail in mp4 files : See https://www.ffmpeg.org/ffmpeg.html#Main-options and : https://stackoverflow.com/q/54717175/5649639

I cannot build/find AtomicParsley for SailfishOS, can you please add the possibility to use ffmpeg (instead of AtomicParsley) to embed thumbnail in downloaded video ?

Thanks a lot to your team for your great amount of work for this great tool I use everyday (along with mpv:-) )

@sebma sebma added the request label Apr 19, 2020
@Seirdy
Copy link

@Seirdy Seirdy commented Apr 22, 2020

This would also be great for embedding thumbnails in container formats besides mp3 and mp4a/mp4 (e.g., Matroska mkv).

@sebma
Copy link
Author

@sebma sebma commented May 1, 2020

Also because AtomicParsley cannot embed old JPEG thumbnails that are not JFIF, such as the ones provided by Dailymotion :

$ curl -qs $(youtube-dl https://www.dailymotion.com/video/x5qpdm --get-thumbnail) | file -b -
JPEG image data
$ curl -qs $(youtube-dl https://www.youtube.com/watch?v=s13q9GhousM --get-thumbnail) | file -b -
JPEG image data, JFIF standard 1.01
$ AtomicParsley Bug2000__hls-380-0__x5qpdm__dailymotion.mp4  --artwork Bug2000__hls-380-0__x5qpdm__dailymotion.jpg --overWrite
AtomicParsley error: Bug2000__hls-380-0__x5qpdm__dailymotion.jpg
	 image file is not jpg/png and cannot be embedded.
$ convert -verbose Bug2000__hls-380-0__x5qpdm__dailymotion.jpg Bug2000__hls-380-0__x5qpdm__dailymotion__NEW.jpg
Bug2000__http-380-1__x5qpdm__dailymotion.jpg JPEG 1440x1080 1440x1080+0+0 8-bit DirectClass 81.3KB 0.040u 0:00.050
Bug2000__http-380-1__x5qpdm__dailymotion.jpg=>Bug2000__hls-380-0__x5qpdm__dailymotion__NEW.jpg JPEG 1440x1080 1440x1080+0+0 8-bit DirectClass 81.9KB 0.060u 0:00.059
$ file Bug2000__hls-380-0__x5qpdm__dailymotion.jpg Bug2000__hls-380-0__x5qpdm__dailymotion__NEW.jpg
Bug2000__hls-380-0__x5qpdm__dailymotion.jpg:      JPEG image data
Bug2000__hls-380-0__x5qpdm__dailymotion__NEW.jpg: JPEG image data, JFIF standard 1.01
$ AtomicParsley Bug2000__hls-380-0__x5qpdm__dailymotion.mp4  --artwork Bug2000__hls-380-0__x5qpdm__dailymotion__NEW.jpg --overWrite

 Started writing to temp file.
 Progress: =======================================================>100% |
 Finished writing to temp file.
@sebma
Copy link
Author

@sebma sebma commented May 2, 2020

BTW : The AtomicParsley issue #48 has been reported since December 2016.

@Vangelis66
Copy link

@Vangelis66 Vangelis66 commented May 4, 2020

@sebma : You do have a valid argument here 👍 , but FFmpeg 4.x.x branches require Windows Vista or higher to run; and that min WinOS requirement is for vanilla FFmpeg code; some third-party libs (e.g. libx265), when compiled with default configuration, require themselves additionally Win7 as a bare minimum WinOS (and this is precisely the reason the Zeranoe FFmpeg binaries won't run under Vista 😞 ) - OTOH, AP Windows binaries run on WinXP+...

The Windows binary of yt-dl, youtube-dl.exe , is being compiled with Python 3.4.4, which is the last WinXP compatible version; so I assume the devs have some vested interest in still supporting WinXP and, though on Vista myself in my older laptop, I do applaud that support 👍 ...

BTW, FFmpeg 4.x.x can also embed artwork as cover to .m4a audio files, not only to A+V .mp4 ones:

ffmpeg -v 16 -stats -i "audio-only.m4a" -i "cover.jpg" -map 0 -map 1 -disposition:v attached_pic -c copy "audio+cover.m4a"

... so I'd say it could probably replace fully AP for MOV/MP4/M4A tagging/artwork-embedding; and since yt-dl already depends on FFmpeg (for muxing elementary media streams into compatible containers and for cases where the native HLS downloader fails), one can kill two birds with one stone, by getting rid of AP altogether...

... However, the most wise move would be to retain AP support as an option, for those users that can't run the latest FFmpeg 4 Windows binaries (XP+Vista); I haven't checked, but what is the usage share of SailfishOS compared to the combined figure for XP+Vista?

FWIW, a kind person I know does compile and offer FFmpeg n4.3-dev Windows builds from forked FFmpeg code patched to make them run on XP SP3 (and SSE+ CPUs), but let's cross that bridge when we find it...

The AtomicParsley issue #48 has been reported since December 2016.

If wez has left the AP project to rot away, either you or Logan Fleur can always fork the project and implement needed patches, can you not? Then the yt-dl community here would need a volunteer to compile the forked AP code for at least Windows x86 (targetting XP+)...

@effleurager
Copy link
Contributor

@effleurager effleurager commented May 4, 2020

@Vangelis66 I can fork & patch the GitHub project, but not compile it for Windows. I'll do that later tonight when I'm done with work.

@Vangelis66
Copy link

@Vangelis66 Vangelis66 commented May 4, 2020

@effleurager wrote:

I can fork & patch the GitHub project

(Do you actually mean the Bitbucket original one by Wez, that uses mercurial version control?)
Highly appreciated, many thanks in advance! 👍

but not compile it for Windows

... such a pity, though... For anyone else that may volunteer, (cross)compilation instructions for Windows 32-bit are described/linked in

https://bitbucket.org/jonhedgerows/atomicparsley/wiki/Building%20for%20Windows

Best wishes 😄

@effleurager
Copy link
Contributor

@effleurager effleurager commented May 4, 2020

@Vangelis66 The GitHub one is severely outdated compared to the Mercurial one, so I've used Bitbucket as the source instead.
effleurager/atomicparsley now has the patched version.

@sebma
Copy link
Author

@sebma sebma commented May 10, 2020

@Vangelis66

... However, the most wise move would be to retain AP support as an option, for those users that can't run the latest FFmpeg 4 Windows binaries (XP+Vista)

According to https://ffmpeg.zeranoe.com/builds/ : ffmpeg can run on Win7. If it does run on Win7, can it not run on Vista ?

If wez has left the AP project to rot away, either you or Logan Fleur can always fork the project and implement needed patches, can you not?

Unfortunately, I'm a better "scripter" than developer : I don't know anything about cross-compiling except doing somethig like this (to build AP for SailfishOS) :

dest=arm-linux-gnueabihf
export CC=$dest-gcc
time ./configure --prefix=$HOME/build/jolla --host=$dest
time make

If I knew more, I would have succeeded building AP on SailfishOS.

I haven't checked, but what is the usage share of SailfishOS compared to the combined figure for XP+Vista?

You're absolutely right 👍, but I've been dreaming for a real Linux smartphone for so long 😃 Nevertheless, I never suggested to abandon AtomicParsley, I do understand the need for AtomicParsley on WinXP+.

However, can we also consider the possiblity to have a new youtube-dl option to use ffmpeg as an alternative tool for youtube-dl to embed thumbnails on Linux platforms, for exemple :

       --external-thumbnailer COMMAND
              Use the specified external thumbnailer.  Currently supports AtomicParsley,ffmpeg
@sebma
Copy link
Author

@sebma sebma commented May 10, 2020

@Vangelis66

BTW, FFmpeg 4.x.x can also embed artwork as cover to .m4a audio files, not only to A+V .mp4 ones:

ffmpeg -v 16 -stats -i "audio-only.m4a" -i "cover.jpg" -map 0 -map 1 -disposition:v attached_pic -c copy "audio+cover.m4a"

👍

I also noticed ffmpeg CAN embed subtitles into m4a files (so that song lyrics are displayed over the thumbnail when the file is played with mpv) :

addSubtitles2media ()
{
	local inputVideo=$1
	test $# -le 1 && {
		echo "=> Usage: $FUNCNAME inputVideo subFile1 subFile2 subFile3 ..." 1>&2
		return 1
	}
	local extension=${inputVideo/*./}
	case $extension in
		mp4 | m4a | m4b | mov)
			subTitleCodec=mov_text
		;;
		webm | mkv | mka)
			subTitleCodec=webvtt
		;;
		*)
			subTitleCodec=not_known_or_not_yet_supported
		;;
	esac
	local outputVideo=${inputVideo/.$extension/_NEW.$extension}
	shift
	local numberOfSubtitles=$#
	( printf "ffmpeg -hide_banner -i $inputVideo "
	printf -- "-i %s " "$@"
	printf -- "-map 0:a? -map 0:v? "
	printf -- "-map %d " $(seq $numberOfSubtitles)
	printf -- "-c copy -c:s $subTitleCodec $outputVideo\n" ) | sh -x
	local retCode=$?
	sync
	sleep 1
	touch -r "$inputVideo" "$outputVideo"
	[ $retCode = 0 ] && echo && \mv -vf "$outputVideo" "$inputVideo" && \rm "$@"
}

I haven't tried it on Matroska contained streams but I can say it works like a charm on m4a files 😄 :

ffprobe -hide_banner Alan_Jackson_-_I_Want_To_Stroll_Over_Heaven_With_You_Live__140__UnZbjvyzteo__youtube_com.m4a
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5655577e84c0] stream 0, timescale not set
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Alan_Jackson_-_I_Want_To_Stroll_Over_Heaven_With_You_Live__140__UnZbjvyzteo__youtube_com.m4a':
  Metadata:
    major_brand     : M4A 
    minor_version   : 512
    compatible_brands: isomiso2
    title           : Alan Jackson - I Want To Stroll Over Heaven With You (Live)
    artist          : GaitherVEVO
    date            : 20170824
    encoder         : Lavf58.20.100
    comment         : Alan Jackson – Official Video for “I Want To Stroll Over Heaven With You Live”, available now!
                    : 
                    : Buy the full-length DVD/CD ‘Alan Jackson Precious Memories: Live at the Ryman Auditorium' Here: http://capcmg.me/preciousmemories
                    : Available at Amazon: http://capcmg.me/am.preciousmemories
                    : 
                    : Sign-Up for the Gaither Newsletter and receive $5 off your next online purchase: http://smarturl.it/GaitherNewsletter
                    : 
                    : Subscribe to Gaither Music YouTube Channel: http://smarturl.it/GaitherMusicTV_Subsc
                    : Subscribe to GaitherVEVO Channel: http://smarturl.it/GaitherVEVOSubscribe
                    : Subscribe to Gaither TV: http://smarturl.it/GaitherTV_Subscribe
                    : 
                    : Follow Gaither Music for updates on your favorite artists.
                    : Facebook: http://smarturl.it/FB_GaitherMusic
                    : Twitter: http://smarturl.it/TW_GaitherMusic
                    : Instagram: http://smarturl.it/IG_GaitherMusic
                    : Website: http://smarturl.it/gaither.com
                    : 
                    : LYRICS:
                    : 
                    : If I survey all the good things that come to me from above
                    : If I count all the blessings from the storehouse of love
                    : I'd simply ask for the favor of him beyond mortal king
                    : And I'm sure he would grant it again
                    : I want to stroll over Heaven with you some glad day
                    : When all our troubles and heartaches are vanished away
                    : Then we'll enjoy the beauty where all things are new
                    : I want to stroll over Heaven with you
                    : 
                    : So many places of beauty we long to see here below
                    : But time and treasures have kept us from making plans as you know
                    : But come the morning of rapture together we'll stand a new
                    : While I stroll over Heaven with you
                    : I want to stroll over Heaven with you some glad day
                    : When all our troubles and heartaches are vanished away
                    : Then we'll enjoy the beauty where all things are new
                    : I want to stroll over Heaven with you
                    : 
                    : Music video by Alan Jackson performing I Want To Stroll Over Heaven With You. (C) 2017 ACR Records, LLC Under license to Spring House Productions, Inc.
                    : 
                    : http://vevo.ly/gumdxW
    description     : https://www.youtube.com/watch?v=UnZbjvyzteo
  Duration: 00:02:52.80, start: 0.000000, bitrate: 133 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s (default)
    Metadata:
      handler_name    : SubtitleHandler
    Stream #0:2(und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
    Metadata:
      handler_name    : SubtitleHandler
    Stream #0:3(und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
    Metadata:
      handler_name    : SubtitleHandler
    Stream #0:4(und): Subtitle: mov_text (tx3g / 0x67337874), 0 kb/s
    Metadata:
      handler_name    : SubtitleHandler
    Stream #0:5: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 90k tbr, 90k tbn, 90k tbc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.