Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Oct 2007 04:05:04 GMT
From:      Alex Kozlov <spam@rm-rf.kiev.ua>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/117053: [patch] www/youtube_dl  Add FLV2MPEG4 option
Message-ID:  <200710100405.l9A454bj056822@www.freebsd.org>
Resent-Message-ID: <200710100410.l9A4A2O5061973@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         117053
>Category:       ports
>Synopsis:       [patch] www/youtube_dl  Add FLV2MPEG4 option
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 10 04:10:02 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Alex Kozlov
>Release:        FreeBSD 6.2
>Organization:
private
>Environment:
>Description:
Add FLV2MPEG4 option to convert flv to avi using multimedia/flv2mpeg4 (3+ times faster and less lossy than ffmpeg).
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Index: www/youtube_dl/Makefile
@@ -23,20 +23,34 @@
 
 PLIST_FILES=	bin/youtube-dl
 
-OPTIONS=	FFMPEG "With optional avi output format" off
+OPTIONS=	FFMPEG "Use ffmpeg for avi output" off \
+			FLV2MPEG4 "Use flv2mpeg4 for avi output" off
 
 .include <bsd.port.pre.mk>
 
+.if defined(WITH_FFMPEG) || defined(WITH_FLV2MPEG4)
+EXTRA_PATCHES+=	${PATCHDIR}/conv2avi.patch
+.endif
+
 .if defined(WITH_FFMPEG)
+.if defined(WITH_FLV2MPEG4)
+IGNORE=		cannot use WITH_FFMPEG and WITH_FLV2MPEG4 simultaneously
+.endif
 RUN_DEPENDS=	ffmpeg:${PORTSDIR}/multimedia/ffmpeg
-EXTRA_PATCHES+=	${PATCHDIR}/ffmpeg.patch
+CONV2AVI_CMD= ffmpeg -y -i
+.elif defined(WITH_FLV2MPEG4)
+RUN_DEPENDS=	flv2mpeg4:${PORTSDIR}/multimedia/flv2mpeg4
+CONV2AVI_CMD=	flv2mpeg4
 .endif
 
 post-extract:
 	@${CP} ${DISTDIR}/youtube-dl-${PORTVERSION} ${WRKSRC}/youtube-dl
 
 post-patch:
-	@${REINPLACE_CMD} -e 's|%%PYTHON_CMD%%|${PYTHON_CMD}|g' ${WRKSRC}/youtube-dl
+	@${REINPLACE_CMD} -e '/^#!/s|!.*|!${PYTHON_CMD}|' ${WRKSRC}/youtube-dl
+.if defined(WITH_FFMPEG) || defined(WITH_FLV2MPEG4)
+	@${REINPLACE_CMD} -e 's|CONV2AVI_CMD|${CONV2AVI_CMD}|' ${WRKSRC}/youtube-dl
+.endif
 
 do-install:
 	@${INSTALL_SCRIPT} ${WRKSRC}/youtube-dl ${PREFIX}/bin/youtube-dl
Index: www/youtube_dl/files/conv2avi.patch
@@ -0,0 +1,36 @@
+Index: youtube-dl
+@@ -206,6 +206,7 @@
+ cmdl_parser.add_option('-t', '--title', action='store_true', dest='use_title', help='use title in file name')
+ cmdl_parser.add_option('-l', '--literal', action='store_true', dest='use_literal', help='use literal title in file name')
+ cmdl_parser.add_option('-n', '--netrc', action='store_true', dest='use_netrc', help='use .netrc authentication data')
++cmdl_parser.add_option('-a', '--avi', action='store_true', dest='use_avi', help='output file in avi format')
+ cmdl_parser.add_option('-g', '--get-url', action='store_true', dest='get_url', help='print final video URL only')
+ cmdl_parser.add_option('-2', '--title-too', action='store_true', dest='get_title', help='used with -g, print title too')
+ (cmdl_opts, cmdl_args) = cmdl_parser.parse_args()
+@@ -404,5 +405,26 @@
+ 	except KeyboardInterrupt:
+ 		sys.exit('\n')
+ 
++# Convert to avi
++if cmdl_opts.use_avi:
++	try:
++		try:
++			final_filename
++		except NameError:
++			final_filename = '%s.flv' % video_url_id
++
++		avi_filename = final_filename.replace('.flv','.avi')
++		os.system("CONV2AVI_CMD %s %s > %s 2> %s" % (final_filename, avi_filename, os.path.devnull, os.path.devnull))
++		cond_print('Video file converted to %s\n' % avi_filename)
++	except OSError:
++		sys.stderr.write('Warning: unable to convert file.\n')
++	except KeyboardInterrupt:
++		sys.exit('\n')
++
++	try:
++		os.unlink(final_filename)
++	except OSError:
++		sys.stderr.write('Warning: unable to remove file.\n')
++
+ # Finish
+ sys.exit()
Index: www/youtube_dl/files/patch-youtube-dl
@@ -1,8 +0,0 @@
---- youtube-dl-orig	Fri Aug 11 01:00:08 2006
-+++ youtube-dl	Sat Aug 12 13:46:38 2006
-@@ -1,4 +1,4 @@
--#!/usr/bin/env python
-+#!%%PYTHON_CMD%%
- #
- # Copyright (c) 2006 Ricardo Garcia Gonzalez
- #
Index: www/youtube_dl/files/ffmpeg.patch
@@ -1,60 +0,0 @@
---- youtube-dl.orig	Wed Mar 28 22:12:49 2007
-+++ youtube-dl	Wed Mar 28 22:11:38 2007
-@@ -203,6 +203,7 @@
- cmdl_parser.add_option('-t', '--title', action='store_true', dest='use_title', help='use title in file name')
- cmdl_parser.add_option('-l', '--literal', action='store_true', dest='use_literal', help='use literal title in file name')
- cmdl_parser.add_option('-n', '--netrc', action='store_true', dest='use_netrc', help='use .netrc authentication data')
-+cmdl_parser.add_option('-a', '--avi', action='store_true', dest='use_avi', help='output file in avi format')
- cmdl_parser.add_option('-g', '--get-url', action='store_true', dest='get_url', help='print final video URL only')
- (cmdl_opts, cmdl_args) = cmdl_parser.parse_args()
- 
-@@ -275,13 +276,21 @@
- 
- # Get output file name 
- if cmdl_opts.outfile is None:
--	video_filename = '%s.flv' % video_url_id
-+	if cmdl_opts.use_avi:
-+		ext = 'avi'
-+	else:
-+		ext = 'flv'
-+	video_filename = '%s.%s' % (video_url_id,ext)
- else:
- 	video_filename = cmdl_opts.outfile
- 
- # Check name
--if not video_filename.lower().endswith('.flv'):
--	sys.stderr.write('Warning: video file name does not end in .flv\n')
-+if cmdl_opts.use_avi:
-+	if not video_filename.lower().endswith('.avi'):
-+		sys.stderr.write('Warning: video file name does not end in .avi\n')
-+else:
-+	if not video_filename.lower().endswith('.flv'):
-+		sys.stderr.write('Warning: video file name does not end in .flv\n')
- 
- # Test writable file
- if not (cmdl_opts.simulate or cmdl_opts.get_url):
-@@ -328,7 +337,10 @@
- 	if cmdl_opts.simulate or cmdl_opts.get_url:
- 		sys.exit()
- 
--	video_file = open(video_filename, 'wb')
-+	if cmdl_opts.use_avi:
-+		video_file = os.popen('ffmpeg -y -i - "%s" > %s 2> %s' % (video_filename, os.path.devnull, os.path.devnull), 'wb')
-+	else:
-+		video_file = open(video_filename, 'wb')
- 	try:
- 		video_len = long(video_data.info()['Content-length'])
- 		video_len_str = format_bytes(video_len)
-@@ -382,7 +394,11 @@
- 			prefix = title_string_norm(video_title)
- 		else:
- 			prefix = title_string_touch(video_title)
--		final_filename = '%s-%s.flv' % (prefix, video_url_id)
-+		if cmdl_opts.use_avi:
-+			ext = 'avi'
-+		else:
-+			ext = 'flv'
-+		final_filename = '%s-%s.%s' % (prefix, video_url_id, ext)		
- 		os.rename(video_filename, final_filename)
- 		cond_print('Video file renamed to %s\n' % final_filename)
- 	


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710100405.l9A454bj056822>