Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Extract motion vectors from x265 (HEVC) encoded video with ffmpeg/libavcodec ?
3 juillet, par John AllardI know that one can extract the motion vectors from an h264 encoded via by first setting the flag
av_dict_set(&opts, "flags2", "+export_mvs", 0);
then you can query the side-data for the motion vectors by doing this
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS);
When I looked online to see if you can do something similar with HEVC encoded videos, I wasn't able to find any information. All I found was this by the definition of "AV_FRAME_DATA_MOTION_VECTORS"
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec AVCodecContext flags2 option).
The data is the AVMotionVector struct defined in libavutil/motion_vector.h.
but there was no information on exactly which codecs export this motion vector information. How would I go about finding this out?
-
Using FFMPEG to join two MTS files together
2 juillet, par ReadoI have two MTS video files, each one 2 minutes long. I need to be able to join the files together and convert the format to MPEG4. I have a suitable command line for converting MTS to MP4 but don't know how to join the files together in the first place.
Some articles on the web suggest using the CAT command, like:
cat video1.mts video2.mts > whole_video.mts
However this doesn't work and according to FFMPEG, "whole_video.mts" is only 2 minutes long, not 4 minutes.
Does anyone know how to join the files together? Is FFMPEG the best program to use to do this? Thanks in advance.
-
How to comp portion of first frame onto rest of video without re-encoding ? [closed]
2 juillet, par jonathanI am working for a company recording educational screencasts using Goodnotes. The first frame looks fine, but as I work on the document, the page number pops up on the bottom left.
My bosses don't like this, so I've been trying to find a way to fix it on the screencast, since I can't find a way to turn it off in Goodnotes.
My current solution is taking a screenshot of the clean frame and using Gimp to crop out all but a small rectangle around where the page number would be, exporting that as a PNG and using ffmpeg to overlay that. The resulting image looks great and my bosses approve, but the script takes time to run since it needs to reencode. I'm wondering if there's a way to do this all with ffmpeg and run it with the
-c copy
flag since the first frame is clean. Please let me know if this is even possible. -
Use FFmpeg to create MPEG-DASH files
2 juillet, par angel_30I know using
ffmpeg
, we can create MPEG-DASH ready files, including the segments and the .mpd manifest file. For instance, I'm trying this command which works:ffmpeg -re -i .\video-h264.mkv -map 0 -map 0 -c:a aac -c:v libx264 -b:v:0 800k -b:v:1 300k -s:v:1 320x170 -profile:v:1 baseline -profile:v:0 main -bf 1 -keyint_min 120 -g 120 -sc_threshold 0 -b_strategy 0 -ar:a:1 22050 -use_timeline 1 -use_template 1 -window_size 5 -adaptation_sets "id=0,streams=v id=1,streams=a" -f dash out.mpd
But I don't want to segment the video- so a simpler version where we have multiple versions of the whole video, no chunks. Does MPEG-DASH allow it? If so, how can I use
ffmpeg
to do it without creating the chunks? -
UserWarning : x bytes wanted but 0 bytes read at frame index y (out of a total z frames), at time q sec. Using the last valid frame instead
1er juillet, par WizI have a script which subclips a larger video and then stitches needed parts together using concatenate and write video file in moviepy. But the problem is everytime i run the script i get the video but the audio is off sync, usually the audio starts normally, but over time becomes delayed. I suspect it is because i want to concatenate around 220 smaller mp4 videos into one big mp4 video, but every smaller clips receives the error:'UserWarning: In file test.mp4, 1555200 bytes wanted but 0 bytes read at frame index y (out of a total y+1 frames), at time x sec. Using the last valid frame instead.'
I use moviepy v2
MY CODE (it doesnt produce any strict errors, but does give the aformentioned UserWarning when writing video_unsilenced.mp4):
n = 0 cuts = [] input_paths = [] vc = [] os.makedirs(r"ShortsBot\SUBCLIPS") for timer in range(len(startsilence)-1): w = VideoFileClip(r"ShortsBot\output\cropped_video.mp4").subclipped(endsilence[n],(startsilence[n+1]+0.5)) w.write_videofile(r"ShortsBot\SUBCLIPS\video" + str(n) + ".mp4") a = VideoFileClip(r"ShortsBot\SUBCLIPS\video" + str(n) + ".mp4") vc.append(a) n+=1 output_fname = "video_unsilenced.mp4" clip = mpy.concatenate_videoclips(clips=vc, method= 'compose') clip.write_videofile(filename=output_fname, fps=30) _ = [a.close() for a in vc]
Because moviepy is shaving off a frame or two for every video clip and at the same time writing the audio of the concatenated clip normally (without shaving off the audio that is in the missing frames), the video and audio slowly become out of sync.And the more clips i want to concatenate, the more the audio becomes out of sync, basically confirming my suspicion that it is because moviepy is using the last valid frame and writing the audio normally. The question i have is how can i fix this? Ive looked for similar questions, but havent found the exact answer i was looking for. Sorry if this is something basic, im a beginner programmer in python and would really appreciate some tips or some sort of fix. Thanks everyone!