VideoHelp Forum

Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !
+ Reply to Thread
Results 1 to 16 of 16
Thread
  1. 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:

    Code:
    pipeIn$ = "-i " + filename$ + " -f image2pipe  -s 1280x720  -pix_fmt yuv420p  -vcodec rawvideo -"
    
    readFrame = RunProgram("ffmpeg.exe", pipeIn$, "", #PB_Program_Open | #PB_Program_Read)
    My program is written in PureBasic, based on a C language program.

    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?
    Quote Quote  
  2. 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 do mean "rewritten" ? Stream copy ? Re-encode ?
    Quote Quote  
  3. What are the other differences between the videos that work , and the ones that do not ? Are both MP4 with h264 video ?
    Yes, both are .mp4 with H.264 video as far as I can tell. The only difference I can discern is one is directly out of the camcorder and the other has been re-encoded.

    What do mean "rewritten" ? Stream copy ? Re-encode ?
    Re-encoded, e.g.

    Code:
    ffmpeg -y  -i  myvideo.mp4  myoutvideo.mp4
    I would like to be able to read the camcorder file directly, without the re-encoding step.
    Quote Quote  
  4. 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 ?
    Quote Quote  
  5. 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
    Directly out of Canon HF G40 Camcorder:

    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
    Quote Quote  
  6. 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
    Quote Quote  
  7. 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
    Quote Quote  
  8. Originally Posted by chris319 View Post
    It works OK with -c:v copy
    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 ?
    Quote Quote  
  9. No error codes.

    Why would it work OK on some files but not others?

    The original camcorder footage plays OK in any video player.
    Quote Quote  
  10. Originally Posted by chris319 View Post
    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.
    Quote Quote  
  11. If it were a path or name error it wouldn't be able to read the files it does.
    Quote Quote  
  12. 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
    Quote Quote  
  13. Checked the file names/paths; no problems found.
    Quote Quote  
  14. Problem solved:

    Had to remove all spaces from directory names. The program was not finding the files and was trying to load blanks.
    Quote Quote  
  15. Spaces should work if you enclose path and names in quotes
    Quote Quote  
  16. Originally Posted by poisondeathray View Post
    Spaces should work if you enclose path and names in quotes
    Yes, that works very nicely, thank you.
    Quote Quote  



Similar Threads