diff --git a/.gitignore b/.gitignore index ad705ae..6dcc389 100644 --- a/.gitignore +++ b/.gitignore @@ -244,4 +244,5 @@ video_creation/data/envvars.txt config.toml ffmpeg.exe -tempTEMP_MPY_wvf_snd.mp4 \ No newline at end of file +tempTEMP_MPY_wvf_snd.mp4 +*.mp4 diff --git a/video_creation/background.py b/video_creation/background.py index 7ef4321..932d0ac 100644 --- a/video_creation/background.py +++ b/video_creation/background.py @@ -1,3 +1,4 @@ +import os from pathlib import Path import random from random import randrange @@ -109,17 +110,22 @@ def chop_background_video(background_config: Tuple[str, str, str, Any], video_le background = VideoFileClip(f"assets/backgrounds/{choice}") start_time, end_time = get_start_and_end_times(video_length, background.duration) - try: - ffmpeg_extract_subclip( - f"assets/backgrounds/{choice}", - start_time, - end_time, - targetname="assets/temp/background.mp4", - ) - except (OSError, IOError): # ffmpeg issue see #348 - print_substep("FFMPEG issue. Trying again...") - with VideoFileClip(f"assets/backgrounds/{choice}") as video: - new = video.subclip(start_time, end_time) - new.write_videofile("assets/temp/background.mp4") - print_substep("Background video chopped successfully!", style="bold green") - return background_config[2] + + os.system("ffmpeg -i " + f"assets/backgrounds/{choice} " + "-acodec copy -f segment " + "-vcodec copy -reset_timestamps 1 -map 0 OUTPUT%d.mp4") + + # try: + # ffmpeg_extract_subclip( + # f"assets/backgrounds/{choice}", + # start_time, + # end_time, + # vcodec="libx264", + # targetname="assets/temp/background.mp4", + #) + #except (OSError, IOError): # ffmpeg issue see #348 + # print_substep("FFMPEG issue. Trying again...") + # with VideoFileClip(f"assets/backgrounds/{choice}") as video: + # new = video.subclip(start_time, end_time) + # new.write_videofile("assets/temp/background.mp4") + #print_substep("Background video chopped successfully!", style="bold green") + #return background_config[2] diff --git a/video_creation/data/videos.json b/video_creation/data/videos.json index 75f44cc..eb260ba 100644 --- a/video_creation/data/videos.json +++ b/video_creation/data/videos.json @@ -86,5 +86,133 @@ "background_credit": "bbswitzer", "reddit_title": "What are some of the first signs a movie is going to suck", "filename": "What are some of the first signs a movie is going to suck.mp4" + }, + { + "subreddit": "askreddit", + "id": "dcxylq", + "time": "1657601343", + "background_credit": "bbswitzer", + "reddit_title": "Anthony Bourdain once said Theres a guy in my head and all he wants to do is lay in bed all day long smoke pot and watch old movies and cartoons My life is a series of strategems to avoid and outwit that guy Who is that guy for you and what do you do to avoid him", + "filename": "Anthony Bourdain once said Theres a guy in my head and all he wants to do is lay in bed all day long smoke pot and watch old movies and cart.mp4" + }, + { + "subreddit": "askreddit", + "id": "ktomhz", + "time": "1657602429", + "background_credit": "bbswitzer", + "reddit_title": "People of Reddit how would you feel if there was a USA filter where non-Americans can scroll through Reddit freely without watching hearing or reading whats going on in America", + "filename": "People of Reddit how would you feel if there was a USA filter where non-Americans can scroll through Reddit freely without watching hearing .mp4" + }, + { + "subreddit": "askreddit", + "id": "q18zrj", + "time": "1657602752", + "background_credit": "bbswitzer", + "reddit_title": "How is everyone enjoying Reddit while Instagram Facebook and whatsapp are all down", + "filename": "How is everyone enjoying Reddit while Instagram Facebook and whatsapp are all down.mp4" + }, + { + "subreddit": "askreddit", + "id": "i4r81a", + "time": "1657602973", + "background_credit": "bbswitzer", + "reddit_title": "Its more than likely that Covid-19 will still be around at Christmas time - how are we going to explain to kids that Santa is still allowed to go into millions of houses", + "filename": "Its more than likely that Covid-19 will still be around at Christmas time - how are we going to explain to kids that Santa is still allowed .mp4" + }, + { + "subreddit": "askreddit", + "id": "99eh6b", + "time": "1657603196", + "background_credit": "bbswitzer", + "reddit_title": "Without saying what the category is what are your top five", + "filename": "Without saying what the category is what are your top five.mp4" + }, + { + "subreddit": "askreddit", + "id": "ecscwk", + "time": "1657603415", + "background_credit": "bbswitzer", + "reddit_title": "What free things online should everyone take advantage of", + "filename": "What free things online should everyone take advantage of.mp4" + }, + { + "subreddit": "askreddit", + "id": "80phz7", + "time": "1657603624", + "background_credit": "bbswitzer", + "reddit_title": "With all of the negative headlines dominating the news these days it can be difficult to spot signs of progress What makes you optimistic about the future", + "filename": "With all of the negative headlines dominating the news these days it can be difficult to spot signs of progress What makes you optimistic ab.mp4" + }, + { + "subreddit": "askreddit", + "id": "ilcknh", + "time": "1657603800", + "background_credit": "bbswitzer", + "reddit_title": "Steve Irwin has you pinned down in a headlock what cool facts does he tell the audience about you and your habitat", + "filename": "Steve Irwin has you pinned down in a headlock what cool facts does he tell the audience about you and your habitat.mp4" + }, + { + "subreddit": "askreddit", + "id": "aicgpz", + "time": "1657603918", + "background_credit": "bbswitzer", + "reddit_title": "Serious Americans would you be in support of putting a law in place that government officials such as senators and the president go without pay during shutdowns like this while other federal employees do Why or why not", + "filename": "Serious Americans would you be in support of putting a law in place that government officials such as senators and the president go without .mp4" + }, + { + "subreddit": "askreddit", + "id": "ac9038", + "time": "1657604153", + "background_credit": "bbswitzer", + "reddit_title": "Iceland just announced that every Icelander over the age of 18 automatically become organ donors with ability to opt out How do you feel about this", + "filename": "Iceland just announced that every Icelander over the age of 18 automatically become organ donors with ability to opt out How do you feel abo.mp4" + }, + { + "subreddit": "askreddit", + "id": "kkmgzr", + "time": "1657604925", + "background_credit": "bbswitzer", + "reddit_title": "With Christmas 364 days away people who already have their decorations up why", + "filename": "With Christmas 364 days away people who already have their decorations up why.mp4" + }, + { + "subreddit": "askreddit", + "id": "hvsxty", + "time": "1657605189", + "background_credit": "bbswitzer", + "reddit_title": "Which legendary Reddit post comment can you still not get over", + "filename": "Which legendary Reddit post comment can you still not get over.mp4" + }, + { + "subreddit": "askreddit", + "id": "jpfqtc", + "time": "1657605431", + "background_credit": "bbswitzer", + "reddit_title": "You go to sleep on the 31st of December 2020 and wake up the next day but when you check your phone it says January 1st 2020 after the first couple of days you realize its just like groundhog day what do you do with the information you have about 2020", + "filename": "You go to sleep on the 31st of December 2020 and wake up the next day but when you check your phone it says January 1st 2020 after the first.mp4" + }, + { + "subreddit": "askreddit", + "id": "70k2ya", + "time": "1657605644", + "background_credit": "bbswitzer", + "reddit_title": "How would you feel about a law that requires people over the age of 70 to pass a specialized driving test in order to continue driving", + "filename": "How would you feel about a law that requires people over the age of 70 to pass a specialized driving test in order to continue driving.mp4" + }, + { + "subreddit": "askreddit", + "id": "dtmyxw", + "time": "1657605914", + "background_credit": "bbswitzer", + "reddit_title": "Now that PBS has announced theyll be televising the impeachment hearings what will the drinking game rules be", + "filename": "Now that PBS has announced theyll be televising the impeachment hearings what will the drinking game rules be.mp4" + }, + { + "subreddit": "askreddit", + "id": "ts82um", + "time": "1657606366", + "background_credit": "bbswitzer", + "reddit_title": "Chris Rock is performing a standup gig tonight in Bostonhis first appearance since the Oscars If you were Chris what would be the first joke youd tell assuming youd want to acknowledge Will Smiths slap", + "filename": "Chris Rock is performing a standup gig tonight in Bostonhis first appearance since the Oscars If you were Chris what would be the first joke.mp4" } ] \ No newline at end of file diff --git a/video_creation/final_video.py b/video_creation/final_video.py index f4a3672..c16a68b 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -130,6 +130,8 @@ def make_final_video( print_substep("The results folder didn't exist so I made it") os.makedirs(f"./results/{subreddit}") +#h264_nvenc, mpeg4 +#libfdk_aac final.write_videofile( "assets/temp/temp.mp4", fps=30,