From: Alan J. Pippin Date: Fri, 18 Nov 2011 22:51:08 +0000 (-0700) Subject: Various bug fixes and improvements. X-Git-Url: http://git.pippins.net/embedvideo/images/%27%20%20%20%20.%20%24GLOBALS%5B%27phpgw%27%5D-%3Elink%28%27inc/jquery/static/x.gif?a=commitdiff_plain;h=ffe1f69dcb8d98356599086af7e60dbffcf9e018;p=videoscripts%2F.git Various bug fixes and improvements. Added some helper/utility scripts. --- diff --git a/make_mkv b/make_mkv index bfbaa11..45ffb75 100755 --- a/make_mkv +++ b/make_mkv @@ -118,8 +118,11 @@ foreach my $video (sort{$videos{$a} <=> $videos{$b}} keys %videos) { print "$cmd\n"; if(! defined $opt_s) { my $errno = system("$cmd"); - if($errno > 0) { $errno = $errno - 255; } - if($errno > 1) { die "-E- mkvmerge encountered some errors with exit code $errno\n"; } + $errno = $errno >> 8; + if($errno > 1) { + unlink "$opt_o"; + die "-E- mkvmerge encountered some errors with exit code $errno\n"; + } } # Remove the temporary file used for the chapter generation diff --git a/merge_videos_by_day b/merge_videos_by_day index f8a5a9e..cd98040 100755 --- a/merge_videos_by_day +++ b/merge_videos_by_day @@ -174,7 +174,7 @@ foreach $video (sort keys %videos) { } else { # Create the merged video my $errno = system("$cmd"); - if($errno > 0) { $errno = $errno - 255; } + $errno = $errno >> 8; if($errno) { die "-E- make_mkv encountered some errors with exit code $errno\n"; } # Fix the permissions system("chown $owner \"$video\""); diff --git a/mkv2mp4 b/mkv2mp4 new file mode 100755 index 0000000..463c3d3 --- /dev/null +++ b/mkv2mp4 @@ -0,0 +1,12 @@ +#!/bin/bash + +# step 1: convert the mkv to mpg ; many mkv files do not directly get converted to mp4 +mencoder "$1" -ovc lavc -lavcopts vcodec=mpeg1video -aid 0 -oac pcm -o delete_me.mpg + +# step 2: convert the mpg file to mp4 +mencoder -of lavf -lavfopts format=mp4 -oac lavc -ovc lavc -lavcopts \ +aglobal=1:vglobal=1:acodec=libfaac:vcodec=mpeg4:abitrate=128:vbitrate=640:keyint=250:mbd=1:vqmax=10:lmax=10:turbo -af lavcresample=44100 \ +-vf harddup,scale=640:-3 "delete_me.mpg" -o "$1.mp4" + +# step 3: delete the temporary huge sized mpg file +rm "delete_me.mpg" diff --git a/mkv_extract_chapter b/mkv_extract_chapter new file mode 100644 index 0000000..2aa4c54 --- /dev/null +++ b/mkv_extract_chapter @@ -0,0 +1,14 @@ + +# MOV: +# Video: h264 (avc1 / 0x31637661) +# Audio: pcm_s16le +ffmpeg -ss 00:00:00.000 -t 00:00:38.299 -i 2010-12-04.000.mkv -map 0 -vcodec copy -acodec copy test.mov + +# MTS: +# Video: h264 (High) +# Audio: ac3 + +# MP4: +# Video: h264 (Baseline) (avc1 / 0x31637661) +# Audio: aac (mp4a / 0x6134706D) + diff --git a/organize_videos b/organize_videos index d0c7458..539c2c1 100755 --- a/organize_videos +++ b/organize_videos @@ -137,7 +137,7 @@ my $merge_opts = ""; if(defined $opt_t) { $merge_opts .= "-t "; } if(defined $opt_r) { $merge_opts .= "-r "; } $errno=system("$merge_videos_by_day -s \"$srcpathname\" $merge_opts"); -if($errno > 0) { $errno = $errno - 255; } +$errno = $errno >> 8; if($errno) { die "-E- $merge_videos_by_day encountered some errors with exit code $errno\n"; } # Copy the videos over to the destination path diff --git a/remove_bad_header b/remove_bad_header new file mode 100755 index 0000000..dc85d9b --- /dev/null +++ b/remove_bad_header @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "-> Removing bad header on $*" + +ffmpeg -ss 2 -i $* -map 0 -acodec copy -vcodec copy new.$* + +if [[ $? == 0 ]]; then + mv new.$* $* +else + echo "-E- Unable to remove the bad header" + rm new.$* +fi +