VideoHelp Forum
+ Reply to Thread
Results 1 to 9 of 9
Thread
  1. I have a bunch of m4v files in a folder (can be made mp4 if necessary) that I want to add a cover to, same one to all files. How can I do this? I figured out how to do it using MKVToolNix but that obviously only works for MKV files. I don't really understand scripting and stuff so I can't just whip together an FFMPEG script or anything, does anyone have a script that would work for this or some other way of doing it in one go? I don't want to have to do it manually.
    Quote Quote  
  2. This should work:

    Code:
    md New
    for %%F in (*.m4v) do ( ffmpeg -i "%%~dpnxF" -i thumbnail.png -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic "%%~dpF\New\%%~nF.m4v" )
    Put it in a batch file. You may need to specify the full path to ffmpeg if it's not in your search path. And put the batch file in the same folder as the m4v files. The thumbnail file should be in that folder too, named thumbnail.png. New files with the same name and embedded thumbnails will be created in a sub folder called New.
    Quote Quote  
  3. Kawaiiii
    Join Date
    May 2021
    Location
    Italy
    Search Comp PM
    Originally Posted by jagabo View Post
    This should work:

    Code:
    md New
    for %%F in (*.m4v) do ( ffmpeg -i "%%~dpnxF" -i thumbnail.png -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic "%%~dpF\New\%%~nF.m4v" )
    You're the batch file.. ffmpeg GOD!!!!
    Quote Quote  
  4. I didnt' know how to add the thumbnail. I had to search for it. The rest is common in other ffmpeg batch scripts. The thumbnails show up in Windows. I don't know about the Mac or other devices.
    Quote Quote  
  5. Originally Posted by jagabo View Post
    This should work:

    Code:
    md New
    for %%F in (*.m4v) do ( ffmpeg -i "%%~dpnxF" -i thumbnail.png -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic "%%~dpF\New\%%~nF.m4v" )
    Put it in a batch file. You may need to specify the full path to ffmpeg if it's not in your search path. And put the batch file in the same folder as the m4v files. The thumbnail file should be in that folder too, named thumbnail.png. New files with the same name and embedded thumbnails will be created in a sub folder called New.
    Thanks for the code, this didn't seem to work on my computer though. It just creates a folder with loads of 0 byte video files. In the cmd windows it said:

    Code:
    Tag text incompatible with output codec id '100359' ([0][0][0][0])
    Could not write header for output file #0 (incorrect codec parameters ?): Invalid data found when processing input
    Error initializing output stream 0:3 --
    On every video.

    Also would this script re-encode the files? For the MKV one it just added them without copying or anything, is that not possible with mp4/m4v?
    Quote Quote  
  6. No it shouldn't re-encode, it does however remux to an output file.
    This can be issue when you just want to modify header tags on large files (ex: 3GB), in which case an in-place operation may be preferable (if it is possible).

    I've used mp4v2\mp4art.exe for this type of thing in the past.

    Converting your mkv to mp4 with ffmpeg may also work.
    Quote Quote  
  7. Originally Posted by jagabo View Post
    This should work:

    Code:
    md New
    for %%F in (*.m4v) do ( ffmpeg -i "%%~dpnxF" -i thumbnail.png -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic "%%~dpF\New\%%~nF.m4v" )
    Put it in a batch file. You may need to specify the full path to ffmpeg if it's not in your search path. And put the batch file in the same folder as the m4v files. The thumbnail file should be in that folder too, named thumbnail.png. New files with the same name and embedded thumbnails will be created in a sub folder called New.
    Actually I think I got it to work, I just have to change the file extension of the output to mp4, idk why that makes it work but it does, thanks for the script! This will it a lot simpler to organise my stuff.
    Quote Quote  
  8. When I tested the batch file I used MP4 files -- since MP4 and M4V files are the same container. When I posted it I just changed the instances of MP4 to M4V and assumed it would work. As it turns out the M4V muxer is for Mpeg 4 Part 2 (Divx, Xvid, etc.) elementary streams. Thanks go to Apple for commandeering an existing extension for their own use.

    So yes, just change the output spec to MP4. And rename to M4V later if necessary:

    Code:
    md New
    for %%F in (*.m4v) do ( 
      ffmpeg -i "%%~dpnxF" -i thumbnail.png -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic "%%~dpFNew\%%~nF.mp4"
      move "%%~dpFNew\%%~nF.mp4" "%%~dpFNew\%%~nF.m4v"
      )
    Last edited by jagabo; 21st May 2021 at 08:16.
    Quote Quote  
  9. Originally Posted by jagabo View Post
    When I tested the batch file I used MP4 files -- since MP4 and M4V files are the same container. When I posted it I just changed the instances of MP4 to M4V and assumed it would work. As it turns out the M4V muxer is for Mpeg 4 Part 2 (Divx, Xvid, etc.) elementary streams. Thanks go to Apple for commandeering an existing extension for their own use.

    So yes, just change the output spec to MP4. And rename to M4V later if necessary:

    Code:
    md New
    for %%F in (*.m4v) do ( 
      ffmpeg -i "%%~dpnxF" -i thumbnail.png -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic "%%~dpFNew\%%~nF.mp4"
      move "%%~dpFNew\%%~nF.mp4" "%%~dpFNew\%%~nF.m4v"
      )
    Thanks, they were allm4v as that's what handbrake seems to default to, I'm not sure why lol it's Apple's standard isn't it?

    That script didn't seem to work if the png was changed to a jpg, I managed to use the loop script and another thumbnail script I found to make this which seems to work with jpg, is there any real difference in the outcome? I know some of the arguments are a bit different but idk what they mean.

    Code:
    @echo off
    md New
    for %%F in (*.m4v) do ( ffmpeg -i "%%~dpnxF" -i cover.jpg -map 1 -map 0 -c copy -disposition:0 attached_pic "%%~dpF\New\%%~nF.mp4" )
    pause
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!