I have written a program to extract a frame of YUV video using ffmpeg.
If the video comes directly from a camcorder, all of the Y, U and V values are set to 0.
If the video file has been rewritten using, say, ffmpeg, the video appears normally using the exact same code. The video files are .mp4 with H.264. All video plays back OK using any video player program.
Here is the code that reads the video frames into the program:
My program is written in PureBasic, based on a C language program.Code:pipeIn$ = "-i " + filename$ + " -f image2pipe -s 1280x720 -pix_fmt yuv420p -vcodec rawvideo -" readFrame = RunProgram("ffmpeg.exe", pipeIn$, "", #PB_Program_Open | #PB_Program_Read)
https://batchloaf.wordpress.com/2017/02/12/a-simple-way-to-read-and-write-audio-and-vi...-part-2-video/
Why do some files work OK and others not?
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 16 of 16
Thread
-
-
What are the other differences between the videos that work , and the ones that do not ? Are both MP4 with h264 video ?
Could it be something simple like path error, or filename error ?
If the video file has been rewritten using, say, ffmpeg, the video appears normally using the exact same code -
What are the other differences between the videos that work , and the ones that do not ? Are both MP4 with h264 video ?
What do mean "rewritten" ? Stream copy ? Re-encode ?
Code:ffmpeg -y -i myvideo.mp4 myoutvideo.mp4
-
Directly out? Is the camcorder file copied to a local HDD ? or still in the camcorder / media card ?
What does mediainfo (view=>text) say about the camcorder file ?
What about stream copying the file? ( -c:v copy ) . Does that work ?
All camcorder files, or only from that specific camcorder ? or only specific files ? -
The files are transferred from the camcorder to a local HD via a USB connection.
It happens with both a Sony and a Canon camcorder.
There is a lot of stuff in MediaInfo which I don't know how to interpret, so here they are:
Re-encoded with ffmpeg:
Code:General Complete name : D:\Videos\Interpositives\fixed.mp4 Format : MPEG-4 Format profile : Base Media Codec ID : isom (isom/iso2/avc1/mp41) File size : 1.25 MiB Duration : 12 s 523 ms Overall bit rate : 837 kb/s Writing application : Lavf58.33.100 Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : High@L3.2 Format settings : CABAC / 4 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 4 frames Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 12 s 513 ms Bit rate : 692 kb/s Width : 1 280 pixels Height : 720 pixels Display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 59.940 (60000/1001) FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.013 Stream size : 1.03 MiB (83%) Writing library : x264 core 158 Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=23.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00 Language : English Codec configuration box : avcC Audio ID : 2 Format : AAC LC Format/Info : Advanced Audio Codec Low Complexity Codec ID : mp4a-40-2 Duration : 12 s 523 ms Bit rate mode : Constant Bit rate : 132 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 48.0 kHz Frame rate : 46.875 FPS (1024 SPF) Compression mode : Lossy Stream size : 201 KiB (16%) Language : English Default : Yes Alternate group : 1 Other ID : 3 Type : Time code Format : QuickTime TC Duration : 12 s 513 ms Frame rate : 59.940 (60000/1001) FPS Time code of first frame : 00:38:44;20 Time code, striped : Yes Language : English Default : No
Code:General Complete name : D:\Videos\Canon Vixia HF G40\VelvetSharpLo.MP4 Format : MPEG-4 Format profile : Base Media / Version 2 Codec ID : mp42 (mp42/avc1/CAEP) File size : 11.9 MiB Duration : 12 s 513 ms Overall bit rate : 7 958 kb/s Encoded date : UTC 2018-05-09 13:22:34 Tagged date : UTC 2018-05-09 13:22:34 Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : Main@L3.2 Format settings : CABAC / 2 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 2 frames Format settings, GOP : M=3, N=30 Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 12 s 513 ms Bit rate : 7 656 kb/s Width : 1 280 pixels Height : 720 pixels Display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 59.940 (60000/1001) FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.139 Stream size : 11.4 MiB (96%) Language : English Encoded date : UTC 2018-05-09 13:22:34 Tagged date : UTC 2018-05-09 13:22:34 Color range : Limited Color primaries : BT.709 Transfer characteristics : BT.709 Matrix coefficients : BT.709 Codec configuration box : avcC Audio ID : 2 Format : AAC LC Format/Info : Advanced Audio Codec Low Complexity Codec ID : mp4a-40-2 Duration : 12 s 501 ms Bit rate mode : Constant Bit rate : 128 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 48.0 kHz Frame rate : 46.875 FPS (1024 SPF) Compression mode : Lossy Stream size : 195 KiB (2%) Language : English Encoded date : UTC 2018-05-09 13:22:34 Tagged date : UTC 2018-05-09 13:22:34 Other ID : 3 Type : Time code Format : QuickTime TC Duration : 12 s 513 ms Bit rate mode : Constant Frame rate : 59.940 (60000/1001) FPS Time code of first frame : 00:38:44;20 Time code, striped : Yes Language : English Encoded date : UTC 2018-05-09 13:22:34 Tagged date : UTC 2018-05-09 13:22:34
-
I don't know . Nothing there jumps out as the culprit. If it works for the reencoded one, it should work for the source.
One difference is the subset of MP4 container. mp42 vs. isom mp41 . Earlier I asked you to stream copy and test that. Rewrap it using the default ffmpeg mp4 muxer profile (isom mp41) . In theory it shouldn't make a difference. If it works, at least the values read off will be accurate, instead of a lossy re-encode. Steam copy will also be faster and much smaller than a lossless re-encode -
It works OK with -c:v copy
Code:General Complete name : D:\Videos\Interpositives\streamed.mp4 Format : MPEG-4 Format profile : Base Media Codec ID : isom (isom/iso2/avc1/mp41) File size : 11.6 MiB Duration : 12 s 523 ms Overall bit rate : 7 795 kb/s Writing application : Lavf58.33.100 Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : Main@L3.2 Format settings : CABAC / 2 Ref Frames Format settings, CABAC : Yes Format settings, Reference frames : 2 frames Format settings, GOP : M=3, N=30 Codec ID : avc1 Codec ID/Info : Advanced Video Coding Duration : 12 s 513 ms Bit rate : 7 656 kb/s Width : 1 280 pixels Height : 720 pixels Display aspect ratio : 16:9 Frame rate mode : Constant Frame rate : 59.940 (60000/1001) FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.139 Stream size : 11.4 MiB (98%) Language : English Color range : Limited Color primaries : BT.709 Transfer characteristics : BT.709 Matrix coefficients : BT.709 Codec configuration box : avcC Audio ID : 2 Format : AAC LC Format/Info : Advanced Audio Codec Low Complexity Codec ID : mp4a-40-2 Duration : 12 s 523 ms Bit rate mode : Constant Bit rate : 132 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 48.0 kHz Frame rate : 46.875 FPS (1024 SPF) Compression mode : Lossy Stream size : 201 KiB (2%) Language : English Default : Yes Alternate group : 1 Other ID : 3 Type : Time code Format : QuickTime TC Duration : 12 s 513 ms Frame rate : 59.940 (60000/1001) FPS Time code of first frame : 00:38:44;20 Time code, striped : Yes Language : English Default : No
-
Completely unexpected.
FFmpeg can read the native camera file, it should be able to pipe it . The container should have nothing to do with it at that point
If the program is giving off values at "zero" , that's more like it's not reading the file at all . Are there error codes or other clues ? -
No error codes.
Why would it work OK on some files but not others?
The original camcorder footage plays OK in any video player. -
I don't know. It doesn't make any sense. It sounds like the original footage is ok - I doubt that is the problem
The one difference is the mp4 container. mp42 (mp4 v2) is a newer profile, but it shouldn't matter. You stream copied it out of that container into the older MP4 profile container and reported that worked. That's the only tangible difference I can see. But once ffmpeg reads it, it pipes the rawvideo data . It obviously can read it from any container variation (including mp42) - other wise you couldn't have re-encoded the original.
The other possible explanation is something simple, like a path or name error. -
If it were a path or name error it wouldn't be able to read the files it does.
-
Are you sure it's reading it when giving off "zero" ?
The paths and names are obviously different on the files that work. The ones in the "Interpositives" folder work -
Problem solved:
Had to remove all spaces from directory names. The program was not finding the files and was trying to load blanks.
Similar Threads
-
Weird Artifacts when extracting video frames to png in ffmpeg
By Blackcero in forum Newbie / General discussionsReplies: 10Last Post: 7th Jul 2018, 10:32 -
Can I force ffmpeg to transcode 59.94 frames to display at 25 frames per se
By oduodui in forum EditingReplies: 4Last Post: 28th Apr 2018, 09:24 -
FFMPEG PNSR Match frames
By themoog in forum Video ConversionReplies: 1Last Post: 13th Nov 2016, 09:29 -
ffmpeg: setting IDR frames option.
By Prathamesh in forum Video ConversionReplies: 10Last Post: 12th Nov 2015, 14:22 -
Using ffmpeg to extract frames from mts file fails
By Prototype v1.0 in forum Video ConversionReplies: 30Last Post: 1st May 2015, 00:39